Bugfixes & UI updates
This commit is contained in:
@@ -106,24 +106,13 @@ export function useMutationAPI() {
|
||||
}: {
|
||||
method: string;
|
||||
endpoint: string;
|
||||
body?: object | undefined | null;
|
||||
body: object | undefined | null;
|
||||
}) => callEndpoint(method, endpoint, body),
|
||||
onMutate: () => {},
|
||||
onSuccess: (data, variables) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['GET', variables.endpoint] });
|
||||
|
||||
if (variables.endpoint.includes('/')) {
|
||||
if ((variables.endpoint.match(/\//g) || []).length > 2) {
|
||||
const GetEndpoint = variables.endpoint.split('/');
|
||||
const Endpoint = `${GetEndpoint[1]}/${GetEndpoint[2]}`;
|
||||
queryClient.invalidateQueries({ queryKey: ['GET', `/${Endpoint}`] });
|
||||
} else {
|
||||
const GetEndpoint = variables.endpoint.split('/')[1];
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['GET', `/${GetEndpoint}`],
|
||||
});
|
||||
}
|
||||
}
|
||||
onMutate: () => {
|
||||
queryClient.invalidateQueries();
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user