Add min cheque value and view contract at the end of form flow

This commit is contained in:
2026-09-07 19:15:06 +02:00
parent b4b4fa7643
commit 768fdb8d97
17 changed files with 1042 additions and 473 deletions

View File

@@ -0,0 +1,70 @@
import { PdfViewer } from "@/components/PdfViewer";
import { t } from "@/config/i18n";
import { Button, Checkbox, Loader, Modal, Stack, Text } from "@mantine/core";
import { isNotEmpty, useForm } from "@mantine/form";
import { useState } from "react";
export type ContractRecapProps = {
opened: boolean;
close: () => void;
pdfUrl?: string;
};
export function ContractRecap({ opened, close, pdfUrl }: ContractRecapProps) {
const [viewPdf, setViewPdf] = useState<boolean>(false);
const form = useForm({
mode: "uncontrolled",
initialValues: { terms: false },
validate: {
terms: isNotEmpty(t("you must accept terms and conditions", { capfirst: true })),
},
});
if (!pdfUrl)
return (
<Modal
opened={opened}
onClose={close}
size="100%"
title={t("contract recap", { capfirst: true })}
>
<Loader></Loader>
</Modal>
);
return (
<Modal
opened={opened}
onClose={close}
size={"55rem"}
title={t("contract recap", { capfirst: true })}
>
<Stack>
<Text>{t("your contract has been submited", { capfirst: true })}</Text>
<Button onClick={() => setViewPdf(!viewPdf)}>
{t("show contract", { capfirst: true })}
</Button>
{viewPdf ? <PdfViewer file={pdfUrl} /> : null}
<form
onSubmit={form.onSubmit(() => {
const link = document.createElement("a");
link.href = pdfUrl;
link.target = "_blank";
link.click();
URL.revokeObjectURL(pdfUrl);
})}
>
<Stack>
<Checkbox
label={t("i have read and accept the mutual agreement", {
capfirst: true,
})}
key={form.key("terms")}
{...form.getInputProps("terms", { type: "checkbox" })}
/>
<Button type="submit">{t("download contract", { capfirst: true })}</Button>
</Stack>
</form>
</Stack>
</Modal>
);
}