mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-24 21:51:34 +10:00
implement button to download PDF from a public resume page
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user