[WIP] Download contract
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user