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