add: order paths & mds

This commit is contained in:
h z
2024-12-29 18:52:39 +00:00
parent 34ab63d0bf
commit 75d083f11f
6 changed files with 116 additions and 17 deletions

View File

@@ -68,10 +68,26 @@ export const useSaveMarkdown = () => {
})
},{
onSuccess: (res, variables) => {
queryClient.invalidateQueries(["markdownsByPath", variables.data.parent_id]);
queryClient.invalidateQueries(["markdownsByPath", variables.data.path_id]);
queryClient.invalidateQueries(["markdown", variables.data.id]);
},
});
};
export const useMoveMarkdown = () => {
const queryClient = useQueryClient();
const config = useConfig();
return useMutation(
({markdown, direction}) => {
const apiEndpoint = `${config.BACKEND_HOST}/api/markdown/move_${direction}/${markdown.id}`;
return fetch_(apiEndpoint, {method: "PATCH"});
},
{
onSuccess: () => {
queryClient.invalidateQueries("paths");
}
}
);
};

View File

@@ -92,4 +92,22 @@ export const useDeletePath = () => {
},
}
);
};
};
export const useMovePath = () => {
const queryClient = useQueryClient();
const config = useConfig();
return useMutation(
({path, direction}) => {
const apiEndpoint = `${config.BACKEND_HOST}/api/path/move_${direction}/${path.id}`;
return fetch_(apiEndpoint, {method: "PATCH"});
},
{
onSuccess: () => {
queryClient.invalidateQueries("paths");
}
}
);
};