import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography"; import { ArrowDownTrayIcon } from "@heroicons/react/24/outline"; import Customer from "le-coffre-resources/dist/Customer"; import { OfficeFolder as OfficeFolderNotary } from "le-coffre-resources/dist/Notary"; import { useCallback, useEffect, useMemo, useState } from "react"; import classes from "./classes.module.scss"; import OfficeRibService from "src/common/Api/LeCoffreApi/sdk/OfficeRibService"; type IProps = { folder: OfficeFolderNotary; customer: Customer; }; export default function ContactBox(props: IProps) { const { folder, customer } = props; const [ribUrl, setRibUrl] = useState(null); const notaryContact = useMemo( () => folder?.stakeholders!.find((stakeholder) => stakeholder.office_role?.name === "Notaire")?.contact ?? folder?.stakeholders![0]!.contact, [folder], ); const note = useMemo( () => folder?.notes?.find((note) => note.customer?.uid === customer?.uid) ?? { content: "Aucune note", created_at: new Date(), updated_at: new Date(), }, [customer?.uid, folder?.notes], ); useEffect(() => { if (!folder?.office?.uid) return; OfficeRibService.getOfficeRib().then((process: any) => { if (process) { const officeRib: any = process.processData; const fileBlob: Blob = new Blob([officeRib.file_blob.data], { type: officeRib.file_blob.type }); setRibUrl(URL.createObjectURL(fileBlob)); } }); }, [folder]); const downloadRib = useCallback(async () => { if (!ribUrl) return; const a = document.createElement("a"); a.style.display = "none"; a.href = ribUrl; a.download = ""; document.body.appendChild(a); a.click(); }, [ribUrl]); return (
L’étude de votre notaire {folder?.office?.name ?? "_"}
Numéro de téléphone {notaryContact?.cell_phone_number ?? notaryContact?.phone_number ?? "_"}
E-mail {notaryContact?.email ?? "_"}
{noteAndRibButton()}
{noteAndRibButton()}
); function noteAndRibButton() { return ( <>
Note dossier {note?.content ?? "-"}
{ribUrl && ( )} ); } }