implement button to download PDF from a public resume page

This commit is contained in:
Amruth Pillai
2023-11-21 13:45:39 +01:00
parent 422865b3ad
commit 2a3ae68948
51 changed files with 1651 additions and 1631 deletions

View File

@ -1,11 +1,9 @@
import { t } from "@lingui/macro";
import { StatisticsDto, UrlDto } from "@reactive-resume/dto";
import { UrlDto } from "@reactive-resume/dto";
import { useMutation } from "@tanstack/react-query";
import { RESUME_KEY } from "@/client/constants/query-keys";
import { toast } from "@/client/hooks/use-toast";
import { axios } from "@/client/libs/axios";
import { queryClient } from "@/client/libs/query-client";
export const printResume = async (data: { id: string }) => {
const response = await axios.get<UrlDto>(`/resume/print/${data.id}`);
@ -20,12 +18,6 @@ export const usePrintResume = () => {
mutateAsync: printResumeFn,
} = useMutation({
mutationFn: printResume,
onSuccess: (_, { id }) => {
queryClient.setQueryData([...RESUME_KEY, "statistics", id], (cache: StatisticsDto) => {
if (cache === undefined) return cache;
return { ...cache, downloads: cache.downloads + 1 } satisfies StatisticsDto;
});
},
onError: (error) => {
const message = error?.message;