75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import React from "react";
|
|
import classes from "./classes.module.scss";
|
|
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
|
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
|
import UserFolder from "@Front/Components/DesignSystem/UserFolder";
|
|
import { AnchorStatus } from "@Front/Components/Layouts/Folder/FolderInformation";
|
|
|
|
type IProps = {
|
|
folder: OfficeFolder;
|
|
anchorStatus: AnchorStatus;
|
|
getFolderCallback: () => Promise<void>;
|
|
};
|
|
type IState = {
|
|
openedCustomer: string;
|
|
};
|
|
|
|
export default class ClientSection extends React.Component<IProps, IState> {
|
|
public constructor(props: IProps) {
|
|
super(props);
|
|
this.state = {
|
|
openedCustomer: "",
|
|
};
|
|
|
|
this.changeUserFolder = this.changeUserFolder.bind(this);
|
|
}
|
|
|
|
public override render(): JSX.Element {
|
|
return (
|
|
<div className={classes["root"]}>
|
|
{this.doesFolderHaveCustomer() ? (
|
|
<>
|
|
<div className={classes["client"]}>{this.renderCustomerFolders()}</div>
|
|
</>
|
|
) : (
|
|
<div className={classes["no-client"]}>
|
|
<Typography typo={ITypo.P_18} color={ITypoColor.COLOR_NEUTRAL_500}>
|
|
Aucun client dans ce dossier
|
|
</Typography>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
private renderCustomerFolders() {
|
|
const output = this.props.folder.customers?.map((customer) => {
|
|
if (!customer) return null;
|
|
return (
|
|
<UserFolder
|
|
folder={this.props.folder}
|
|
customer={customer}
|
|
key={customer.uid}
|
|
isOpened={this.state.openedCustomer === customer.uid}
|
|
onChange={this.changeUserFolder}
|
|
anchorStatus={this.props.anchorStatus}
|
|
isArchived
|
|
getFolderCallback={this.props.getFolderCallback}
|
|
/>
|
|
);
|
|
});
|
|
return output ?? null;
|
|
}
|
|
|
|
private changeUserFolder(uid: string) {
|
|
this.setState({
|
|
openedCustomer: uid === this.state.openedCustomer ? "" : uid,
|
|
});
|
|
}
|
|
|
|
private doesFolderHaveCustomer(): boolean {
|
|
if (!this.props.folder?.customers) return false;
|
|
return this.props.folder?.customers!.length > 0;
|
|
}
|
|
}
|