Add min cheque value and view contract at the end of form flow
This commit is contained in:
70
frontend/src/pages/Contract/recap.tsx
Normal file
70
frontend/src/pages/Contract/recap.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user