Skip to content

Commit 2120e46

Browse files
committed
Refactor GraphQL queries in DatasetPage to include entityType and entitySlug parameters
1 parent 2598224 commit 2120e46

File tree

1 file changed

+33
-12
lines changed
  • app/[locale]/dashboard/[entityType]/[entitySlug]/usecases

1 file changed

+33
-12
lines changed

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

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export default function DatasetPage({
7171
() =>
7272
GraphQL(
7373
allUseCases,
74-
{},
74+
{
75+
[params.entityType]: params.entitySlug,
76+
},
7577
{
7678
filters: {
7779
status: navigationTab === 'published' ? 'PUBLISHED' : 'DRAFT',
@@ -98,7 +100,13 @@ export default function DatasetPage({
98100
} = useMutation(
99101
[`delete_Usecase`],
100102
(data: { id: string }) =>
101-
GraphQL(deleteUseCase, {}, { useCaseId: data.id }),
103+
GraphQL(
104+
deleteUseCase,
105+
{
106+
[params.entityType]: params.entitySlug,
107+
},
108+
{ useCaseId: data.id }
109+
),
102110
{
103111
onSuccess: () => {
104112
toast(`Deleted UseCase successfully`);
@@ -114,16 +122,29 @@ export default function DatasetPage({
114122
mutate: any;
115123
isLoading: boolean;
116124
error: any;
117-
} = useMutation([`delete_Usecase`], () => GraphQL(AddUseCase, {}, []), {
118-
onSuccess: (response: any) => {
119-
toast(`UseCase created successfully`);
120-
router.push(`/dashboard/${params.entityType}/${params.entitySlug}/usecases/edit/${response.addUseCase.id}/details`);
121-
AllUseCases.refetch();
122-
},
123-
onError: (err: any) => {
124-
toast('Error: ' + err.message.split(':')[0]);
125-
},
126-
});
125+
} = useMutation(
126+
[`delete_Usecase`],
127+
() =>
128+
GraphQL(
129+
AddUseCase,
130+
{
131+
[params.entityType]: params.entitySlug,
132+
},
133+
[]
134+
),
135+
{
136+
onSuccess: (response: any) => {
137+
toast(`UseCase created successfully`);
138+
router.push(
139+
`/dashboard/${params.entityType}/${params.entitySlug}/usecases/edit/${response.addUseCase.id}/details`
140+
);
141+
AllUseCases.refetch();
142+
},
143+
onError: (err: any) => {
144+
toast('Error: ' + err.message.split(':')[0]);
145+
},
146+
}
147+
);
127148

128149
const datasetsListColumns = [
129150
{

0 commit comments

Comments
 (0)