Revert "Feat/customizable links"

This commit is contained in:
Daniel
2024-08-18 14:46:52 -04:00
committed by GitHub
parent ee2319996b
commit 9a3e82470a
28 changed files with 326 additions and 976 deletions
+3 -28
View File
@@ -225,21 +225,9 @@ const useDeleteLink = () => {
const useGetLink = () => {
const queryClient = useQueryClient();
const router = useRouter();
return useMutation({
mutationFn: async ({
id,
isPublicRoute = router.pathname.startsWith("/public") ? true : undefined,
}: {
id: number;
isPublicRoute?: boolean;
}) => {
const path = isPublicRoute
? `/api/v1/public/links/${id}`
: `/api/v1/links/${id}`;
const response = await fetch(path);
mutationFn: async (id: number) => {
const response = await fetch(`/api/v1/links/${id}`);
const data = await response.json();
if (!response.ok) throw new Error(data.response);
@@ -262,20 +250,7 @@ const useGetLink = () => {
};
});
queryClient.setQueriesData(
{ queryKey: ["publicLinks"] },
(oldData: any) => {
if (!oldData) return undefined;
return {
pages: oldData.pages.map((page: any) =>
page.map((item: any) => (item.id === data.id ? data : item))
),
pageParams: oldData.pageParams,
};
}
);
// queryClient.invalidateQueries({ queryKey: ["publicLinks"] });
queryClient.invalidateQueries({ queryKey: ["publicLinks"] });
},
});
};