From 223e7b5c904ba355f66c3a2f6e8a7b5f4a1f26e3 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 11:59:03 +0200 Subject: [PATCH 01/15] :sparkles: Refuse documents working --- .../SuperAdmin/Documents/Documents.ts | 3 ++- .../Layouts/Folder/ViewDocuments/index.tsx | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index 608bf951..72188423 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -13,7 +13,8 @@ export interface IGetDocumentsparams { // TODO Type getbyuid query params export type IPutDocumentsParams = { - document_status?: EDocumentStatus + document_status?: EDocumentStatus; + refused_reason?: string; }; export interface IPostDocumentsParams {} diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index 9d0ec40a..0c76aa41 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -66,6 +66,7 @@ class ViewDocumentsClass extends BasePage { this.hasPrevious = this.hasPrevious.bind(this); this.hasNext = this.hasNext.bind(this); + this.refuseDocument = this.refuseDocument.bind(this); } public override render(): JSX.Element | null { @@ -156,7 +157,7 @@ class ViewDocumentsClass extends BasePage { { return index < this.state.document!.files!.length; } + private async refuseDocument(){ + try{ + await Documents.getInstance().put(this.props.documentUid, { + document_status: EDocumentStatus.REFUSED, + refused_reason: this.state.refuseText, + }); + + this.props.router.push( + Module.getInstance() + .get() + .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid), + ); + }catch(e){ + console.error(e); + } + } + private async validateAnchoring() { this.setState({ hasValidateAnchoring: true, From 2ea53d7a84a225f9933d66c5292d7c79f48302aa Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 12:01:07 +0200 Subject: [PATCH 02/15] :bug: Fixing refused_reason --- src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts | 4 ++-- src/front/Components/Layouts/Folder/ViewDocuments/index.tsx | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index 72188423..2f74e8fd 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -1,4 +1,4 @@ -import { Document } from "le-coffre-resources/dist/SuperAdmin"; +import { Document, DocumentHistory } from "le-coffre-resources/dist/SuperAdmin"; import { Service } from "typedi"; import BaseSuperAdmin from "../BaseSuperAdmin"; @@ -14,7 +14,7 @@ export interface IGetDocumentsparams { export type IPutDocumentsParams = { document_status?: EDocumentStatus; - refused_reason?: string; + document_history?: Partial; }; export interface IPostDocumentsParams {} diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index 0c76aa41..a266ad95 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -249,7 +249,9 @@ class ViewDocumentsClass extends BasePage { try{ await Documents.getInstance().put(this.props.documentUid, { document_status: EDocumentStatus.REFUSED, - refused_reason: this.state.refuseText, + document_history: { + refused_reason: this.state.refuseText, + } }); this.props.router.push( From 117636eb4f4d20628af769670dc7bd9363394467 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 12:12:40 +0200 Subject: [PATCH 03/15] :sparkles: Delete asked document working --- .../SuperAdmin/Documents/Documents.ts | 10 ++++++++++ .../UserFolder/UserFolderHeader/index.tsx | 1 - .../DesignSystem/UserFolder/index.tsx | 18 +++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index 608bf951..7c92a282 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -80,4 +80,14 @@ export default class Documents extends BaseSuperAdmin { return Promise.reject(err); } } + + public async delete(uid: string): Promise { + const url = new URL(this.baseURl.concat(`/${uid}`)); + try { + return await this.deleteRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } } diff --git a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx index b82b80c2..bdc82961 100644 --- a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx @@ -67,7 +67,6 @@ export default class UserFolderHeader extends React.Component { } private hasPendingFiles() { - console.log(this.props.folder.documents); 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) ?? []; diff --git a/src/front/Components/DesignSystem/UserFolder/index.tsx b/src/front/Components/DesignSystem/UserFolder/index.tsx index 8e0b391b..ec45279b 100644 --- a/src/front/Components/DesignSystem/UserFolder/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/index.tsx @@ -15,6 +15,7 @@ import classes from "./classes.module.scss"; import DocumentList from "./DocumentList"; import UserFolderHeader from "./UserFolderHeader"; import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; +import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; type IProps = { customer: Customer; @@ -26,6 +27,7 @@ type IProps = { }; type IState = { isOpenDeletionModal: boolean; + selectedDocumentToDelete: string; }; export default class UserFolder extends React.Component { @@ -39,10 +41,12 @@ export default class UserFolder extends React.Component { super(props); this.state = { isOpenDeletionModal: false, + selectedDocumentToDelete: "", }; this.closeDeletionModal = this.closeDeletionModal.bind(this); this.openDeletionModal = this.openDeletionModal.bind(this); this.changeUserFolder = this.changeUserFolder.bind(this); + this.deleteAskedDocument = this.deleteAskedDocument.bind(this); } public override render(): JSX.Element { const documentsAsked: Document[] | null = this.getDocumentsByStatus("ASKED"); @@ -55,6 +59,7 @@ export default class UserFolder extends React.Component { { this.rootRefElement.current?.style.setProperty("--animation-delay", this.props.animationDelay!.toString().concat("ms")); } + private async deleteAskedDocument(){ + try{ + await Documents.getInstance().delete(this.state.selectedDocumentToDelete); + window.location.reload(); + }catch(e){ + console.error(e); + } + } + private calculateDocumentsPercentageProgress(): number { if (!this.props.customer.documents) return 0; const totalDocuments: number = this.props.customer.documents.length; @@ -159,9 +173,11 @@ export default class UserFolder extends React.Component { } private openDeletionModal(uid?: string): void { - // TODO: call API to delete document + if(!uid) return; + this.setState({ isOpenDeletionModal: true, + selectedDocumentToDelete: uid, }); } private closeDeletionModal(): void { From 5ffdca6323224224daf50c932ce03c31eed223cc Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 12:16:42 +0200 Subject: [PATCH 04/15] :bug: Fixing percentage --- src/front/Components/DesignSystem/UserFolder/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/front/Components/DesignSystem/UserFolder/index.tsx b/src/front/Components/DesignSystem/UserFolder/index.tsx index ec45279b..2abe3b37 100644 --- a/src/front/Components/DesignSystem/UserFolder/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/index.tsx @@ -140,7 +140,10 @@ export default class UserFolder extends React.Component { if (!this.props.customer.documents) return 0; const totalDocuments: number = this.props.customer.documents.length; const numberDocumentsAsked: number = this.getDocumentsByStatus(EDocumentStatus.ASKED)?.length || 0; - return Math.round(((totalDocuments - numberDocumentsAsked) / totalDocuments) * 100); + + const percentage = Math.round(((totalDocuments - numberDocumentsAsked) / totalDocuments) * 100); + if(!percentage) return 0; + return percentage; } private getDocumentsByStatus(status: string): Document[] | null { From 14a47bc4749f8e97be9dd8e447a47ca8fdbe5426 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 13:22:07 +0200 Subject: [PATCH 05/15] :sparkles: Getting documents available --- .../SuperAdmin/DocumentTypes/DocumentTypes.ts | 81 +++++++++++++++++++ .../Layouts/Folder/AskDocuments/index.tsx | 64 ++++++++++++++- 2 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts b/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts new file mode 100644 index 00000000..0cb86bd3 --- /dev/null +++ b/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts @@ -0,0 +1,81 @@ +import { DocumentType } from "le-coffre-resources/dist/SuperAdmin"; +import { Service } from "typedi"; + +import BaseSuperAdmin from "../BaseSuperAdmin"; + +// TODO Type get query params -> Where + inclue + orderby +export interface IGetDocumentTypesparams { + where?: {}; + include?: {}; +} + +// TODO Type getbyuid query params + +export type IPutDocumentTypesParams = { +}; + +export interface IPostDocumentTypesParams {} + +@Service() +export default class DocumentTypes extends BaseSuperAdmin { + private static instance: DocumentTypes; + private readonly baseURl = this.namespaceUrl.concat("/document-types"); + + private constructor() { + super(); + } + + public static getInstance() { + if (!this.instance) { + return new this(); + } else { + return this.instance; + } + } + + public async get(q: IGetDocumentTypesparams): Promise { + const url = new URL(this.baseURl); + Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); + try { + return await this.getRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } + + /** + * @description : Create a Document + */ + public async post(body: any): Promise { + const url = new URL(this.baseURl); + try { + return await this.postRequest(url, body); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } + + public async getByUid(uid: string, q?: any): Promise { + const url = new URL(this.baseURl.concat(`/${uid}`)); + const query = { q }; + if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); + try { + return await this.getRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } + + public async put(uid: string, body: IPutDocumentTypesParams): Promise { + const url = new URL(this.baseURl.concat(`/${uid}`)); + try { + return await this.putRequest(url, body); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } +} diff --git a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx index 2f95d95e..8316e98a 100644 --- a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx @@ -1,4 +1,7 @@ +import "reflect-metadata"; + import PlusIcon from "@Assets/Icons/plus.svg"; +import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import CheckBox from "@Front/Components/DesignSystem/CheckBox"; import Form from "@Front/Components/DesignSystem/Form"; @@ -8,19 +11,27 @@ import { IOption } from "@Front/Components/DesignSystem/Select"; import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography"; import BackArrow from "@Front/Components/Elements/BackArrow"; import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import { NextRouter, useRouter } from "next/router"; import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; +import DocumentTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes"; +import DeedTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes"; type IProps = {}; +type IPropsClass = IProps & { + router: NextRouter; + folderUid: string; +}; type IState = { isCreateDocumentModalVisible: boolean; documentName: string; visibleDescription: string; + documentTypes: IOption[]; }; -export default class AskDocuments extends BasePage { +class AskDocumentsClass extends BasePage { private documentsType: IOption[] = [ { label: "Carte d'identité", value: "carte_identite" }, { label: "Diagnostic État Risques et Pollution", value: "diagnostic_erep" }, @@ -35,13 +46,14 @@ export default class AskDocuments extends BasePage { { label: "Diagnostic État des nuisances sonores aériennes", value: "diagnostic_ednsa" }, ]; - public constructor(props: IProps) { + public constructor(props: IPropsClass) { super(props); this.state = { isCreateDocumentModalVisible: false, documentName: "", visibleDescription: "", + documentTypes: [], }; this.onFormSubmit = this.onFormSubmit.bind(this); @@ -65,7 +77,7 @@ export default class AskDocuments extends BasePage {
- {this.documentsType.map((documentType) => ( + {this.state.documentTypes.map((documentType) => ( ))}
@@ -117,6 +129,45 @@ export default class AskDocuments extends BasePage { ); } + public override async componentDidMount(): Promise { + try{ + const folder = await Folders.getInstance().getByUid(this.props.folderUid, { + q:{ + deed: { + include: { + deed_type: true + } + } + } + }); + if(!folder) return; + + const documentTypes = await DeedTypes.getInstance().getByUid(folder.deed!.deed_type!.uid!, { + q: { + deed_type_has_document_types: { + include: { + document_type: true + } + } + } + }) + + if(!documentTypes) return; + + const documentTypesOptions: IOption[] = documentTypes.deed_type_has_document_types!.map((documentType) => { + return { + label: documentType.document_type!.name!, + value: documentType.document_type!.uid!, + }; + }); + + this.setState({ + documentTypes: documentTypesOptions, + }); + }catch(e){ + console.error(e); + } + } private canAddDocument() { if (this.state.documentName === "" || this.state.visibleDescription === "") { return false; @@ -175,3 +226,10 @@ export default class AskDocuments extends BasePage { ) { } } + +export default function AskDocuments(props: IProps){ + const router = useRouter(); + let { folderUid } = router.query; + folderUid = folderUid as string; + return ; +} From 22442234e2e832496d9d14c9ea353a6cf64776e0 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 13:32:57 +0200 Subject: [PATCH 06/15] :sparkles: Ask documents working --- .../DesignSystem/UserFolder/index.tsx | 2 +- .../Layouts/Folder/AskDocuments/index.tsx | 50 +++++++++++-------- src/front/Config/Module/development.json | 2 +- src/front/Config/Module/preprod.json | 2 +- src/front/Config/Module/production.json | 2 +- src/front/Config/Module/staging.json | 2 +- .../ask-documents/index.tsx | 0 7 files changed, 35 insertions(+), 25 deletions(-) rename src/pages/folders/[folderUid]/{ => [customerUid]}/ask-documents/index.tsx (100%) diff --git a/src/front/Components/DesignSystem/UserFolder/index.tsx b/src/front/Components/DesignSystem/UserFolder/index.tsx index 8e0b391b..d0c528de 100644 --- a/src/front/Components/DesignSystem/UserFolder/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/index.tsx @@ -49,7 +49,7 @@ export default class UserFolder extends React.Component { const otherDocuments: Document[] | null = this.getValidatedAndPendindDocuments(); const redirectPath = Module.getInstance() .get() - .modules.pages.Folder.pages.AskDocument.props.path.replace("[folderUid]", this.props.folder.uid ?? ""); + .modules.pages.Folder.pages.AskDocument.props.path.replace("[folderUid]", this.props.folder.uid ?? "").replace("[customerUid]", this.props.customer.uid ?? ""); return (
{ - private documentsType: IOption[] = [ - { label: "Carte d'identité", value: "carte_identite" }, - { label: "Diagnostic État Risques et Pollution", value: "diagnostic_erep" }, - { label: "Justificatif de domicile", value: "justificatif_domicile" }, - { label: "Diagnostic gaz", value: "diagnostic_gaz" }, - { label: "Compromis de vente", value: "compromis_de_vente" }, - { label: "Diagnostic DPE", value: "diagnostic_dpe" }, - { label: "Diagnostic électrique", value: "diagnostic_electrique" }, - { label: "Diagnostic plombs", value: "diagnostic_plombs" }, - { label: "Diagnostic amiante", value: "diagnostic_amiante" }, - { label: "Diagnostic termites", value: "diagnostic_termites" }, - { label: "Diagnostic État des nuisances sonores aériennes", value: "diagnostic_ednsa" }, - ]; - public constructor(props: IPropsClass) { super(props); @@ -78,7 +66,7 @@ class AskDocumentsClass extends BasePage {
{this.state.documentTypes.map((documentType) => ( - + ))}
@@ -218,18 +206,40 @@ class AskDocumentsClass extends BasePage { }); } - private onFormSubmit( + private async onFormSubmit( e: React.FormEvent | null, values: { - [key: string]: string; + [key: string]: any; } ) { + try{ + const documentAsked: [] = values["document_types"] as []; + await documentAsked.forEach(async (document) => { + await Documents.getInstance().post({ + folder: { + uid: this.props.folderUid + }, + depositor: { + uid: this.props.customerUid + }, + document_type: { + uid: document + } + }); + }); + + this.props.router.push(Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid)); + }catch(e){ + console.error(e); + } + console.log(values["document_types"]); } } export default function AskDocuments(props: IProps){ const router = useRouter(); - let { folderUid } = router.query; + let { folderUid, customerUid } = router.query; folderUid = folderUid as string; - return ; + customerUid = customerUid as string; + return ; } diff --git a/src/front/Config/Module/development.json b/src/front/Config/Module/development.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/development.json +++ b/src/front/Config/Module/development.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/front/Config/Module/preprod.json b/src/front/Config/Module/preprod.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/preprod.json +++ b/src/front/Config/Module/preprod.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/front/Config/Module/production.json b/src/front/Config/Module/production.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/production.json +++ b/src/front/Config/Module/production.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/front/Config/Module/staging.json b/src/front/Config/Module/staging.json index ed5d3660..882bd5dd 100644 --- a/src/front/Config/Module/staging.json +++ b/src/front/Config/Module/staging.json @@ -55,7 +55,7 @@ "AskDocument": { "enabled": true, "props": { - "path": "/folders/[folderUid]/ask-documents", + "path": "/folders/[folderUid]/[customerUid]/ask-documents", "labelKey": "ask_documents" } }, diff --git a/src/pages/folders/[folderUid]/ask-documents/index.tsx b/src/pages/folders/[folderUid]/[customerUid]/ask-documents/index.tsx similarity index 100% rename from src/pages/folders/[folderUid]/ask-documents/index.tsx rename to src/pages/folders/[folderUid]/[customerUid]/ask-documents/index.tsx From 5f134a765acdbd2c301376c37b8219e7801837f1 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 13:48:45 +0200 Subject: [PATCH 07/15] :sparkles: Creating document type working --- .../SuperAdmin/DocumentTypes/DocumentTypes.ts | 13 ++- .../Layouts/Folder/AskDocuments/index.tsx | 85 +++++++++++++------ 2 files changed, 67 insertions(+), 31 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts b/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts index 0cb86bd3..55746b8f 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts @@ -14,7 +14,14 @@ export interface IGetDocumentTypesparams { export type IPutDocumentTypesParams = { }; -export interface IPostDocumentTypesParams {} +export interface IPostDocumentTypesParams { + name: string; + public_description: string; + private_description: string; + office: { + uid: string; + }; +} @Service() export default class DocumentTypes extends BaseSuperAdmin { @@ -47,10 +54,10 @@ export default class DocumentTypes extends BaseSuperAdmin { /** * @description : Create a Document */ - public async post(body: any): Promise { + public async post(body: IPostDocumentTypesParams): Promise { const url = new URL(this.baseURl); try { - return await this.postRequest(url, body); + return await this.postRequest(url, body as any); } catch (err) { this.onError(err); return Promise.reject(err); diff --git a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx index fac5849e..cb9af00c 100644 --- a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx @@ -19,6 +19,8 @@ import classes from "./classes.module.scss"; import DeedTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes"; import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; import Module from "@Front/Config/Module"; +import DocumentTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes"; +import { OfficeFolder } from "le-coffre-resources/dist/Customer"; type IProps = {}; type IPropsClass = IProps & { @@ -31,6 +33,7 @@ type IState = { documentName: string; visibleDescription: string; documentTypes: IOption[]; + folder: OfficeFolder | null; }; class AskDocumentsClass extends BasePage { @@ -42,6 +45,7 @@ class AskDocumentsClass extends BasePage { documentName: "", visibleDescription: "", documentTypes: [], + folder: null, }; this.onFormSubmit = this.onFormSubmit.bind(this); @@ -118,6 +122,10 @@ class AskDocumentsClass extends BasePage { } public override async componentDidMount(): Promise { + this.loadData(); + } + + private async loadData(){ try{ const folder = await Folders.getInstance().getByUid(this.props.folderUid, { q:{ @@ -125,37 +133,44 @@ class AskDocumentsClass extends BasePage { include: { deed_type: true } - } + }, + office: true } }); if(!folder) return; - - const documentTypes = await DeedTypes.getInstance().getByUid(folder.deed!.deed_type!.uid!, { - q: { - deed_type_has_document_types: { - include: { - document_type: true - } - } - } - }) - - if(!documentTypes) return; - - const documentTypesOptions: IOption[] = documentTypes.deed_type_has_document_types!.map((documentType) => { - return { - label: documentType.document_type!.name!, - value: documentType.document_type!.uid!, - }; - }); - this.setState({ - documentTypes: documentTypesOptions, + folder, + documentTypes: await this.getAvailableDocuments(folder), }); }catch(e){ console.error(e); } } + + private async getAvailableDocuments(folder: OfficeFolder): Promise{ + const documentTypes = await DeedTypes.getInstance().getByUid(folder.deed!.deed_type!.uid!, { + q: { + deed_type_has_document_types: { + include: { + document_type: true + } + } + } + }) + + if(!documentTypes) return []; + + const documentTypesOptions: IOption[] = documentTypes.deed_type_has_document_types!.map((documentType) => { + return { + label: documentType.document_type!.name!, + value: documentType.document_type!.uid!, + }; + }); + + return documentTypesOptions + + } + private canAddDocument() { if (this.state.documentName === "" || this.state.visibleDescription === "") { return false; @@ -163,12 +178,26 @@ class AskDocumentsClass extends BasePage { return true; } - private addDocument() { - this.setState({ - isCreateDocumentModalVisible: false, - documentName: "", - visibleDescription: "", - }); + private async addDocument() { + try{ + await DocumentTypes.getInstance().post({ + name: this.state.documentName, + private_description: this.state.visibleDescription, + office: { + uid: this.state.folder?.office!.uid! + }, + public_description: this.state.visibleDescription + }) + + await this.loadData(); + this.setState({ + isCreateDocumentModalVisible: false, + documentName: "", + visibleDescription: "", + }); + }catch(e){ + console.error(e); + } } private onVisibleDescriptionChange(e: React.ChangeEvent) { From da2b372aa5cf299bd934bce5951224dad35b471b Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 15:01:34 +0200 Subject: [PATCH 08/15] :bug: Fixing refuse with back working --- src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts | 4 ++-- src/front/Components/Layouts/Folder/ViewDocuments/index.tsx | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index 2f74e8fd..72188423 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -1,4 +1,4 @@ -import { Document, DocumentHistory } from "le-coffre-resources/dist/SuperAdmin"; +import { Document } from "le-coffre-resources/dist/SuperAdmin"; import { Service } from "typedi"; import BaseSuperAdmin from "../BaseSuperAdmin"; @@ -14,7 +14,7 @@ export interface IGetDocumentsparams { export type IPutDocumentsParams = { document_status?: EDocumentStatus; - document_history?: Partial; + refused_reason?: string; }; export interface IPostDocumentsParams {} diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index a266ad95..f737b1bc 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -249,9 +249,7 @@ class ViewDocumentsClass extends BasePage { try{ await Documents.getInstance().put(this.props.documentUid, { document_status: EDocumentStatus.REFUSED, - document_history: { - refused_reason: this.state.refuseText, - } + refused_reason: this.state.refuseText }); this.props.router.push( From dbe0e3f558c4a535fd5f4a6c2a9e15e6ff8a8e89 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 16:18:55 +0200 Subject: [PATCH 09/15] :sparkles: Everything working --- package-lock.json | 236 +++++++++--------- .../Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts | 1 + .../UserFolder/classes.module.scss | 1 + .../Layouts/Folder/AskDocuments/index.tsx | 29 ++- 4 files changed, 142 insertions(+), 125 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3fbee2e1..db6b7d05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.35", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.38", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", @@ -171,65 +171,65 @@ } }, "node_modules/@emotion/babel-plugin": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.10.8.tgz", - "integrity": "sha512-gxNky50AJL3AlkbjvTARiwAqei6/tNUxDZPSKd+3jqWVM3AmdVTTdpjHorR/an/M0VJqdsuq5oGcFH+rjtyujQ==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz", + "integrity": "sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==", "dependencies": { "@babel/helper-module-imports": "^7.16.7", "@babel/runtime": "^7.18.3", - "@emotion/hash": "^0.9.0", - "@emotion/memoize": "^0.8.0", - "@emotion/serialize": "^1.1.1", + "@emotion/hash": "^0.9.1", + "@emotion/memoize": "^0.8.1", + "@emotion/serialize": "^1.1.2", "babel-plugin-macros": "^3.1.0", "convert-source-map": "^1.5.0", "escape-string-regexp": "^4.0.0", "find-root": "^1.1.0", "source-map": "^0.5.7", - "stylis": "4.1.4" + "stylis": "4.2.0" } }, "node_modules/@emotion/cache": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.10.8.tgz", - "integrity": "sha512-5fyqGHi51LU95o7qQ/vD1jyvC4uCY5GcBT+UgP4LHdpO9jPDlXqhrRr9/wCKmfoAvh5G/F7aOh4MwQa+8uEqhA==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.11.0.tgz", + "integrity": "sha512-P34z9ssTCBi3e9EI1ZsWpNHcfY1r09ZO0rZbRO2ob3ZQMnFI35jB536qoXbkdesr5EUhYi22anuEJuyxifaqAQ==", "dependencies": { - "@emotion/memoize": "^0.8.0", - "@emotion/sheet": "^1.2.1", - "@emotion/utils": "^1.2.0", - "@emotion/weak-memoize": "^0.3.0", - "stylis": "4.1.4" + "@emotion/memoize": "^0.8.1", + "@emotion/sheet": "^1.2.2", + "@emotion/utils": "^1.2.1", + "@emotion/weak-memoize": "^0.3.1", + "stylis": "4.2.0" } }, "node_modules/@emotion/hash": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.0.tgz", - "integrity": "sha512-14FtKiHhy2QoPIzdTcvh//8OyBlknNs2nXRwIhG904opCby3l+9Xaf/wuPvICBF0rc1ZCNBd3nKe9cd2mecVkQ==" + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.1.tgz", + "integrity": "sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ==" }, "node_modules/@emotion/is-prop-valid": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.0.tgz", - "integrity": "sha512-3aDpDprjM0AwaxGE09bOPkNxHpBd+kA6jty3RnaEXdweX1DF1U3VQpPYb0g1IStAuK7SVQ1cy+bNBBKp4W3Fjg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz", + "integrity": "sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==", "dependencies": { - "@emotion/memoize": "^0.8.0" + "@emotion/memoize": "^0.8.1" } }, "node_modules/@emotion/memoize": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.0.tgz", - "integrity": "sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==" + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" }, "node_modules/@emotion/react": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.10.8.tgz", - "integrity": "sha512-ZfGfiABtJ1P1OXqOBsW08EgCDp5fK6C5I8hUJauc/VcJBGSzqAirMnFslhFWnZJ/w5HxPI36XbvMV0l4KZHl+w==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.0.tgz", + "integrity": "sha512-ZSK3ZJsNkwfjT3JpDAWJZlrGD81Z3ytNDsxw1LKq1o+xkmO5pnWfr6gmCC8gHEFf3nSSX/09YrG67jybNPxSUw==", "dependencies": { "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.10.8", - "@emotion/cache": "^11.10.8", - "@emotion/serialize": "^1.1.1", - "@emotion/use-insertion-effect-with-fallbacks": "^1.0.0", - "@emotion/utils": "^1.2.0", - "@emotion/weak-memoize": "^0.3.0", + "@emotion/babel-plugin": "^11.11.0", + "@emotion/cache": "^11.11.0", + "@emotion/serialize": "^1.1.2", + "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", + "@emotion/utils": "^1.2.1", + "@emotion/weak-memoize": "^0.3.1", "hoist-non-react-statics": "^3.3.1" }, "peerDependencies": { @@ -242,33 +242,33 @@ } }, "node_modules/@emotion/serialize": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.1.tgz", - "integrity": "sha512-Zl/0LFggN7+L1liljxXdsVSVlg6E/Z/olVWpfxUTxOAmi8NU7YoeWeLfi1RmnB2TATHoaWwIBRoL+FvAJiTUQA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.2.tgz", + "integrity": "sha512-zR6a/fkFP4EAcCMQtLOhIgpprZOwNmCldtpaISpvz348+DP4Mz8ZoKaGGCQpbzepNIUWbq4w6hNZkwDyKoS+HA==", "dependencies": { - "@emotion/hash": "^0.9.0", - "@emotion/memoize": "^0.8.0", - "@emotion/unitless": "^0.8.0", - "@emotion/utils": "^1.2.0", + "@emotion/hash": "^0.9.1", + "@emotion/memoize": "^0.8.1", + "@emotion/unitless": "^0.8.1", + "@emotion/utils": "^1.2.1", "csstype": "^3.0.2" } }, "node_modules/@emotion/sheet": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.2.1.tgz", - "integrity": "sha512-zxRBwl93sHMsOj4zs+OslQKg/uhF38MB+OMKoCrVuS0nyTkqnau+BM3WGEoOptg9Oz45T/aIGs1qbVAsEFo3nA==" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.2.2.tgz", + "integrity": "sha512-0QBtGvaqtWi+nx6doRwDdBIzhNdZrXUppvTM4dtZZWEGTXL/XE/yJxLMGlDT1Gt+UHH5IX1n+jkXyytE/av7OA==" }, "node_modules/@emotion/styled": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.10.8.tgz", - "integrity": "sha512-gow0lF4Uw/QEdX2REMhI8v6wLOabPKJ+4HKNF0xdJ2DJdznN6fxaXpQOx6sNkyBhSUL558Rmcu1Lq/MYlVo4vw==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.11.0.tgz", + "integrity": "sha512-hM5Nnvu9P3midq5aaXj4I+lnSfNi7Pmd4EWk1fOZ3pxookaQTNew6bp4JaCBYM4HVFZF9g7UjJmsUmC2JlxOng==", "dependencies": { "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.10.8", - "@emotion/is-prop-valid": "^1.2.0", - "@emotion/serialize": "^1.1.1", - "@emotion/use-insertion-effect-with-fallbacks": "^1.0.0", - "@emotion/utils": "^1.2.0" + "@emotion/babel-plugin": "^11.11.0", + "@emotion/is-prop-valid": "^1.2.1", + "@emotion/serialize": "^1.1.2", + "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", + "@emotion/utils": "^1.2.1" }, "peerDependencies": { "@emotion/react": "^11.0.0-rc.0", @@ -281,27 +281,27 @@ } }, "node_modules/@emotion/unitless": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.0.tgz", - "integrity": "sha512-VINS5vEYAscRl2ZUDiT3uMPlrFQupiKgHz5AA4bCH1miKBg4qtwkim1qPmJj/4WG6TreYMY111rEFsjupcOKHw==" + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", + "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==" }, "node_modules/@emotion/use-insertion-effect-with-fallbacks": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.0.tgz", - "integrity": "sha512-1eEgUGmkaljiBnRMTdksDV1W4kUnmwgp7X9G8B++9GYwl1lUdqSndSriIrTJ0N7LQaoauY9JJ2yhiOYK5+NI4A==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.1.tgz", + "integrity": "sha512-jT/qyKZ9rzLErtrjGgdkMBn2OP8wl0G3sQlBb3YPryvKHsjvINUhVaPFfP+fpBcOkmrVOVEEHQFJ7nbj2TH2gw==", "peerDependencies": { "react": ">=16.8.0" } }, "node_modules/@emotion/utils": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.2.0.tgz", - "integrity": "sha512-sn3WH53Kzpw8oQ5mgMmIzzyAaH2ZqFEbozVVBSYp538E06OSE6ytOp7pRAjNQR+Q/orwqdQYJSe2m3hCOeznkw==" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.2.1.tgz", + "integrity": "sha512-Y2tGf3I+XVnajdItskUCn6LX+VUDmP6lTL4fcqsXAv43dnlbZiuW4MWQW38rW/BVWSE7Q/7+XQocmpnRYILUmg==" }, "node_modules/@emotion/weak-memoize": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz", - "integrity": "sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg==" + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.1.tgz", + "integrity": "sha512-EsBwpc7hBUJWAsNPBmJy4hxWx12v6bshQsldrVmjxJoc3isbxhOrF2IcCpaXxfvq03NwkI7sbsOLXbYuqF/8Ww==" }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", @@ -326,13 +326,13 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", - "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", + "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.1", + "espree": "^9.5.2", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -942,9 +942,9 @@ } }, "node_modules/@types/react-is/node_modules/@types/react": { - "version": "17.0.58", - "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.58.tgz", - "integrity": "sha512-c1GzVY97P0fGxwGxhYq989j4XwlcHQoto6wQISOC2v6wm3h0PORRWJFHlkRjfGsiG3y1609WdQ+J+tKxvrEd6A==", + "version": "17.0.59", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.59.tgz", + "integrity": "sha512-gSON5zWYIGyoBcycCE75E9+r6dCC2dHdsrVkOEiIYNU5+Q28HcBAuqvDuxHcCbMfHBHdeT5Tva/AFn3rnMKE4g==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -952,9 +952,9 @@ } }, "node_modules/@types/react-transition-group": { - "version": "4.4.5", - "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.5.tgz", - "integrity": "sha512-juKD/eiSM3/xZYzjuzH6ZwpP+/lejltmiS3QEzV/vmb/Q8+HfDmxu+Baga8UEMGBqV88Nbg4l2hY/K2DkyaLLA==", + "version": "4.4.6", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.6.tgz", + "integrity": "sha512-VnCdSxfcm08KjsJVQcfBmhEQAPnLB8G08hAxn39azX1qYBQ/5RVQuoHuKIcfKOdncuaUvEpFKFzEvbtIMsfVew==", "dependencies": { "@types/react": "*" } @@ -965,18 +965,18 @@ "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" }, "node_modules/@types/validator": { - "version": "13.7.15", - "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.15.tgz", - "integrity": "sha512-yeinDVQunb03AEP8luErFcyf/7Lf7AzKCD0NXfgVoGCCQDNpZET8Jgq74oBgqKld3hafLbfzt/3inUdQvaFeXQ==" + "version": "13.7.16", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.16.tgz", + "integrity": "sha512-VyKmLktUHYLbrSbsRi241MSUlGYomQgK/tfCNpej3Gt5qDOM10AZ3nU2aR2s5JritClXuOBu4K7MkywVW/Y6Ow==" }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.2.tgz", - "integrity": "sha512-uq0sKyw6ao1iFOZZGk9F8Nro/8+gfB5ezl1cA06SrqbgJAt0SRoFhb9pXaHvkrxUpZaoLxt8KlovHNk8Gp6/HQ==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.5.tgz", + "integrity": "sha512-NJXQC4MRnF9N9yWqQE2/KLRSOLvrrlZb48NGVfBa+RuPMN6B7ZcK5jZOvhuygv4D64fRKnZI4L4p8+M+rfeQuw==", "dependencies": { - "@typescript-eslint/scope-manager": "5.59.2", - "@typescript-eslint/types": "5.59.2", - "@typescript-eslint/typescript-estree": "5.59.2", + "@typescript-eslint/scope-manager": "5.59.5", + "@typescript-eslint/types": "5.59.5", + "@typescript-eslint/typescript-estree": "5.59.5", "debug": "^4.3.4" }, "engines": { @@ -996,12 +996,12 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.2.tgz", - "integrity": "sha512-dB1v7ROySwQWKqQ8rEWcdbTsFjh2G0vn8KUyvTXdPoyzSL6lLGkiXEV5CvpJsEe9xIdKV+8Zqb7wif2issoOFA==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.5.tgz", + "integrity": "sha512-jVecWwnkX6ZgutF+DovbBJirZcAxgxC0EOHYt/niMROf8p4PwxxG32Qdhj/iIQQIuOflLjNkxoXyArkcIP7C3A==", "dependencies": { - "@typescript-eslint/types": "5.59.2", - "@typescript-eslint/visitor-keys": "5.59.2" + "@typescript-eslint/types": "5.59.5", + "@typescript-eslint/visitor-keys": "5.59.5" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1012,9 +1012,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.2.tgz", - "integrity": "sha512-LbJ/HqoVs2XTGq5shkiKaNTuVv5tTejdHgfdjqRUGdYhjW1crm/M7og2jhVskMt8/4wS3T1+PfFvL1K3wqYj4w==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.5.tgz", + "integrity": "sha512-xkfRPHbqSH4Ggx4eHRIO/eGL8XL4Ysb4woL8c87YuAo8Md7AUjyWKa9YMwTL519SyDPrfEgKdewjkxNCVeJW7w==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -1024,12 +1024,12 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.2.tgz", - "integrity": "sha512-+j4SmbwVmZsQ9jEyBMgpuBD0rKwi9RxRpjX71Brr73RsYnEr3Lt5QZ624Bxphp8HUkSKfqGnPJp1kA5nl0Sh7Q==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.5.tgz", + "integrity": "sha512-+XXdLN2CZLZcD/mO7mQtJMvCkzRfmODbeSKuMY/yXbGkzvA9rJyDY5qDYNoiz2kP/dmyAxXquL2BvLQLJFPQIg==", "dependencies": { - "@typescript-eslint/types": "5.59.2", - "@typescript-eslint/visitor-keys": "5.59.2", + "@typescript-eslint/types": "5.59.5", + "@typescript-eslint/visitor-keys": "5.59.5", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1050,11 +1050,11 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.2.tgz", - "integrity": "sha512-EEpsO8m3RASrKAHI9jpavNv9NlEUebV4qmF1OWxSTtKSFBpC1NCmWazDQHFivRf0O1DV11BA645yrLEVQ0/Lig==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.5.tgz", + "integrity": "sha512-qL+Oz+dbeBRTeyJTIy0eniD3uvqU7x+y1QceBismZ41hd4aBSRh8UAw4pZP0+XzLuPZmx4raNMq/I+59W2lXKA==", "dependencies": { - "@typescript-eslint/types": "5.59.2", + "@typescript-eslint/types": "5.59.5", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -1363,9 +1363,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001482", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001482.tgz", - "integrity": "sha512-F1ZInsg53cegyjroxLNW9DmrEQ1SuGRTO1QlpA0o2/6OpQ0gFeDRoq1yFmnr8Sakn9qwwt9DmbxHB6w167OSuQ==", + "version": "1.0.30001486", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001486.tgz", + "integrity": "sha512-uv7/gXuHi10Whlj0pp5q/tsK/32J2QSqVRKQhs2j8VsDCjgyruAh/eEXHF822VqO9yT6iZKw3nRwZRSPBE9OQg==", "funding": [ { "type": "opencollective", @@ -2174,9 +2174,9 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", - "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -2185,13 +2185,13 @@ } }, "node_modules/espree": { - "version": "9.5.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", - "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", + "version": "9.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", + "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", "dependencies": { "acorn": "^8.8.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -3166,7 +3166,7 @@ } }, "node_modules/le-coffre-resources": { - "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#5052051e1d3f56b8f895f7132090c77ff7bdd6bc", + "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#b3d3495c0e65afc0b149d6c07fd5741e144e2aaa", "license": "MIT", "dependencies": { "class-transformer": "^0.5.1", @@ -3186,9 +3186,9 @@ } }, "node_modules/libphonenumber-js": { - "version": "1.10.28", - "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.28.tgz", - "integrity": "sha512-1eAgjLrZA0+2Wgw4hs+4Q/kEBycxQo8ZLYnmOvZ3AlM8ImAVAJgDPlZtISLEzD1vunc2q8s2Pn7XwB7I8U3Kzw==" + "version": "1.10.30", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.30.tgz", + "integrity": "sha512-PLGc+xfrQrkya/YK2/5X+bPpxRmyJBHM+xxz9krUdSgk4Vs2ZwxX5/Ow0lv3r9PDlDtNWb4u+it8MY5rZ0IyGw==" }, "node_modules/lines-and-columns": { "version": "1.2.4", @@ -4287,9 +4287,9 @@ } }, "node_modules/stylis": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.1.4.tgz", - "integrity": "sha512-USf5pszRYwuE6hg9by0OkKChkQYEXfkeTtm0xKw+jqQhwyjCVLdYyMBK7R+n7dhzsblAWJnGxju4vxq5eH20GQ==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", + "integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==" }, "node_modules/supports-color": { "version": "7.2.0", diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts index 948d021c..bb51d0e0 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds.ts @@ -16,6 +16,7 @@ export type IPutDeedsParams = { description?: OfficeFolder["description"]; archived_description?: OfficeFolder["archived_description"]; status?: OfficeFolder["status"]; + deed_has_document_types?: Deed["deed_has_document_types"]; }; @Service() diff --git a/src/front/Components/DesignSystem/UserFolder/classes.module.scss b/src/front/Components/DesignSystem/UserFolder/classes.module.scss index 570bdaf9..b091f167 100644 --- a/src/front/Components/DesignSystem/UserFolder/classes.module.scss +++ b/src/front/Components/DesignSystem/UserFolder/classes.module.scss @@ -62,6 +62,7 @@ display: inline-grid; justify-items: start; gap: 32px; + margin-top: 16px; } } } diff --git a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx index cb9af00c..e79da376 100644 --- a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx @@ -16,11 +16,11 @@ import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; -import DeedTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes"; import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; import Module from "@Front/Config/Module"; -import DocumentTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes"; import { OfficeFolder } from "le-coffre-resources/dist/Customer"; +import Deeds from "@Front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds"; +import DocumentTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes"; type IProps = {}; type IPropsClass = IProps & { @@ -131,7 +131,11 @@ class AskDocumentsClass extends BasePage { q:{ deed: { include: { - deed_type: true + deed_has_document_types: { + include: { + document_type: true + } + } } }, office: true @@ -148,9 +152,9 @@ class AskDocumentsClass extends BasePage { } private async getAvailableDocuments(folder: OfficeFolder): Promise{ - const documentTypes = await DeedTypes.getInstance().getByUid(folder.deed!.deed_type!.uid!, { + const documentTypes = await Deeds.getInstance().getByUid(folder.deed!.uid!, { q: { - deed_type_has_document_types: { + deed_has_document_types: { include: { document_type: true } @@ -160,7 +164,7 @@ class AskDocumentsClass extends BasePage { if(!documentTypes) return []; - const documentTypesOptions: IOption[] = documentTypes.deed_type_has_document_types!.map((documentType) => { + const documentTypesOptions: IOption[] = documentTypes.deed_has_document_types!.map((documentType) => { return { label: documentType.document_type!.name!, value: documentType.document_type!.uid!, @@ -180,7 +184,7 @@ class AskDocumentsClass extends BasePage { private async addDocument() { try{ - await DocumentTypes.getInstance().post({ + const documentType = await DocumentTypes.getInstance().post({ name: this.state.documentName, private_description: this.state.visibleDescription, office: { @@ -189,6 +193,17 @@ class AskDocumentsClass extends BasePage { public_description: this.state.visibleDescription }) + const oldDocumentsType = this.state.folder?.deed?.deed_has_document_types!; + const deed = await Deeds.getInstance().put(this.state.folder?.deed?.uid!,{ + deed_has_document_types: [ + ...oldDocumentsType, + { + document_type: documentType, + } + ] + }); + + console.log("Deed : ", deed); await this.loadData(); this.setState({ isCreateDocumentModalVisible: false, From 824390d9f4e244022ff4aa89773b13f566c6947d Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 16:24:51 +0200 Subject: [PATCH 10/15] :bug: Forgot console log --- src/front/Components/Layouts/Folder/AskDocuments/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx index fac5849e..44aced87 100644 --- a/src/front/Components/Layouts/Folder/AskDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/AskDocuments/index.tsx @@ -232,7 +232,6 @@ class AskDocumentsClass extends BasePage { }catch(e){ console.error(e); } - console.log(values["document_types"]); } } From 10dced877b44cc951ef37c64594410773408bfc4 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 16:50:50 +0200 Subject: [PATCH 11/15] :sparkles: Fixing remove/edit of customers --- .../DesignSystem/RadioBox/index.tsx | 14 +++- .../Folder/AddClientToFolder/index.tsx | 80 ++++++++++++------- 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/src/front/Components/DesignSystem/RadioBox/index.tsx b/src/front/Components/DesignSystem/RadioBox/index.tsx index 5db4f30e..47fdd9ba 100644 --- a/src/front/Components/DesignSystem/RadioBox/index.tsx +++ b/src/front/Components/DesignSystem/RadioBox/index.tsx @@ -1,4 +1,5 @@ import React from "react"; + import Tooltip from "../ToolTip"; import Typography, { ITypo, ITypoColor } from "../Typography"; import classes from "./classes.module.scss"; @@ -7,12 +8,16 @@ type IProps = { children: React.ReactNode; name: string; toolTip?: string; - defaultChecked?: boolean; + checked?: boolean; onChange?: (event: React.ChangeEvent) => void; value: string; + disabled: boolean; }; export default class RadioBox extends React.Component { + static defaultProps = { + disabled: false, + }; public override render(): JSX.Element { return ( @@ -20,9 +25,10 @@ export default class RadioBox extends React.Component { {this.props.children} {this.props.toolTip && } @@ -30,4 +36,8 @@ export default class RadioBox extends React.Component { ); } + + public override componentDidMount(): void { + console.log(this.props); + } } diff --git a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx index 5daf7a2d..170655ad 100644 --- a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx +++ b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx @@ -1,3 +1,7 @@ +import "reflect-metadata"; + +import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers"; +import Folders, { IPutFoldersParams } from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Form from "@Front/Components/DesignSystem/Form"; import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField"; @@ -7,24 +11,22 @@ import { IOption } from "@Front/Components/DesignSystem/Select"; import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import BackArrow from "@Front/Components/Elements/BackArrow"; import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import Module from "@Front/Config/Module"; +import { ECivility } from "le-coffre-resources/dist/Customer/Contact"; +import { Customer } from "le-coffre-resources/dist/Notary"; +import Link from "next/link"; import { NextRouter, useRouter } from "next/router"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; -import Link from "next/link"; -import Module from "@Front/Config/Module"; -import { ECivility } from "le-coffre-resources/dist/Customer/Contact"; -import Folders, { IPutFoldersParams } from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders"; -import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers"; -import { Customer } from "le-coffre-resources/dist/Notary"; type IProps = {}; type IState = { selectedFolder: IDashBoardFolder | null; - isExistingClientSelected: boolean; - isNewClientSelected: boolean; - availableCustomers: Customer[] | null; + selectedOption: "new_customer" | "existing_customer"; + availableCustomers: Customer[]; selectedCustomers: readonly IOption[]; + existingCustomers: IOption[]; }; type IPropsClass = IProps & { @@ -36,10 +38,10 @@ class AddClientToFolderClass extends BasePage { super(props); this.state = { selectedFolder: null, - isExistingClientSelected: true, - isNewClientSelected: false, + selectedOption: "existing_customer", availableCustomers: [], selectedCustomers: [], + existingCustomers: [], }; this.onSelectedFolder = this.onSelectedFolder.bind(this); this.onExistingClientSelected = this.onExistingClientSelected.bind(this); @@ -61,24 +63,27 @@ class AddClientToFolderClass extends BasePage {
Associer un ou plusieurs client(s)
- - Client existant - + {this.state.availableCustomers.length !== 0 && ( + + Client existant + + )} + Nouveau client
- {this.state.isExistingClientSelected && ( + {this.state.selectedOption === "existing_customer" && (
{
)} - {this.state.isNewClientSelected && ( + {this.state.selectedOption === "new_customer" && (
@@ -118,9 +123,21 @@ class AddClientToFolderClass extends BasePage { public override async componentDidMount() { const query = {}; const availableCustomers = await Customers.getInstance().get(query); - let preSelectedCustomers: IOption[] | undefined = await this.getFolderPreSelectedCustomers(this.props.selectedFolderUid); - const selectedCustomers = preSelectedCustomers ?? []; - this.setState({ availableCustomers, selectedCustomers }); + let preExistingCustomers: IOption[] | undefined = await this.getFolderPreSelectedCustomers(this.props.selectedFolderUid); + const existingCustomers = preExistingCustomers ?? []; + + existingCustomers.forEach((customer) => { + const index = availableCustomers.findIndex((availableCustomer) => availableCustomer.uid === customer.value); + if (index !== -1) availableCustomers.splice(index, 1); + }); + + if (availableCustomers.length === 0) { + this.setState({ + selectedOption: "new_customer", + }); + } + + this.setState({ availableCustomers, existingCustomers }); } private async getFolderPreSelectedCustomers(folderUid: string): Promise { @@ -137,10 +154,10 @@ class AddClientToFolderClass extends BasePage { }, }, }; - let preSelectedCustomers: IOption[] = []; + let preExistingCustomers: IOption[] = []; try { const folder = await Folders.getInstance().getByUid(folderUid, query); - preSelectedCustomers = folder.office_folder_has_customers!.map((folderHasCustomer) => { + preExistingCustomers = folder.office_folder_has_customers!.map((folderHasCustomer) => { return { label: folderHasCustomer.customer.contact?.first_name + " " + folderHasCustomer.customer.contact?.last_name, value: folderHasCustomer.customer.uid, @@ -150,7 +167,7 @@ class AddClientToFolderClass extends BasePage { this.props.router.push(Module.getInstance().get().modules.pages["404"].props.path); return; } - return preSelectedCustomers; + return preExistingCustomers; } private getSelectedOptions(): IOption[] { @@ -173,11 +190,11 @@ class AddClientToFolderClass extends BasePage { } private onExistingClientSelected(): void { - this.setState({ isExistingClientSelected: true, isNewClientSelected: false }); + this.setState({ selectedOption: "existing_customer" }); } private onNewClientSelected(): void { - this.setState({ isExistingClientSelected: false, isNewClientSelected: true }); + this.setState({ selectedOption: "new_customer" }); } private async onFormSubmit( @@ -188,13 +205,14 @@ class AddClientToFolderClass extends BasePage { ) { values["civility"] = ECivility.MALE; // TODO: should maybe be deleted later or added to the form - let customersToLink: IPutFoldersParams["office_folder_has_customers"] = this.state.selectedCustomers.map((customer) => { + const allCustomersToLink = this.state.selectedCustomers.concat(this.state.existingCustomers); + let customersToLink: IPutFoldersParams["office_folder_has_customers"] = allCustomersToLink.map((customer) => { return { customer: { uid: customer.value }, }; }) as IPutFoldersParams["office_folder_has_customers"]; - if (this.state.isNewClientSelected) { + if (this.state.selectedOption === "new_customer") { const customer: Customer = await Customers.getInstance().post({ contact: values, }); From 8894b5fd7464c5d266aaa3d4cb8506a19f4ad788 Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Tue, 9 May 2023 16:52:16 +0200 Subject: [PATCH 12/15] customer allowed to post files --- package-lock.json | 293 +++++++++++------- package.json | 3 +- src/front/Api/BaseApiService.ts | 12 + .../SuperAdmin/Documents/Documents.ts | 3 +- .../Api/LeCoffreApi/SuperAdmin/Files/Files.ts | 26 +- .../DesignSystem/DepositDocument/index.tsx | 26 +- .../Layouts/ClientDashboard/index.tsx | 41 ++- .../Services/CryptoService/CryptoService.ts | 14 +- tsconfig.json | 52 ++-- 9 files changed, 305 insertions(+), 165 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3fbee2e1..52eeaf26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,8 @@ "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.35", + "form-data": "^4.0.0", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.40", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", @@ -171,65 +172,65 @@ } }, "node_modules/@emotion/babel-plugin": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.10.8.tgz", - "integrity": "sha512-gxNky50AJL3AlkbjvTARiwAqei6/tNUxDZPSKd+3jqWVM3AmdVTTdpjHorR/an/M0VJqdsuq5oGcFH+rjtyujQ==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/babel-plugin/-/babel-plugin-11.11.0.tgz", + "integrity": "sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==", "dependencies": { "@babel/helper-module-imports": "^7.16.7", "@babel/runtime": "^7.18.3", - "@emotion/hash": "^0.9.0", - "@emotion/memoize": "^0.8.0", - "@emotion/serialize": "^1.1.1", + "@emotion/hash": "^0.9.1", + "@emotion/memoize": "^0.8.1", + "@emotion/serialize": "^1.1.2", "babel-plugin-macros": "^3.1.0", "convert-source-map": "^1.5.0", "escape-string-regexp": "^4.0.0", "find-root": "^1.1.0", "source-map": "^0.5.7", - "stylis": "4.1.4" + "stylis": "4.2.0" } }, "node_modules/@emotion/cache": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.10.8.tgz", - "integrity": "sha512-5fyqGHi51LU95o7qQ/vD1jyvC4uCY5GcBT+UgP4LHdpO9jPDlXqhrRr9/wCKmfoAvh5G/F7aOh4MwQa+8uEqhA==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/cache/-/cache-11.11.0.tgz", + "integrity": "sha512-P34z9ssTCBi3e9EI1ZsWpNHcfY1r09ZO0rZbRO2ob3ZQMnFI35jB536qoXbkdesr5EUhYi22anuEJuyxifaqAQ==", "dependencies": { - "@emotion/memoize": "^0.8.0", - "@emotion/sheet": "^1.2.1", - "@emotion/utils": "^1.2.0", - "@emotion/weak-memoize": "^0.3.0", - "stylis": "4.1.4" + "@emotion/memoize": "^0.8.1", + "@emotion/sheet": "^1.2.2", + "@emotion/utils": "^1.2.1", + "@emotion/weak-memoize": "^0.3.1", + "stylis": "4.2.0" } }, "node_modules/@emotion/hash": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.0.tgz", - "integrity": "sha512-14FtKiHhy2QoPIzdTcvh//8OyBlknNs2nXRwIhG904opCby3l+9Xaf/wuPvICBF0rc1ZCNBd3nKe9cd2mecVkQ==" + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.1.tgz", + "integrity": "sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ==" }, "node_modules/@emotion/is-prop-valid": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.0.tgz", - "integrity": "sha512-3aDpDprjM0AwaxGE09bOPkNxHpBd+kA6jty3RnaEXdweX1DF1U3VQpPYb0g1IStAuK7SVQ1cy+bNBBKp4W3Fjg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.1.tgz", + "integrity": "sha512-61Mf7Ufx4aDxx1xlDeOm8aFFigGHE4z+0sKCa+IHCeZKiyP9RLD0Mmx7m8b9/Cf37f7NAvQOOJAbQQGVr5uERw==", "dependencies": { - "@emotion/memoize": "^0.8.0" + "@emotion/memoize": "^0.8.1" } }, "node_modules/@emotion/memoize": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.0.tgz", - "integrity": "sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==" + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" }, "node_modules/@emotion/react": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.10.8.tgz", - "integrity": "sha512-ZfGfiABtJ1P1OXqOBsW08EgCDp5fK6C5I8hUJauc/VcJBGSzqAirMnFslhFWnZJ/w5HxPI36XbvMV0l4KZHl+w==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.11.0.tgz", + "integrity": "sha512-ZSK3ZJsNkwfjT3JpDAWJZlrGD81Z3ytNDsxw1LKq1o+xkmO5pnWfr6gmCC8gHEFf3nSSX/09YrG67jybNPxSUw==", "dependencies": { "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.10.8", - "@emotion/cache": "^11.10.8", - "@emotion/serialize": "^1.1.1", - "@emotion/use-insertion-effect-with-fallbacks": "^1.0.0", - "@emotion/utils": "^1.2.0", - "@emotion/weak-memoize": "^0.3.0", + "@emotion/babel-plugin": "^11.11.0", + "@emotion/cache": "^11.11.0", + "@emotion/serialize": "^1.1.2", + "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", + "@emotion/utils": "^1.2.1", + "@emotion/weak-memoize": "^0.3.1", "hoist-non-react-statics": "^3.3.1" }, "peerDependencies": { @@ -242,33 +243,33 @@ } }, "node_modules/@emotion/serialize": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.1.tgz", - "integrity": "sha512-Zl/0LFggN7+L1liljxXdsVSVlg6E/Z/olVWpfxUTxOAmi8NU7YoeWeLfi1RmnB2TATHoaWwIBRoL+FvAJiTUQA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@emotion/serialize/-/serialize-1.1.2.tgz", + "integrity": "sha512-zR6a/fkFP4EAcCMQtLOhIgpprZOwNmCldtpaISpvz348+DP4Mz8ZoKaGGCQpbzepNIUWbq4w6hNZkwDyKoS+HA==", "dependencies": { - "@emotion/hash": "^0.9.0", - "@emotion/memoize": "^0.8.0", - "@emotion/unitless": "^0.8.0", - "@emotion/utils": "^1.2.0", + "@emotion/hash": "^0.9.1", + "@emotion/memoize": "^0.8.1", + "@emotion/unitless": "^0.8.1", + "@emotion/utils": "^1.2.1", "csstype": "^3.0.2" } }, "node_modules/@emotion/sheet": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.2.1.tgz", - "integrity": "sha512-zxRBwl93sHMsOj4zs+OslQKg/uhF38MB+OMKoCrVuS0nyTkqnau+BM3WGEoOptg9Oz45T/aIGs1qbVAsEFo3nA==" + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.2.2.tgz", + "integrity": "sha512-0QBtGvaqtWi+nx6doRwDdBIzhNdZrXUppvTM4dtZZWEGTXL/XE/yJxLMGlDT1Gt+UHH5IX1n+jkXyytE/av7OA==" }, "node_modules/@emotion/styled": { - "version": "11.10.8", - "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.10.8.tgz", - "integrity": "sha512-gow0lF4Uw/QEdX2REMhI8v6wLOabPKJ+4HKNF0xdJ2DJdznN6fxaXpQOx6sNkyBhSUL558Rmcu1Lq/MYlVo4vw==", + "version": "11.11.0", + "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.11.0.tgz", + "integrity": "sha512-hM5Nnvu9P3midq5aaXj4I+lnSfNi7Pmd4EWk1fOZ3pxookaQTNew6bp4JaCBYM4HVFZF9g7UjJmsUmC2JlxOng==", "dependencies": { "@babel/runtime": "^7.18.3", - "@emotion/babel-plugin": "^11.10.8", - "@emotion/is-prop-valid": "^1.2.0", - "@emotion/serialize": "^1.1.1", - "@emotion/use-insertion-effect-with-fallbacks": "^1.0.0", - "@emotion/utils": "^1.2.0" + "@emotion/babel-plugin": "^11.11.0", + "@emotion/is-prop-valid": "^1.2.1", + "@emotion/serialize": "^1.1.2", + "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", + "@emotion/utils": "^1.2.1" }, "peerDependencies": { "@emotion/react": "^11.0.0-rc.0", @@ -281,27 +282,27 @@ } }, "node_modules/@emotion/unitless": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.0.tgz", - "integrity": "sha512-VINS5vEYAscRl2ZUDiT3uMPlrFQupiKgHz5AA4bCH1miKBg4qtwkim1qPmJj/4WG6TreYMY111rEFsjupcOKHw==" + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", + "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==" }, "node_modules/@emotion/use-insertion-effect-with-fallbacks": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.0.tgz", - "integrity": "sha512-1eEgUGmkaljiBnRMTdksDV1W4kUnmwgp7X9G8B++9GYwl1lUdqSndSriIrTJ0N7LQaoauY9JJ2yhiOYK5+NI4A==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@emotion/use-insertion-effect-with-fallbacks/-/use-insertion-effect-with-fallbacks-1.0.1.tgz", + "integrity": "sha512-jT/qyKZ9rzLErtrjGgdkMBn2OP8wl0G3sQlBb3YPryvKHsjvINUhVaPFfP+fpBcOkmrVOVEEHQFJ7nbj2TH2gw==", "peerDependencies": { "react": ">=16.8.0" } }, "node_modules/@emotion/utils": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.2.0.tgz", - "integrity": "sha512-sn3WH53Kzpw8oQ5mgMmIzzyAaH2ZqFEbozVVBSYp538E06OSE6ytOp7pRAjNQR+Q/orwqdQYJSe2m3hCOeznkw==" + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emotion/utils/-/utils-1.2.1.tgz", + "integrity": "sha512-Y2tGf3I+XVnajdItskUCn6LX+VUDmP6lTL4fcqsXAv43dnlbZiuW4MWQW38rW/BVWSE7Q/7+XQocmpnRYILUmg==" }, "node_modules/@emotion/weak-memoize": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.0.tgz", - "integrity": "sha512-AHPmaAx+RYfZz0eYu6Gviiagpmiyw98ySSlQvCUhVGDRtDFe4DBS0x1bSjdF3gqUDYOczB+yYvBTtEylYSdRhg==" + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@emotion/weak-memoize/-/weak-memoize-0.3.1.tgz", + "integrity": "sha512-EsBwpc7hBUJWAsNPBmJy4hxWx12v6bshQsldrVmjxJoc3isbxhOrF2IcCpaXxfvq03NwkI7sbsOLXbYuqF/8Ww==" }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", @@ -326,13 +327,13 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.2.tgz", - "integrity": "sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.3.tgz", + "integrity": "sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ==", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.5.1", + "espree": "^9.5.2", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -942,9 +943,9 @@ } }, "node_modules/@types/react-is/node_modules/@types/react": { - "version": "17.0.58", - "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.58.tgz", - "integrity": "sha512-c1GzVY97P0fGxwGxhYq989j4XwlcHQoto6wQISOC2v6wm3h0PORRWJFHlkRjfGsiG3y1609WdQ+J+tKxvrEd6A==", + "version": "17.0.59", + "resolved": "https://registry.npmjs.org/@types/react/-/react-17.0.59.tgz", + "integrity": "sha512-gSON5zWYIGyoBcycCE75E9+r6dCC2dHdsrVkOEiIYNU5+Q28HcBAuqvDuxHcCbMfHBHdeT5Tva/AFn3rnMKE4g==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -952,9 +953,9 @@ } }, "node_modules/@types/react-transition-group": { - "version": "4.4.5", - "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.5.tgz", - "integrity": "sha512-juKD/eiSM3/xZYzjuzH6ZwpP+/lejltmiS3QEzV/vmb/Q8+HfDmxu+Baga8UEMGBqV88Nbg4l2hY/K2DkyaLLA==", + "version": "4.4.6", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.6.tgz", + "integrity": "sha512-VnCdSxfcm08KjsJVQcfBmhEQAPnLB8G08hAxn39azX1qYBQ/5RVQuoHuKIcfKOdncuaUvEpFKFzEvbtIMsfVew==", "dependencies": { "@types/react": "*" } @@ -965,18 +966,18 @@ "integrity": "sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==" }, "node_modules/@types/validator": { - "version": "13.7.15", - "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.15.tgz", - "integrity": "sha512-yeinDVQunb03AEP8luErFcyf/7Lf7AzKCD0NXfgVoGCCQDNpZET8Jgq74oBgqKld3hafLbfzt/3inUdQvaFeXQ==" + "version": "13.7.16", + "resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.7.16.tgz", + "integrity": "sha512-VyKmLktUHYLbrSbsRi241MSUlGYomQgK/tfCNpej3Gt5qDOM10AZ3nU2aR2s5JritClXuOBu4K7MkywVW/Y6Ow==" }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.2.tgz", - "integrity": "sha512-uq0sKyw6ao1iFOZZGk9F8Nro/8+gfB5ezl1cA06SrqbgJAt0SRoFhb9pXaHvkrxUpZaoLxt8KlovHNk8Gp6/HQ==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.59.5.tgz", + "integrity": "sha512-NJXQC4MRnF9N9yWqQE2/KLRSOLvrrlZb48NGVfBa+RuPMN6B7ZcK5jZOvhuygv4D64fRKnZI4L4p8+M+rfeQuw==", "dependencies": { - "@typescript-eslint/scope-manager": "5.59.2", - "@typescript-eslint/types": "5.59.2", - "@typescript-eslint/typescript-estree": "5.59.2", + "@typescript-eslint/scope-manager": "5.59.5", + "@typescript-eslint/types": "5.59.5", + "@typescript-eslint/typescript-estree": "5.59.5", "debug": "^4.3.4" }, "engines": { @@ -996,12 +997,12 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.2.tgz", - "integrity": "sha512-dB1v7ROySwQWKqQ8rEWcdbTsFjh2G0vn8KUyvTXdPoyzSL6lLGkiXEV5CvpJsEe9xIdKV+8Zqb7wif2issoOFA==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.59.5.tgz", + "integrity": "sha512-jVecWwnkX6ZgutF+DovbBJirZcAxgxC0EOHYt/niMROf8p4PwxxG32Qdhj/iIQQIuOflLjNkxoXyArkcIP7C3A==", "dependencies": { - "@typescript-eslint/types": "5.59.2", - "@typescript-eslint/visitor-keys": "5.59.2" + "@typescript-eslint/types": "5.59.5", + "@typescript-eslint/visitor-keys": "5.59.5" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1012,9 +1013,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.2.tgz", - "integrity": "sha512-LbJ/HqoVs2XTGq5shkiKaNTuVv5tTejdHgfdjqRUGdYhjW1crm/M7og2jhVskMt8/4wS3T1+PfFvL1K3wqYj4w==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.59.5.tgz", + "integrity": "sha512-xkfRPHbqSH4Ggx4eHRIO/eGL8XL4Ysb4woL8c87YuAo8Md7AUjyWKa9YMwTL519SyDPrfEgKdewjkxNCVeJW7w==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -1024,12 +1025,12 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.2.tgz", - "integrity": "sha512-+j4SmbwVmZsQ9jEyBMgpuBD0rKwi9RxRpjX71Brr73RsYnEr3Lt5QZ624Bxphp8HUkSKfqGnPJp1kA5nl0Sh7Q==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.5.tgz", + "integrity": "sha512-+XXdLN2CZLZcD/mO7mQtJMvCkzRfmODbeSKuMY/yXbGkzvA9rJyDY5qDYNoiz2kP/dmyAxXquL2BvLQLJFPQIg==", "dependencies": { - "@typescript-eslint/types": "5.59.2", - "@typescript-eslint/visitor-keys": "5.59.2", + "@typescript-eslint/types": "5.59.5", + "@typescript-eslint/visitor-keys": "5.59.5", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1050,11 +1051,11 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.2.tgz", - "integrity": "sha512-EEpsO8m3RASrKAHI9jpavNv9NlEUebV4qmF1OWxSTtKSFBpC1NCmWazDQHFivRf0O1DV11BA645yrLEVQ0/Lig==", + "version": "5.59.5", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.5.tgz", + "integrity": "sha512-qL+Oz+dbeBRTeyJTIy0eniD3uvqU7x+y1QceBismZ41hd4aBSRh8UAw4pZP0+XzLuPZmx4raNMq/I+59W2lXKA==", "dependencies": { - "@typescript-eslint/types": "5.59.2", + "@typescript-eslint/types": "5.59.5", "eslint-visitor-keys": "^3.3.0" }, "engines": { @@ -1235,6 +1236,11 @@ "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz", "integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag==" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -1363,9 +1369,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001482", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001482.tgz", - "integrity": "sha512-F1ZInsg53cegyjroxLNW9DmrEQ1SuGRTO1QlpA0o2/6OpQ0gFeDRoq1yFmnr8Sakn9qwwt9DmbxHB6w167OSuQ==", + "version": "1.0.30001486", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001486.tgz", + "integrity": "sha512-uv7/gXuHi10Whlj0pp5q/tsK/32J2QSqVRKQhs2j8VsDCjgyruAh/eEXHF822VqO9yT6iZKw3nRwZRSPBE9OQg==", "funding": [ { "type": "opencollective", @@ -1482,6 +1488,17 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1637,6 +1654,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -2174,9 +2199,9 @@ } }, "node_modules/eslint-visitor-keys": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz", - "integrity": "sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", + "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -2185,13 +2210,13 @@ } }, "node_modules/espree": { - "version": "9.5.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.1.tgz", - "integrity": "sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg==", + "version": "9.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.5.2.tgz", + "integrity": "sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==", "dependencies": { "acorn": "^8.8.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2376,6 +2401,19 @@ "is-callable": "^1.1.3" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3166,7 +3204,7 @@ } }, "node_modules/le-coffre-resources": { - "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#5052051e1d3f56b8f895f7132090c77ff7bdd6bc", + "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#62639b8bfcd0f779357554a04cd40e8a3ba4e62b", "license": "MIT", "dependencies": { "class-transformer": "^0.5.1", @@ -3186,9 +3224,9 @@ } }, "node_modules/libphonenumber-js": { - "version": "1.10.28", - "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.28.tgz", - "integrity": "sha512-1eAgjLrZA0+2Wgw4hs+4Q/kEBycxQo8ZLYnmOvZ3AlM8ImAVAJgDPlZtISLEzD1vunc2q8s2Pn7XwB7I8U3Kzw==" + "version": "1.10.30", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.30.tgz", + "integrity": "sha512-PLGc+xfrQrkya/YK2/5X+bPpxRmyJBHM+xxz9krUdSgk4Vs2ZwxX5/Ow0lv3r9PDlDtNWb4u+it8MY5rZ0IyGw==" }, "node_modules/lines-and-columns": { "version": "1.2.4", @@ -3266,6 +3304,25 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", @@ -4287,9 +4344,9 @@ } }, "node_modules/stylis": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.1.4.tgz", - "integrity": "sha512-USf5pszRYwuE6hg9by0OkKChkQYEXfkeTtm0xKw+jqQhwyjCVLdYyMBK7R+n7dhzsblAWJnGxju4vxq5eH20GQ==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", + "integrity": "sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==" }, "node_modules/supports-color": { "version": "7.2.0", diff --git a/package.json b/package.json index 80137aaf..eac9c138 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.38", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.40", + "form-data": "^4.0.0", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", diff --git a/src/front/Api/BaseApiService.ts b/src/front/Api/BaseApiService.ts index 3461c6dd..2667e83d 100644 --- a/src/front/Api/BaseApiService.ts +++ b/src/front/Api/BaseApiService.ts @@ -31,6 +31,7 @@ export default abstract class BaseApiService { } protected buildBody(body: { [key: string]: unknown }): string { + console.log("2 >> body >>>", JSON.stringify(body)); return JSON.stringify(body); } @@ -54,6 +55,17 @@ export default abstract class BaseApiService { ); } + protected async postRequestFormData(url: URL, body: FormData) { + return this.sendRequest( + async () => + await fetch(url, { + method: "POST", + headers: this.buildHeaders(ContentType.FORM_DATA), + body, + }), + ); + } + protected async putRequest(url: URL, body: { [key: string]: unknown } = {}) { const request = async () => await fetch(url, { diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts index d9a9e3d7..a3a88213 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Documents/Documents.ts @@ -34,7 +34,8 @@ export default class Documents extends BaseSuperAdmin { public async get(q: IGetDocumentsparams): Promise { const url = new URL(this.baseURl); - Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); + const query = { q }; + if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); try { return await this.getRequest(url); } catch (err) { diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts index 28a49068..63cc47ed 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts @@ -35,13 +35,14 @@ export default class Files extends BaseSuperAdmin { public async get(q: IGetFilesparams): Promise { const url = new URL(this.baseURl); - Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); + const query = { q }; + if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); try { - const files = await this.getRequest(url); - files.forEach(async(file) => { + const files = await this.getRequest(url); + files.forEach(async (file) => { file.file_path = await this.cryptoService.decrypt(file.file_path!, file.iv); - }) - return files + }); + return files; } catch (err) { this.onError(err); return Promise.reject(err); @@ -54,7 +55,7 @@ export default class Files extends BaseSuperAdmin { public async post(body: any): Promise { const url = new URL(this.baseURl); try { - return await this.postRequest(url, body); + return await this.postRequestFormData(url, body); } catch (err) { this.onError(err); return Promise.reject(err); @@ -84,4 +85,17 @@ export default class Files extends BaseSuperAdmin { return Promise.reject(err); } } + + /** + * @description : Delete a folder only if the folder don't contains customers + */ + public async delete(uid: string): Promise { + const url = new URL(this.baseURl.concat(`/${uid}`)); + try { + return await this.deleteRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } } diff --git a/src/front/Components/DesignSystem/DepositDocument/index.tsx b/src/front/Components/DesignSystem/DepositDocument/index.tsx index 306a79b3..0f566b4b 100644 --- a/src/front/Components/DesignSystem/DepositDocument/index.tsx +++ b/src/front/Components/DesignSystem/DepositDocument/index.tsx @@ -9,13 +9,15 @@ import Button, { EButtonVariant } from "../Button"; import Tooltip from "../ToolTip"; import Typography, { ITypo, ITypoColor } from "../Typography"; import classes from "./classes.module.scss"; -import { File as FileCustomer } from "le-coffre-resources/dist/Customer"; +import { Document, File as FileCustomer } from "le-coffre-resources/dist/Customer"; +import Files from "@Front/Api/LeCoffreApi/SuperAdmin/Files/Files"; type IProps = { title: string; dateAsked: Date; defaultFiles?: FileCustomer[]; onChange?: (files: File[]) => void; + document: Document; }; type IFile = { @@ -26,6 +28,7 @@ type IFile = { type IState = { files: IFile[]; isDragOver: boolean; + currentFiles?: FileCustomer[]; }; export default class DepositDocument extends React.Component { @@ -38,6 +41,7 @@ export default class DepositDocument extends React.Component { this.state = { files: [], isDragOver: false, + currentFiles: this.props.defaultFiles, }; this.addDocument = this.addDocument.bind(this); @@ -151,7 +155,7 @@ export default class DepositDocument extends React.Component { if (file) this.addFile(file); } - private addFile(file: File) { + private async addFile(file: File) { this.setState({ files: [ ...this.state.files, @@ -163,17 +167,33 @@ export default class DepositDocument extends React.Component { }); if (this.props.onChange) this.props.onChange(this.state.files.map((file) => file.file)); + + const formData = new FormData(); + formData.append("file", file, file.name); + const query = JSON.stringify({ document: { uid: this.props.document.uid } }); + formData.append("q", query); + + const newFile = await Files.getInstance().post(formData); + const files = this.state.currentFiles ? [...this.state.currentFiles, newFile] : [newFile]; + this.setState({ + currentFiles: files, + }); } - private removeFile(e: any) { + private async removeFile(e: any) { const image = e.target as HTMLElement; const indexToRemove = image.getAttribute("data-file"); if (!indexToRemove) return; + // const file = this.state.files.find((file) => file.index === parseInt(indexToRemove)); this.setState({ files: this.state.files.filter((file) => file.index !== parseInt(indexToRemove)), }); if (this.props.onChange) this.props.onChange(this.state.files.map((file) => file.file)); + // TODO Finir la suppression de fichier + // const deletedFileUid = this.props.document.files?.find((file) => file.file_path === newFile.file_path)?.uid; + // console.log({ deletedFileUid }); + // await Files.getInstance().delete(file?.uid); } private async onFileChange() { diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index 1f147b94..6415bb59 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -8,10 +8,14 @@ import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; import React from "react"; import { documentDeposited } from "../DesignSystem/dummyData"; import classes from "./classes.module.scss"; +import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; +import { Document } from "le-coffre-resources/dist/Customer"; +import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; type IProps = {}; type IState = { isAddDocumentModalVisible: boolean; + documents: Document[]; }; export default class ClientDashboard extends Base { @@ -19,6 +23,7 @@ export default class ClientDashboard extends Base { super(props); this.state = { isAddDocumentModalVisible: false, + documents: [], }; this.onCloseModalAddDocument = this.onCloseModalAddDocument.bind(this); this.onOpenModalAddDocument = this.onOpenModalAddDocument.bind(this); @@ -31,16 +36,15 @@ export default class ClientDashboard extends Base { {this.renderHeader()}
- - - - - - + {this.state.documents?.map((document) => ( + + ))}
Documents supplémentaires (facultatif) @@ -67,7 +71,7 @@ export default class ClientDashboard extends Base { Glissez / Déposez votre document dans la zone prévue à cet effet ou cliquez sur la zone puis sélectionnez le document correspondant. - +
@@ -100,6 +104,21 @@ export default class ClientDashboard extends Base { ); } + public override async componentDidMount() { + // TODO Get documents of the current customer according to userStore + // REMOVE this mock + const mockUsers = (await Users.getInstance().get({}))[2]; + const query: IGetDocumentsparams = { + where: { depositor: mockUsers?.uid }, + include: { + files: true, + }, + }; + const documents: Document[] = await Documents.getInstance().get(query); + console.log({ documents }); + this.setState({ documents }); + } + private onCloseModalAddDocument() { this.setState({ isAddDocumentModalVisible: false }); } diff --git a/src/front/Services/CryptoService/CryptoService.ts b/src/front/Services/CryptoService/CryptoService.ts index c2d62524..281d7023 100644 --- a/src/front/Services/CryptoService/CryptoService.ts +++ b/src/front/Services/CryptoService/CryptoService.ts @@ -5,7 +5,7 @@ import crypto from "crypto"; @Service() export default class CryptoService { private jwkKey: JsonWebKey; - private subtle: SubtleCrypto = crypto.webcrypto.subtle + private subtle: SubtleCrypto = window.crypto.subtle; constructor(protected variables: FrontendVariables) { this.jwkKey = { kty: "oct", @@ -16,7 +16,7 @@ export default class CryptoService { } private async getKey() { - return await this.subtle.importKey("jwk", this.jwkKey, {name: "AES-GCM"}, false, ["encrypt", "decrypt"]); + return await this.subtle.importKey("jwk", this.jwkKey, { name: "AES-GCM" }, false, ["encrypt", "decrypt"]); } /** @@ -36,8 +36,8 @@ export default class CryptoService { encodedData, ); - const cipherText = Buffer.from(cipherData).toString('base64'); - const ivStringified = Buffer.from(iv).toString('base64'); + const cipherText = Buffer.from(cipherData).toString("base64"); + const ivStringified = Buffer.from(iv).toString("base64"); return { cipherText, ivStringified }; } @@ -47,8 +47,8 @@ export default class CryptoService { * @throws {Error} If data cannot be decrypted */ public async decrypt(cipherText: string, ivStringified: string): Promise { - const cipherData = Buffer.from(cipherText, 'base64'); - const iv = Buffer.from(ivStringified, 'base64'); + const cipherData = Buffer.from(cipherText, "base64"); + const iv = Buffer.from(ivStringified, "base64"); const key = await this.getKey(); const decryptedData = await this.subtle.decrypt( { @@ -59,6 +59,6 @@ export default class CryptoService { cipherData, ); - return Buffer.from(decryptedData).toString('utf-8'); + return Buffer.from(decryptedData).toString("utf-8"); } } diff --git a/tsconfig.json b/tsconfig.json index e13e0501..ae259ebf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "incremental": false, + "incremental": false, "target": "es5", "module": "CommonJS", "lib": [ @@ -20,7 +20,7 @@ "allowUnusedLabels": false, "exactOptionalPropertyTypes": false, "noImplicitOverride": true, - "strict": true, + "strict": true, "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, @@ -30,22 +30,38 @@ "alwaysStrict": true, "noPropertyAccessFromIndexSignature": true, /* Additional Checks */ - "noUnusedLocals": true, - "noImplicitReturns": true, + "noUnusedLocals": true, + "noImplicitReturns": true, "noUncheckedIndexedAccess": true, "useUnknownInCatchVariables": true, /* Module Resolution Options */ "moduleResolution": "node", "baseUrl": ".", "paths": { - "@Api/*": ["src/api/*"], - "@Front/*": ["src/front/*"], - "@Assets/*": ["src/front/Assets/*"], - "@Components/*": ["src/front/Components/*"], - "@Themes/*": ["src/front/Themes/*"], - "@Stores/*": ["src/front/Stores/*"], - "@FrontServices/*": ["src/front/services/*"], - "@Page/*": ["src/pages/*"], + "@Api/*": [ + "src/api/*" + ], + "@Front/*": [ + "src/front/*" + ], + "@Assets/*": [ + "src/front/Assets/*" + ], + "@Components/*": [ + "src/front/Components/*" + ], + "@Themes/*": [ + "src/front/Themes/*" + ], + "@Stores/*": [ + "src/front/Stores/*" + ], + "@FrontServices/*": [ + "src/front/services/*" + ], + "@Page/*": [ + "src/pages/*" + ], }, // "rootDirs": [], // "typeRoots": [], @@ -60,19 +76,19 @@ //"inlineSources": false, /* Experimental Options */ "experimentalDecorators": true, - "emitDecoratorMetadata": true, + "emitDecoratorMetadata": true, "skipLibCheck": true, - "forceConsistentCasingInFileNames": true, + "forceConsistentCasingInFileNames": true, "allowJs": true, "isolatedModules": true }, "include": [ "next-env.d.ts", "**/*.ts", - "**/*.tsx" -, "src/front/next.config.js" ], + "**/*.tsx", + "src/front/next.config.js" + ], "exclude": [ "node_modules" ] -} - +} \ No newline at end of file From 296ff3ed3d6e1c2261c2c1f9504d0068602158d9 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 16:54:34 +0200 Subject: [PATCH 13/15] :bug: Fixing default checked build --- src/front/Components/DesignSystem/RadioBox/index.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/front/Components/DesignSystem/RadioBox/index.tsx b/src/front/Components/DesignSystem/RadioBox/index.tsx index 47fdd9ba..4d779e20 100644 --- a/src/front/Components/DesignSystem/RadioBox/index.tsx +++ b/src/front/Components/DesignSystem/RadioBox/index.tsx @@ -9,6 +9,7 @@ type IProps = { name: string; toolTip?: string; checked?: boolean; + defaultChecked?: boolean; onChange?: (event: React.ChangeEvent) => void; value: string; disabled: boolean; @@ -17,6 +18,7 @@ type IProps = { export default class RadioBox extends React.Component { static defaultProps = { disabled: false, + defaultChecked: false, }; public override render(): JSX.Element { return ( @@ -26,6 +28,7 @@ export default class RadioBox extends React.Component { type="radio" name={this.props.name} checked={this.props.checked} + defaultChecked={this.props.defaultChecked} onChange={this.props.onChange} value={this.props.value} disabled={this.props.disabled} From 7665857f2a35bf916e4427fc25057e34bcd1f5c4 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 16:56:16 +0200 Subject: [PATCH 14/15] :bug: Fixing default checked build --- src/front/Components/DesignSystem/RadioBox/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/front/Components/DesignSystem/RadioBox/index.tsx b/src/front/Components/DesignSystem/RadioBox/index.tsx index 4d779e20..60cdc63d 100644 --- a/src/front/Components/DesignSystem/RadioBox/index.tsx +++ b/src/front/Components/DesignSystem/RadioBox/index.tsx @@ -18,7 +18,6 @@ type IProps = { export default class RadioBox extends React.Component { static defaultProps = { disabled: false, - defaultChecked: false, }; public override render(): JSX.Element { return ( From b8ea4fca5c5685223c98a546a6399e0a4a3b189b Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 9 May 2023 17:02:44 +0200 Subject: [PATCH 15/15] :bug: Review PR --- .../Components/DesignSystem/RadioBox/index.tsx | 4 ---- .../Layouts/Folder/AddClientToFolder/index.tsx | 14 +++++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/front/Components/DesignSystem/RadioBox/index.tsx b/src/front/Components/DesignSystem/RadioBox/index.tsx index 60cdc63d..f41d50ce 100644 --- a/src/front/Components/DesignSystem/RadioBox/index.tsx +++ b/src/front/Components/DesignSystem/RadioBox/index.tsx @@ -38,8 +38,4 @@ export default class RadioBox extends React.Component { ); } - - public override componentDidMount(): void { - console.log(this.props); - } } diff --git a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx index 170655ad..da0e9378 100644 --- a/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx +++ b/src/front/Components/Layouts/Folder/AddClientToFolder/index.tsx @@ -20,10 +20,14 @@ import { NextRouter, useRouter } from "next/router"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; +enum ESelectedOption { + EXISTING_CUSTOMER = "existing_customer", + NEW_CUSTOMER = "new_customer", +} type IProps = {}; type IState = { selectedFolder: IDashBoardFolder | null; - selectedOption: "new_customer" | "existing_customer"; + selectedOption: ESelectedOption; availableCustomers: Customer[]; selectedCustomers: readonly IOption[]; existingCustomers: IOption[]; @@ -38,7 +42,7 @@ class AddClientToFolderClass extends BasePage { super(props); this.state = { selectedFolder: null, - selectedOption: "existing_customer", + selectedOption: ESelectedOption.EXISTING_CUSTOMER, availableCustomers: [], selectedCustomers: [], existingCustomers: [], @@ -133,7 +137,7 @@ class AddClientToFolderClass extends BasePage { if (availableCustomers.length === 0) { this.setState({ - selectedOption: "new_customer", + selectedOption: ESelectedOption.NEW_CUSTOMER, }); } @@ -190,11 +194,11 @@ class AddClientToFolderClass extends BasePage { } private onExistingClientSelected(): void { - this.setState({ selectedOption: "existing_customer" }); + this.setState({ selectedOption: ESelectedOption.EXISTING_CUSTOMER }); } private onNewClientSelected(): void { - this.setState({ selectedOption: "new_customer" }); + this.setState({ selectedOption: ESelectedOption.NEW_CUSTOMER }); } private async onFormSubmit(