refactor: improve return of reorder

This commit is contained in:
Carlos Valente
2025-05-16 20:23:35 +02:00
committed by Carlos Valente
parent 1ee773a426
commit 8232e64cc6
6 changed files with 36 additions and 15 deletions
@@ -549,6 +549,22 @@ export const useEntryActions = () => {
onError: (_error, _data, context) => {
queryClient.setQueryData<Rundown>(RUNDOWN, context?.previousData);
},
// Mutation finished, we update the rundown with the response
onSuccess: (response) => {
if (response.data) {
const { id, title, order, flatOrder, entries, revision } = response.data;
queryClient.setQueryData<Rundown>(RUNDOWN, {
id,
title,
order,
flatOrder,
entries,
revision,
});
}
},
// Mutation finished, failed or successful
// Fetch anyway, just to be sure
onSettled: () => {