[WIP] Download contract

This commit is contained in:
Julien Aldon
2026-02-16 17:49:15 +01:00
parent 5354a74cac
commit ab98ba81c8
10 changed files with 98 additions and 15 deletions

View File

@@ -586,6 +586,25 @@ export function useGetContract(
});
}
export function useGetContractFile(
id?: number,
) {
return useQuery({
queryKey: ["contract"],
queryFn: () => fetch(`${Config.backend_uri}/contracts/${id}/file`)
.then(async (res) => {
const blob = await res.blob();
const disposition = res.headers.get("Content-Disposition");
const filename = disposition && disposition?.includes("filename=") ?
disposition.split("filname=")[1].replace(/"/g, "") :
`contract_${id}.pdf`
return {blob, filename};
}),
enabled: !!id,
});
}
export function useCreateContract() {
const queryClient = useQueryClient();