Skip to content

Commit 2d8fff6

Browse files
committed
add entity headers in every graphql call on provider side
1 parent 3c4bb3f commit 2d8fff6

File tree

13 files changed

+110
-45
lines changed

13 files changed

+110
-45
lines changed

app/[locale]/dashboard/[entityType]/[entitySlug]/admin/addUser.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ const AddUser = ({
7777
() =>
7878
GraphQL(
7979
FetchUsers,
80-
{},
80+
{
81+
[params.entityType]: params.entitySlug,
82+
},
8183
{
8284
limit: 10,
8385
searchTerm: searchValue,

app/[locale]/dashboard/[entityType]/[entitySlug]/charts/components/ChartsImage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ const ChartsImage: React.FC<ImageProps> = ({
183183

184184
const { mutate, isLoading: editMutationLoading } = useMutation(
185185
(data: { data: ResourceChartImageInputPartial }) =>
186-
GraphQL(UpdateChartImageMutation, {}, data),
186+
GraphQL(UpdateChartImageMutation, {
187+
[params.entityType]: params.entitySlug,
188+
}, data),
187189
{
188190
onSuccess: () => {
189191
toast('ChartImage updated successfully');

app/[locale]/dashboard/[entityType]/[entitySlug]/dataset/[id]/edit/resources/components/EditResource.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const resourceDetails: any = graphql(`
8888
`);
8989

9090
export const EditResource = ({ refetch, allResources }: EditProps) => {
91-
const params = useParams();
91+
const params = useParams<{ entityType: string; entitySlug: string; id: string }>();
9292

9393
const [resourceId, setResourceId] = useQueryState<any>('id', parseAsString);
9494
const [schema, setSchema] = React.useState([]);
@@ -99,7 +99,7 @@ export const EditResource = ({ refetch, allResources }: EditProps) => {
9999
GraphQL(
100100
resourceDetails,
101101
{
102-
// Entity Headers if present
102+
[params.entityType]: params.entitySlug,
103103
},
104104
{ resourceId: resourceId }
105105
),
@@ -112,7 +112,7 @@ export const EditResource = ({ refetch, allResources }: EditProps) => {
112112
GraphQL(
113113
resetSchema,
114114
{
115-
// Entity Headers if present
115+
[params.entityType]: params.entitySlug,
116116
},
117117
data
118118
),
@@ -134,7 +134,7 @@ export const EditResource = ({ refetch, allResources }: EditProps) => {
134134
GraphQL(
135135
updateResourceDoc,
136136
{
137-
// Entity Headers if present
137+
[params.entityType]: params.entitySlug,
138138
},
139139
data
140140
),
@@ -165,7 +165,7 @@ export const EditResource = ({ refetch, allResources }: EditProps) => {
165165
GraphQL(
166166
updateSchema,
167167
{
168-
// Entity Headers if present
168+
[params.entityType]: params.entitySlug,
169169
},
170170
data
171171
),
@@ -189,7 +189,7 @@ export const EditResource = ({ refetch, allResources }: EditProps) => {
189189
GraphQL(
190190
createResourceFilesDoc,
191191
{
192-
// Entity Headers if present
192+
[params.entityType]: params.entitySlug,
193193
},
194194
data
195195
),

app/[locale]/dashboard/[entityType]/[entitySlug]/layout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export default function OrgDashboardLayout({ children }: DashboardLayoutProps) {
2828
useQuery([`entity_details_${params.entityType}`], () =>
2929
GraphQL(
3030
params.entityType === 'organization' && getOrgDetailsQryDoc,
31-
{},
31+
{
32+
[params.entityType]: params.entitySlug,
33+
},
3234
{ slug: params.entitySlug }
3335
)
3436
);

app/[locale]/dashboard/[entityType]/[entitySlug]/profile/orgProfile.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ const OrgProfile = () => {
8181

8282
const { mutate, isLoading: editMutationLoading } = useMutation(
8383
(input: { input: OrganizationInputPartial }) =>
84-
GraphQL(organizationUpdateMutation, {}, input),
84+
GraphQL(organizationUpdateMutation, {
85+
[params.entityType]: params.entitySlug,
86+
}, input),
8587
{
8688
onSuccess: (res: any) => {
8789
toast('Organization updated successfully');

app/[locale]/dashboard/[entityType]/[entitySlug]/profile/userProfile.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const updateUserMutation: any = graphql(`
3636
`);
3737

3838
const UserProfile = () => {
39-
const params = useParams<{ entitySlug: string }>();
39+
const params = useParams<{ entityType: string; entitySlug: string }>();
4040

4141
const { setUserDetails, userDetails } = useDashboardStore();
4242

@@ -70,7 +70,9 @@ const UserProfile = () => {
7070

7171
const { mutate, isLoading: editMutationLoading } = useMutation(
7272
(input: { input: UpdateUserInput }) =>
73-
GraphQL(updateUserMutation, {}, input),
73+
GraphQL(updateUserMutation, {
74+
[params.entityType]: params.entitySlug,
75+
}, input),
7476
{
7577
onSuccess: (res: any) => {
7678
toast('User details updated successfully');

app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/assign/page.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ const AssignUsecaseDatasets: any = graphql(`
4242
}
4343
`);
4444
const Assign = () => {
45-
const params = useParams();
45+
const params = useParams<{
46+
entityType: string;
47+
entitySlug: string;
48+
id: string;
49+
}>();
4650
const router = useRouter();
4751

4852
const [data, setData] = useState<any[]>([]); // Ensure `data` is an array
@@ -54,7 +58,9 @@ const Assign = () => {
5458
() =>
5559
GraphQL(
5660
FetchUseCaseDetails,
57-
{},
61+
{
62+
[params.entityType]: params.entitySlug,
63+
},
5864
{
5965
filters: {
6066
id: params.id,
@@ -87,15 +93,12 @@ const Assign = () => {
8793
});
8894
}, []);
8995

90-
91-
9296
const columns = [
9397
{ accessorKey: 'title', header: 'Title' },
9498
{ accessorKey: 'category', header: 'Sector' },
9599
{ accessorKey: 'modified', header: 'Last Modified' },
96100
];
97101

98-
99102
const generateTableData = (list: Array<any>) => {
100103
return list.map((item) => {
101104
return {
@@ -111,7 +114,9 @@ const Assign = () => {
111114
() =>
112115
GraphQL(
113116
AssignUsecaseDatasets,
114-
{},
117+
{
118+
[params.entityType]: params.entitySlug,
119+
},
115120
{
116121
useCaseId: params.id,
117122
datasetIds: Array.isArray(selectedRow)
@@ -123,7 +128,9 @@ const Assign = () => {
123128
onSuccess: (data: any) => {
124129
toast('Dataset Assigned Successfully');
125130
UseCaseDetails.refetch();
126-
router.push(`/dashboard/${params.entityType}/${params.entitySlug}/usecases/edit/${params.id}/contributors`);
131+
router.push(
132+
`/dashboard/${params.entityType}/${params.entitySlug}/usecases/edit/${params.id}/contributors`
133+
);
127134
},
128135
onError: (err: any) => {
129136
toast(`Received ${err} on dataset publish `);

app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/contributors/page.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
} from './query';
2626

2727
const Details = () => {
28-
const params = useParams<{ id: string }>();
28+
const params = useParams<{ entityType: string; entitySlug: string; id: string }>();
2929
const [searchValue, setSearchValue] = useState('');
3030
const [formData, setFormData] = useState({
3131
contributors: [] as { label: string; value: string }[],
@@ -38,7 +38,9 @@ const Details = () => {
3838
() =>
3939
GraphQL(
4040
FetchUsers,
41-
{},
41+
{
42+
[params.entityType]: params.entitySlug,
43+
},
4244
{
4345
limit: 10,
4446
searchTerm: searchValue,
@@ -51,15 +53,19 @@ const Details = () => {
5153
);
5254

5355
const Organizations: { data: any; isLoading: boolean; refetch: any } =
54-
useQuery([`fetch_orgs`], () => GraphQL(OrgList, {}, []));
56+
useQuery([`fetch_orgs`], () => GraphQL(OrgList, {
57+
[params.entityType]: params.entitySlug,
58+
}, []));
5559

5660

5761
const UseCaseData: { data: any; isLoading: boolean; refetch: any } = useQuery(
5862
[`fetch_usecase_${params.id}`],
5963
() =>
6064
GraphQL(
6165
FetchUsecaseInfo,
62-
{},
66+
{
67+
[params.entityType]: params.entitySlug,
68+
},
6369
{
6470
filters: {
6571
id: params.id,
@@ -100,7 +106,9 @@ const Details = () => {
100106
const { mutate: addContributor, isLoading: addContributorLoading } =
101107
useMutation(
102108
(input: { useCaseId: string; userId: string }) =>
103-
GraphQL(AddContributors, {}, input),
109+
GraphQL(AddContributors, {
110+
[params.entityType]: params.entitySlug,
111+
}, input),
104112
{
105113
onSuccess: (res: any) => {
106114
toast('Contributor added successfully');
@@ -115,7 +123,9 @@ const Details = () => {
115123
const { mutate: removeContributor, isLoading: removeContributorLoading } =
116124
useMutation(
117125
(input: { useCaseId: string; userId: string }) =>
118-
GraphQL(RemoveContributor, {}, input),
126+
GraphQL(RemoveContributor, {
127+
[params.entityType]: params.entitySlug,
128+
}, input),
119129
{
120130
onSuccess: (res: any) => {
121131
toast('Contributor removed successfully');
@@ -128,7 +138,9 @@ const Details = () => {
128138

129139
const { mutate: addSupporter, isLoading: addSupporterLoading } = useMutation(
130140
(input: { useCaseId: string; organizationId: string }) =>
131-
GraphQL(AddSupporters, {}, input),
141+
GraphQL(AddSupporters, {
142+
[params.entityType]: params.entitySlug,
143+
}, input),
132144
{
133145
onSuccess: (res: any) => {
134146
toast('Supporter added successfully');
@@ -143,7 +155,9 @@ const Details = () => {
143155
const { mutate: removeSupporter, isLoading: removeSupporterLoading } =
144156
useMutation(
145157
(input: { useCaseId: string; organizationId: string }) =>
146-
GraphQL(RemoveSupporters, {}, input),
158+
GraphQL(RemoveSupporters, {
159+
[params.entityType]: params.entitySlug,
160+
}, input),
147161
{
148162
onSuccess: (res: any) => {
149163
toast('Supporter removed successfully');
@@ -156,7 +170,9 @@ const Details = () => {
156170

157171
const { mutate: addPartner, isLoading: addPartnerLoading } = useMutation(
158172
(input: { useCaseId: string; organizationId: string }) =>
159-
GraphQL(AddPartners, {}, input),
173+
GraphQL(AddPartners, {
174+
[params.entityType]: params.entitySlug,
175+
}, input),
160176
{
161177
onSuccess: (res: any) => {
162178
toast('Partner added successfully');
@@ -171,7 +187,9 @@ const Details = () => {
171187
const { mutate: removePartner, isLoading: removePartnerLoading } =
172188
useMutation(
173189
(input: { useCaseId: string; organizationId: string }) =>
174-
GraphQL(RemovePartners, {}, input),
190+
GraphQL(RemovePartners, {
191+
[params.entityType]: params.entitySlug,
192+
}, input),
175193
{
176194
onSuccess: (res: any) => {
177195
toast('Partner removed successfully');

app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/dashboards/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const deleteDashboard: any = graphql(`
7373
}
7474
`);
7575

76-
const Dashboard = ({ params }: { params: { id: string } }) => {
76+
const Dashboard = ({ params }: { params: { entityType: string; entitySlug: string; id: string } }) => {
7777
const usecaseId = parseInt(params.id);
7878

7979
const [dashboards, setDashboards] = useState<
@@ -83,7 +83,7 @@ const Dashboard = ({ params }: { params: { id: string } }) => {
8383

8484
const { data, isLoading } = useQuery(
8585
['fetch_dashboardData', usecaseId],
86-
() => GraphQL(dashboardList, {}, { usecaseId }),
86+
() => GraphQL(dashboardList, { [params.entityType]: params.entitySlug }, { usecaseId }),
8787
{
8888
refetchOnMount: true,
8989
refetchOnReconnect: true,
@@ -100,7 +100,7 @@ const Dashboard = ({ params }: { params: { id: string } }) => {
100100

101101
const { mutate: addDashboard, isLoading: addLoading } = useMutation(
102102
({ usecaseId }: { usecaseId: number }) =>
103-
GraphQL(AddDashboard, {}, { usecaseId }),
103+
GraphQL(AddDashboard, { [params.entityType]: params.entitySlug }, { usecaseId }),
104104
{
105105
onSuccess: (res: any) => {
106106
const newDashboard = res.addUsecaseDashboard.data;
@@ -116,7 +116,7 @@ const Dashboard = ({ params }: { params: { id: string } }) => {
116116
);
117117
const { mutate: saveDashboard, isLoading: saveLoading } = useMutation(
118118
({ id, name, link }: { id: string; name: string; link: string }) =>
119-
GraphQL(updateDashboard, {}, { id, name, link }),
119+
GraphQL(updateDashboard, { [params.entityType]: params.entitySlug }, { id, name, link }),
120120
{
121121
onSuccess: ({ updateUsecaseDashboard }: any) => {
122122
toast.success('Changes saved');
@@ -132,7 +132,7 @@ const Dashboard = ({ params }: { params: { id: string } }) => {
132132
);
133133

134134
const { mutate: removeDashboard, isLoading: deleteLoading } = useMutation(
135-
(id: number) => GraphQL(deleteDashboard, {}, { id }),
135+
(id: number) => GraphQL(deleteDashboard, { [params.entityType]: params.entitySlug }, { id }),
136136
{
137137
onSuccess: (_, id) => {
138138
setDashboards((prev) => prev.filter((d) => d.id !== id.toString()));

app/[locale]/dashboard/[entityType]/[entitySlug]/usecases/edit/[id]/details/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ const Details = () => {
7373
() =>
7474
GraphQL(
7575
FetchUseCase,
76-
{},
76+
{
77+
[params.entityType]: params.entitySlug,
78+
},
7779
{
7880
filters: {
7981
id: params.id,
@@ -147,7 +149,9 @@ const Details = () => {
147149

148150
const { mutate, isLoading: editMutationLoading } = useMutation(
149151
(data: { data: UseCaseInputPartial }) =>
150-
GraphQL(UpdateUseCaseMutation, {}, data),
152+
GraphQL(UpdateUseCaseMutation, {
153+
[params.entityType]: params.entitySlug,
154+
}, data),
151155
{
152156
onSuccess: (res: any) => {
153157
toast('Use case updated successfully');

0 commit comments

Comments
 (0)