import PenIcon from "@Assets/Icons/pen.svg"; import { OfficeFolder } from "le-coffre-resources/dist/Notary"; import Module from "@Front/Config/Module"; import { Customer } from "le-coffre-resources/dist/Notary"; import Image from "next/image"; import Link from "next/link"; import React from "react"; import Typography, { ITypo } from "../../Typography"; import WarningBadge from "../../WarningBadge"; import classes from "./classes.module.scss"; import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; type IProps = { customer: Customer; folder: OfficeFolder; isArchived?: boolean; }; type IState = {}; export default class UserFolderHeader extends React.Component { static defaultProps = { isArchived: false, }; public override render(): JSX.Element | null { const redirectPath = Module.getInstance() .get() .modules.pages.Folder.pages.EditClient.props.path.replace("[folderUid]", this.props.folder.uid ?? "") .replace("[customerUid]", this.props.customer.uid ?? ""); if (!this.props.customer.contact) return null; return (
Nom {this.props.customer.contact.last_name}
Prénom {this.props.customer.contact.first_name}
Numéro de téléphone {this.formatPhoneNumber(this.props.customer.contact.cell_phone_number) ?? this.formatPhoneNumber(this.props.customer.contact.phone_number?.toString() ?? "")}
E-mail {this.props.customer.contact.email}
{!this.props.isArchived && (
{this.hasPendingFiles() && } edit
)}
); } private hasPendingFiles() { const documents = this.props.folder.documents?.filter((document) => document.depositor?.contact?.uid === this.props.customer.contact?.uid) ?? []; const notAskedDocuments = documents.filter((document) => document.document_status === EDocumentStatus.DEPOSITED) ?? []; return notAskedDocuments.length > 0; } private formatPhoneNumber(phoneNumber: string): string { if (!phoneNumber) return ""; phoneNumber = phoneNumber.replace(/ /g, ""); phoneNumber = phoneNumber.replace("+33", "0"); if (phoneNumber.length !== 10) { // split the last 9 digits const lastNineDigits = phoneNumber.slice(-9); // get the country code const countryCode = phoneNumber.slice(0, -9); // isolate the first digit const firstDigit = lastNineDigits.slice(0, 1); // isolate the 8 other ones const lastEightDigits = lastNineDigits.slice(1); // make a space every two digits on the last eights const output = lastEightDigits.split("").map((char, index) => { if (index % 2) return char + " "; return char; }); // format the phone number phoneNumber = countryCode + " " + firstDigit + " " + output.join(""); return phoneNumber; } const output = phoneNumber.split("").map((char, index) => { if (index % 2) return char + " "; return char; }); return output.join(""); } private onEditClick(): void {} }