F: Add query invalidation after error in mutation
This commit is contained in:
parent
8c0d5bfca7
commit
be1edcd949
|
@ -10,7 +10,8 @@ export const useCloneItem = () => {
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationKey: [KEYS.global_mutation, libraryApi.baseKey, 'clone-item'],
|
mutationKey: [KEYS.global_mutation, libraryApi.baseKey, 'clone-item'],
|
||||||
mutationFn: libraryApi.cloneItem,
|
mutationFn: libraryApi.cloneItem,
|
||||||
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] })
|
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] }),
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cloneItem: (data: ICloneLibraryItemDTO) => mutation.mutateAsync(data)
|
cloneItem: (data: ICloneLibraryItemDTO) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -10,7 +10,8 @@ export const useCreateItem = () => {
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationKey: [KEYS.global_mutation, libraryApi.baseKey, 'create-item'],
|
mutationKey: [KEYS.global_mutation, libraryApi.baseKey, 'create-item'],
|
||||||
mutationFn: libraryApi.createItem,
|
mutationFn: libraryApi.createItem,
|
||||||
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] })
|
onSuccess: () => client.invalidateQueries({ queryKey: [libraryApi.baseKey] }),
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
createItem: (data: ICreateLibraryItemDTO) => mutation.mutateAsync(data),
|
createItem: (data: ICreateLibraryItemDTO) => mutation.mutateAsync(data),
|
||||||
|
|
|
@ -21,7 +21,8 @@ export const useDeleteItem = () => {
|
||||||
]).catch(console.error),
|
]).catch(console.error),
|
||||||
PARAMETER.navigationDuration
|
PARAMETER.navigationDuration
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
deleteItem: (target: number) => mutation.mutateAsync(target),
|
deleteItem: (target: number) => mutation.mutateAsync(target),
|
||||||
|
|
|
@ -15,7 +15,8 @@ export const useRenameLocation = () => {
|
||||||
client.invalidateQueries({ queryKey: [KEYS.library] }),
|
client.invalidateQueries({ queryKey: [KEYS.library] }),
|
||||||
client.invalidateQueries({ queryKey: [KEYS.rsform] }),
|
client.invalidateQueries({ queryKey: [KEYS.rsform] }),
|
||||||
client.invalidateQueries({ queryKey: [KEYS.oss] })
|
client.invalidateQueries({ queryKey: [KEYS.oss] })
|
||||||
])
|
]),
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
renameLocation: (data: IRenameLocationDTO) => mutation.mutateAsync(data)
|
renameLocation: (data: IRenameLocationDTO) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -39,7 +39,8 @@ export const useSetAccessPolicy = () => {
|
||||||
client.setQueryData(libraryApi.libraryListKey, (prev: ILibraryItem[] | undefined) =>
|
client.setQueryData(libraryApi.libraryListKey, (prev: ILibraryItem[] | undefined) =>
|
||||||
prev?.map(item => (item.id === variables.itemID ? { ...item, access_policy: variables.policy } : item))
|
prev?.map(item => (item.id === variables.itemID ? { ...item, access_policy: variables.policy } : item))
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -34,7 +34,8 @@ export const useSetEditors = () => {
|
||||||
client.setQueryData(rsKey, (prev: IRSFormDTO | undefined) =>
|
client.setQueryData(rsKey, (prev: IRSFormDTO | undefined) =>
|
||||||
!prev ? undefined : { ...prev, editors: variables.editors }
|
!prev ? undefined : { ...prev, editors: variables.editors }
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -39,7 +39,8 @@ export const useSetLocation = () => {
|
||||||
client.setQueryData(libraryApi.libraryListKey, (prev: ILibraryItem[] | undefined) =>
|
client.setQueryData(libraryApi.libraryListKey, (prev: ILibraryItem[] | undefined) =>
|
||||||
prev?.map(item => (item.id === variables.itemID ? { ...item, location: variables.location } : item))
|
prev?.map(item => (item.id === variables.itemID ? { ...item, location: variables.location } : item))
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -39,7 +39,8 @@ export const useSetOwner = () => {
|
||||||
client.setQueryData(libraryApi.libraryListKey, (prev: ILibraryItem[] | undefined) =>
|
client.setQueryData(libraryApi.libraryListKey, (prev: ILibraryItem[] | undefined) =>
|
||||||
prev?.map(item => (item.id === variables.itemID ? { ...item, owner: variables.owner } : item))
|
prev?.map(item => (item.id === variables.itemID ? { ...item, owner: variables.owner } : item))
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -32,7 +32,8 @@ export const useUpdateItem = () => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
updateItem: (data: IUpdateLibraryItemDTO) => mutation.mutateAsync(data)
|
updateItem: (data: IUpdateLibraryItemDTO) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -15,7 +15,8 @@ export const useVersionCreate = () => {
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
client.setQueryData(KEYS.composite.rsItem({ itemID: data.schema.id }), data.schema);
|
client.setQueryData(KEYS.composite.rsItem({ itemID: data.schema.id }), data.schema);
|
||||||
updateTimestamp(data.schema.id);
|
updateTimestamp(data.schema.id);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionCreate: (data: { itemID: number; data: IVersionCreateDTO }) =>
|
versionCreate: (data: { itemID: number; data: IVersionCreateDTO }) =>
|
||||||
|
|
|
@ -20,7 +20,8 @@ export const useVersionDelete = () => {
|
||||||
versions: prev.versions.filter(version => version.id !== variables.versionID)
|
versions: prev.versions.filter(version => version.id !== variables.versionID)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionDelete: (data: { itemID: number; versionID: number }) => mutation.mutateAsync(data)
|
versionDelete: (data: { itemID: number; versionID: number }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -12,7 +12,8 @@ export const useVersionRestore = () => {
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
client.setQueryData(KEYS.composite.rsItem({ itemID: data.id }), data);
|
client.setQueryData(KEYS.composite.rsItem({ itemID: data.id }), data);
|
||||||
return client.invalidateQueries({ queryKey: [libraryApi.baseKey] });
|
return client.invalidateQueries({ queryKey: [libraryApi.baseKey] });
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionRestore: (data: { versionID: number }) => mutation.mutateAsync(data)
|
versionRestore: (data: { versionID: number }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -23,7 +23,8 @@ export const useVersionUpdate = () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
versionUpdate: (data: { itemID: number; version: IVersionUpdateDTO }) => mutation.mutateAsync(data)
|
versionUpdate: (data: { itemID: number; version: IVersionUpdateDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { ossApi } from './api';
|
import { ossApi } from './api';
|
||||||
|
|
||||||
export const useFindPredecessor = () => {
|
export const useFindPredecessor = () => {
|
||||||
|
const client = useQueryClient();
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationKey: [ossApi.baseKey, 'find-predecessor'],
|
mutationKey: [ossApi.baseKey, 'find-predecessor'],
|
||||||
mutationFn: ossApi.getPredecessor
|
mutationFn: ossApi.getPredecessor,
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
findPredecessor: (target: number) => mutation.mutateAsync({ target: target })
|
findPredecessor: (target: number) => mutation.mutateAsync({ target: target })
|
||||||
|
|
|
@ -16,7 +16,8 @@ export const useInputCreate = () => {
|
||||||
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
||||||
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
inputCreate: (data: { itemID: number; data: ITargetOperation }) =>
|
inputCreate: (data: { itemID: number; data: ITargetOperation }) =>
|
||||||
|
|
|
@ -16,7 +16,8 @@ export const useInputUpdate = () => {
|
||||||
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
||||||
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
inputUpdate: (data: { itemID: number; data: IInputUpdateDTO }) => mutation.mutateAsync(data)
|
inputUpdate: (data: { itemID: number; data: IInputUpdateDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -16,7 +16,8 @@ export const useOperationCreate = () => {
|
||||||
onSuccess: response => {
|
onSuccess: response => {
|
||||||
client.setQueryData(ossApi.getOssQueryOptions({ itemID: response.oss.id }).queryKey, response.oss);
|
client.setQueryData(ossApi.getOssQueryOptions({ itemID: response.oss.id }).queryKey, response.oss);
|
||||||
updateTimestamp(response.oss.id);
|
updateTimestamp(response.oss.id);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
operationCreate: (data: { itemID: number; data: IOperationCreateDTO }) => mutation.mutateAsync(data)
|
operationCreate: (data: { itemID: number; data: IOperationCreateDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -16,7 +16,8 @@ export const useOperationDelete = () => {
|
||||||
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
||||||
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
operationDelete: (data: { itemID: number; data: IOperationDeleteDTO }) => mutation.mutateAsync(data)
|
operationDelete: (data: { itemID: number; data: IOperationDeleteDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -16,7 +16,8 @@ export const useOperationExecute = () => {
|
||||||
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
||||||
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
operationExecute: (data: { itemID: number; data: ITargetOperation }) => mutation.mutateAsync(data)
|
operationExecute: (data: { itemID: number; data: ITargetOperation }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -28,7 +28,8 @@ export const useOperationUpdate = () => {
|
||||||
return client.invalidateQueries({
|
return client.invalidateQueries({
|
||||||
queryKey: KEYS.composite.rsItem({ itemID: schemaID })
|
queryKey: KEYS.composite.rsItem({ itemID: schemaID })
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
operationUpdate: (data: { itemID: number; data: IOperationUpdateDTO }) => mutation.mutateAsync(data)
|
operationUpdate: (data: { itemID: number; data: IOperationUpdateDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -16,7 +16,8 @@ export const useRelocateConstituents = () => {
|
||||||
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
client.invalidateQueries({ queryKey: KEYS.composite.libraryList }),
|
||||||
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
client.invalidateQueries({ queryKey: [KEYS.rsform] })
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
relocateConstituents: (data: ICstRelocateDTO) => mutation.mutateAsync(data)
|
relocateConstituents: (data: ICstRelocateDTO) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { useMutation } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { useUpdateTimestamp } from '@/features/library';
|
import { useUpdateTimestamp } from '@/features/library';
|
||||||
|
|
||||||
|
@ -8,11 +8,13 @@ import { ossApi } from './api';
|
||||||
import { IOperationPosition } from './types';
|
import { IOperationPosition } from './types';
|
||||||
|
|
||||||
export const useUpdatePositions = () => {
|
export const useUpdatePositions = () => {
|
||||||
|
const client = useQueryClient();
|
||||||
const { updateTimestamp } = useUpdateTimestamp();
|
const { updateTimestamp } = useUpdateTimestamp();
|
||||||
const mutation = useMutation({
|
const mutation = useMutation({
|
||||||
mutationKey: [KEYS.global_mutation, ossApi.baseKey, 'update-positions'],
|
mutationKey: [KEYS.global_mutation, ossApi.baseKey, 'update-positions'],
|
||||||
mutationFn: ossApi.updatePositions,
|
mutationFn: ossApi.updatePositions,
|
||||||
onSuccess: (_, variables) => updateTimestamp(variables.itemID)
|
onSuccess: (_, variables) => updateTimestamp(variables.itemID),
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
updatePositions: (data: {
|
updatePositions: (data: {
|
||||||
|
|
|
@ -24,7 +24,8 @@ export const useCstCreate = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.schema.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.schema.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstCreate: (data: { itemID: number; data: ICstCreateDTO }) =>
|
cstCreate: (data: { itemID: number; data: ICstCreateDTO }) =>
|
||||||
|
|
|
@ -24,7 +24,8 @@ export const useCstDelete = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstDelete: (data: { itemID: number; data: IConstituentaList }) => mutation.mutateAsync(data)
|
cstDelete: (data: { itemID: number; data: IConstituentaList }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -16,7 +16,8 @@ export const useCstMove = () => {
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
client.setQueryData(rsformsApi.getRSFormQueryOptions({ itemID: data.id }).queryKey, data);
|
client.setQueryData(rsformsApi.getRSFormQueryOptions({ itemID: data.id }).queryKey, data);
|
||||||
updateTimestamp(data.id);
|
updateTimestamp(data.id);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstMove: (data: { itemID: number; data: ICstMoveDTO }) => mutation.mutateAsync(data)
|
cstMove: (data: { itemID: number; data: ICstMoveDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -24,7 +24,8 @@ export const useCstRename = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.schema.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.schema.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstRename: (data: { itemID: number; data: ICstRenameDTO }) => mutation.mutateAsync(data)
|
cstRename: (data: { itemID: number; data: ICstRenameDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -24,7 +24,8 @@ export const useCstSubstitute = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstSubstitute: (data: { itemID: number; data: ICstSubstitutionsDTO }) => mutation.mutateAsync(data)
|
cstSubstitute: (data: { itemID: number; data: ICstSubstitutionsDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -20,7 +20,8 @@ export const useCstUpdate = () => {
|
||||||
client.invalidateQueries({ queryKey: [KEYS.oss] }),
|
client.invalidateQueries({ queryKey: [KEYS.oss] }),
|
||||||
client.invalidateQueries({ queryKey: [rsformsApi.baseKey] })
|
client.invalidateQueries({ queryKey: [rsformsApi.baseKey] })
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
cstUpdate: (data: { itemID: number; data: ICstUpdateDTO }) => mutation.mutateAsync(data)
|
cstUpdate: (data: { itemID: number; data: ICstUpdateDTO }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -24,7 +24,8 @@ export const useInlineSynthesis = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
inlineSynthesis: (data: IInlineSynthesisDTO) => mutation.mutateAsync(data)
|
inlineSynthesis: (data: IInlineSynthesisDTO) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -24,7 +24,8 @@ export const useProduceStructure = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.schema.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.schema.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
produceStructure: (data: { itemID: number; data: ITargetCst }) =>
|
produceStructure: (data: { itemID: number; data: ITargetCst }) =>
|
||||||
|
|
|
@ -23,7 +23,8 @@ export const useResetAliases = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
resetAliases: (data: { itemID: number }) => mutation.mutateAsync(data)
|
resetAliases: (data: { itemID: number }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -15,7 +15,8 @@ export const useRestoreOrder = () => {
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
client.setQueryData(rsformsApi.getRSFormQueryOptions({ itemID: data.id }).queryKey, data);
|
client.setQueryData(rsformsApi.getRSFormQueryOptions({ itemID: data.id }).queryKey, data);
|
||||||
updateTimestamp(data.id);
|
updateTimestamp(data.id);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
restoreOrder: (data: { itemID: number }) => mutation.mutateAsync(data)
|
restoreOrder: (data: { itemID: number }) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -25,7 +25,8 @@ export const useUploadTRS = () => {
|
||||||
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
predicate: query => query.queryKey.length > 2 && query.queryKey[2] !== data.id
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
upload: (data: IRSFormUploadDTO) => mutation.mutateAsync(data)
|
upload: (data: IRSFormUploadDTO) => mutation.mutateAsync(data)
|
||||||
|
|
|
@ -13,7 +13,8 @@ export const useUpdateProfile = () => {
|
||||||
onSuccess: data => {
|
onSuccess: data => {
|
||||||
client.setQueryData(usersApi.getProfileQueryOptions().queryKey, data);
|
client.setQueryData(usersApi.getProfileQueryOptions().queryKey, data);
|
||||||
return client.invalidateQueries({ queryKey: usersApi.getUsersQueryOptions().queryKey });
|
return client.invalidateQueries({ queryKey: usersApi.getUsersQueryOptions().queryKey });
|
||||||
}
|
},
|
||||||
|
onError: () => client.invalidateQueries()
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
updateProfile: (data: IUpdateProfileDTO) => mutation.mutateAsync(data),
|
updateProfile: (data: IUpdateProfileDTO) => mutation.mutateAsync(data),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user