import ValidIcon from "@Assets/Icons/check-valid.svg"; import TrashIcon from "@Assets/Icons/trash.svg"; import classNames from "classnames"; import { Document } from "le-coffre-resources/dist/Customer"; import Image from "next/image"; import { NextRouter, useRouter } from "next/router"; 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 = { folderUid: string; document: { uid?: Document["uid"]; document_type?: Document["document_type"]; document_status: Document["document_status"]; folder?: Document["folder"]; files?: Document["files"]; }; openDeletionModal?: (uid: Document["uid"]) => void; }; type IPropsClass = IProps & { router: NextRouter; }; type IState = {}; class DocumentNotaryClass extends React.Component { public constructor(props: IPropsClass) { super(props); this.onOpenDeletionModal = this.onOpenDeletionModal.bind(this); this.onClick = this.onClick.bind(this); } public override render(): JSX.Element { return (
{this.props.document?.document_type?.name} {this.getDocumentsTitle()}
{this.renderIcon()}
); } private getDocumentsTitle() { const documentFiles = this.props.document.files; if (documentFiles) { if (documentFiles.length === 1) { const fileName = documentFiles[0]?.file_path?.split("/").pop(); if (fileName && fileName.length > 20) { return `${fileName.substring(0, 7)}...${fileName.substring(fileName.length - 7, fileName.length)}`; } else { return fileName; } } else { const archivedFilesLenght = documentFiles.filter((file) => file.archived_at).length; const documentFileLenght = documentFiles.length - archivedFilesLenght; return `${documentFileLenght} documents déposés`; } } else { return "Aucun document déposé"; } } private onClick() { if ( this.props.document.document_status !== EDocumentStatus.VALIDATED && this.props.document.document_status !== EDocumentStatus.DEPOSITED ) return; this.props.router.push(`/folders/${this.props.folderUid}/documents/${this.props.document.uid}`); } private renderIcon(): JSX.Element { switch (this.props.document.document_status) { case "VALIDATED": return (
valid icon
); case EDocumentStatus.DEPOSITED: return ; default: return trash icon; } } private onOpenDeletionModal(): void { if (!this.props.openDeletionModal) return; this.props.openDeletionModal(this.props.document.uid ?? ""); } } export default function DocumentNotary(props: IProps): JSX.Element { const router = useRouter(); return ; }