🐛 Warning icon on client only if something pending

This commit is contained in:
Maxime Lalo 2023-04-27 14:10:52 +02:00
parent ae79ed86ca
commit 32bdcbcc92
3 changed files with 28 additions and 10 deletions

View File

@ -7,6 +7,7 @@ import PenIcon from "@Assets/Icons/pen.svg";
import WarningBadge from "../../WarningBadge"; import WarningBadge from "../../WarningBadge";
import Link from "next/link"; import Link from "next/link";
import Module from "@Front/Config/Module"; import Module from "@Front/Config/Module";
import { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
type IProps = { type IProps = {
contact: { contact: {
@ -17,7 +18,7 @@ type IProps = {
cell_phone_number: Contact["cell_phone_number"]; cell_phone_number: Contact["cell_phone_number"];
email: Contact["email"]; email: Contact["email"];
}; };
selectedFolderUid: string; folder: IDashBoardFolder;
isArchived?: boolean; isArchived?: boolean;
}; };
type IState = {}; type IState = {};
@ -29,7 +30,7 @@ export default class UserFolderHeader extends React.Component<IProps, IState> {
public override render(): JSX.Element { public override render(): JSX.Element {
const redirectPath = Module.getInstance() const redirectPath = Module.getInstance()
.get() .get()
.modules.pages.Folder.pages.EditClient.props.path.replace("[folderUid]", this.props.selectedFolderUid) .modules.pages.Folder.pages.EditClient.props.path.replace("[folderUid]", this.props.folder.uid)
.replace("[clientUid]", this.props.contact.uid); .replace("[clientUid]", this.props.contact.uid);
return ( return (
<div className={classes["root"]}> <div className={classes["root"]}>
@ -59,7 +60,7 @@ export default class UserFolderHeader extends React.Component<IProps, IState> {
</div> </div>
{!this.props.isArchived && ( {!this.props.isArchived && (
<div className={classes["icons"]}> <div className={classes["icons"]}>
<WarningBadge /> {this.hasPendingFiles() && <WarningBadge />}
<Link href={redirectPath}> <Link href={redirectPath}>
<Image src={PenIcon} alt="edit" className={classes["edit-icon"]} onClick={this.onEditClick} /> <Image src={PenIcon} alt="edit" className={classes["edit-icon"]} onClick={this.onEditClick} />
</Link> </Link>
@ -69,6 +70,14 @@ export default class UserFolderHeader extends React.Component<IProps, IState> {
); );
} }
private hasPendingFiles(){
const documents = this.props.folder.documents?.filter((document) => document.depositor.contact.uid === this.props.contact.uid) ?? [];
const notAskedDocuments = documents.filter((document) => document.document_status === "PENDING") ?? [];
console.log(this.props.contact.uid);
console.log(notAskedDocuments.length);
return notAskedDocuments.length > 0;
}
private formatPhoneNumber(phoneNumber: string): string { private formatPhoneNumber(phoneNumber: string): string {
if (!phoneNumber) return ""; if (!phoneNumber) return "";
const output = phoneNumber.split("").map((char, index) => { const output = phoneNumber.split("").map((char, index) => {

View File

@ -68,7 +68,7 @@ export default class UserFolder extends React.Component<IProps, IState> {
<div className={classes["header"]} onClick={this.toggleOpen}> <div className={classes["header"]} onClick={this.toggleOpen}>
<UserFolderHeader <UserFolderHeader
contact={this.props.customer.contact} contact={this.props.customer.contact}
selectedFolderUid={this.props.folder.uid} folder={this.props.folder}
isArchived={this.props.isArchived} isArchived={this.props.isArchived}
/> />
<Image <Image

View File

@ -39,7 +39,7 @@ export const deed: Deed = {
}; };
export const contact: Contact = { export const contact: Contact = {
uid: "g('yeh(grgrezg", uid: "contact_1_uid",
first_name: "John", first_name: "John",
last_name: "Doe", last_name: "Doe",
email: "johnDoe@gmail.com", email: "johnDoe@gmail.com",
@ -52,7 +52,7 @@ export const contact: Contact = {
}; };
export const contact2: Contact = { export const contact2: Contact = {
uid: "g('yeh(grgrezg", uid: "contact_2_uid",
first_name: "Customer2", first_name: "Customer2",
last_name: "Doe", last_name: "Doe",
email: "johnDoe@gmail.com", email: "johnDoe@gmail.com",
@ -91,6 +91,15 @@ export const customer: Customer = {
updated_at: new Date(), updated_at: new Date(),
status: ECustomerStatus.VALIDATED, status: ECustomerStatus.VALIDATED,
}; };
export const customer2_mock: Customer = {
uid: "yregrgetergrt",
contact: contact2,
created_at: new Date(),
updated_at: new Date(),
status: ECustomerStatus.VALIDATED,
};
export const folder: OfficeFolder = { export const folder: OfficeFolder = {
uid: "mkovrijvrezviev", uid: "mkovrijvrezviev",
folder_number: "12331", folder_number: "12331",
@ -108,7 +117,7 @@ export const folder: OfficeFolder = {
export const document: Document = { export const document: Document = {
uid: "fzeafergreztyzgrf", uid: "fzeafergreztyzgrf",
depositor: customer, depositor: customer2_mock,
document_status: "ASKED", document_status: "ASKED",
folder: folder, folder: folder,
document_type: docType, document_type: docType,
@ -144,7 +153,7 @@ export const identityFile: File = {
export const documentIdentity: Document = { export const documentIdentity: Document = {
uid: "ethrthbkjtrbporjbh", uid: "ethrthbkjtrbporjbh",
depositor: customer, depositor: customer2_mock,
document_status: "PENDING", document_status: "PENDING",
folder: folder, folder: folder,
document_type: identityDocType, document_type: identityDocType,
@ -155,7 +164,7 @@ export const documentIdentity: Document = {
export const documentPending: Document = { export const documentPending: Document = {
uid: "fzefeazdagrtetrury", uid: "fzefeazdagrtetrury",
depositor: customer, depositor: customer2_mock,
document_status: "PENDING", document_status: "PENDING",
folder: folder, folder: folder,
document_type: docType, document_type: docType,
@ -166,7 +175,7 @@ export const documentPending: Document = {
export const documentDeposited: Document = { export const documentDeposited: Document = {
uid: "uè§u§htfgrthytrgr", uid: "uè§u§htfgrthytrgr",
depositor: customer, depositor: customer2_mock,
document_status: "VALIDATED", document_status: "VALIDATED",
folder: folder, folder: folder,
document_type: docType, document_type: docType,