This commit is contained in:
@@ -23,7 +23,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|||||||
import { useParams } from "react-router";
|
import { useParams } from "react-router";
|
||||||
import { computePrices } from "./price";
|
import { computePrices } from "./price";
|
||||||
import { ContractCheque } from "@/components/PaymentMethods/Cheque";
|
import { ContractCheque } from "@/components/PaymentMethods/Cheque";
|
||||||
import { tranformProducts, type ContractInputs } from "@/services/resources/contracts";
|
import { transformProducts, type ContractInputs } from "@/services/resources/contracts";
|
||||||
import type { Shipment } from "@/services/resources/shipments";
|
import type { Shipment } from "@/services/resources/shipments";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { ContractRecap } from "./recap";
|
import { ContractRecap } from "./recap";
|
||||||
@@ -68,7 +68,6 @@ export function Contract() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!form) return;
|
if (!form) return;
|
||||||
console.log("aze");
|
|
||||||
inputForm.setFieldValue("cheque_quantity", Number(minCheques) || 1);
|
inputForm.setFieldValue("cheque_quantity", Number(minCheques) || 1);
|
||||||
}, [form]);
|
}, [form]);
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ export function Contract() {
|
|||||||
cheque_quantity:
|
cheque_quantity:
|
||||||
formValues.payment_method === "cheque" ? formValues.cheque_quantity : 0,
|
formValues.payment_method === "cheque" ? formValues.cheque_quantity : 0,
|
||||||
form_id: form.id,
|
form_id: form.id,
|
||||||
products: tranformProducts(withDefaultValues(formValues.products)),
|
products: transformProducts(withDefaultValues(formValues.products)),
|
||||||
};
|
};
|
||||||
const { blob } = await createContractMutation.mutateAsync(contract);
|
const { blob } = await createContractMutation.mutateAsync(contract);
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
@@ -341,7 +340,12 @@ export function Contract() {
|
|||||||
{t("for transfer method contact your referer or productor", { capfirst: true })}
|
{t("for transfer method contact your referer or productor", { capfirst: true })}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
<ContractRecap opened={isRecapModalOpened} close={closeRecapModal} pdfUrl={pdfUrl} />
|
<ContractRecap
|
||||||
|
opened={isRecapModalOpened}
|
||||||
|
close={closeRecapModal}
|
||||||
|
pdfUrl={pdfUrl}
|
||||||
|
contractName={`${form.name}-${form.season}`}
|
||||||
|
/>
|
||||||
<Space h="15vh"></Space>
|
<Space h="15vh"></Space>
|
||||||
<Overlay
|
<Overlay
|
||||||
bg={"lightGray"}
|
bg={"lightGray"}
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ export type ContractRecapProps = {
|
|||||||
opened: boolean;
|
opened: boolean;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
pdfUrl?: string;
|
pdfUrl?: string;
|
||||||
|
contractName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ContractRecap({ opened, close, pdfUrl }: ContractRecapProps) {
|
export function ContractRecap({ opened, close, pdfUrl, contractName }: ContractRecapProps) {
|
||||||
const [viewPdf, setViewPdf] = useState<boolean>(false);
|
const [viewPdf, setViewPdf] = useState<boolean>(false);
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
mode: "uncontrolled",
|
mode: "uncontrolled",
|
||||||
@@ -51,7 +52,7 @@ export function ContractRecap({ opened, close, pdfUrl }: ContractRecapProps) {
|
|||||||
onSubmit={form.onSubmit(() => {
|
onSubmit={form.onSubmit(() => {
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.href = pdfUrl;
|
link.href = pdfUrl;
|
||||||
link.target = "_blank";
|
link.download = contractName || "contract";
|
||||||
link.click();
|
link.click();
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user