From 00a7529c72f741c914d9d7c1eff334c44fa336e1 Mon Sep 17 00:00:00 2001 From: Vincent Alamelle Date: Wed, 3 May 2023 16:20:38 +0200 Subject: [PATCH 1/3] Removed update archived folder description --- .../classes.module.scss | 56 ---------------- .../UpdateFolderDescription/index.tsx | 67 ------------------- 2 files changed, 123 deletions(-) delete mode 100644 src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/classes.module.scss delete mode 100644 src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/index.tsx diff --git a/src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/classes.module.scss b/src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/classes.module.scss deleted file mode 100644 index cd3ceba2..00000000 --- a/src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/classes.module.scss +++ /dev/null @@ -1,56 +0,0 @@ -@import "@Themes/constants.scss"; - -.root { - display: flex; - flex-direction: column; - min-height: 100%; - align-items: flex-start; - width: fit-content; - - .back-arrow { - margin-bottom: 24px; - } - - .form { - width: 100%; - - .content { - margin-top: 32px; - - >:not(:last-child) { - margin-bottom: 24px; - } - - } - - .button-container { - width: 100%; - display: flex; - text-align: center; - margin-top: 24px; - - .cancel-button { - display: flex; - margin-right: 32px; - } - - @media (max-width: $screen-m) { - display: flex; - flex-direction: column-reverse; - - .cancel-button { - margin-left: 0; - margin-top: 12px; - - >* { - flex: 1; - } - } - - >* { - width: 100%; - } - } - } - } -} \ No newline at end of file diff --git a/src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/index.tsx b/src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/index.tsx deleted file mode 100644 index 3416e816..00000000 --- a/src/front/Components/Layouts/FolderArchived/UpdateFolderDescription/index.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; -import Form from "@Front/Components/DesignSystem/Form"; -import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField"; -import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; -import BackArrow from "@Front/Components/Elements/BackArrow"; -import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; -import { 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"; - -type IProps = { - selectedFolderUid: string; -}; -type IState = { - selectedFolder: IDashBoardFolder | null; -}; -class UpdateFolderDescriptionClass extends BasePage { - constructor(props: IProps) { - super(props); - this.state = { - selectedFolder: null, - }; - this.onSelectedFolder = this.onSelectedFolder.bind(this); - } - public override render(): JSX.Element { - const backwardPath = Module.getInstance() - .get() - .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.selectedFolderUid); - return ( - -
-
- -
- Modifier la note du dossier - -
-
- -
- -
- - - - -
-
-
-
- ); - } - - private onSelectedFolder(folder: IDashBoardFolder): void { - this.setState({ selectedFolder: folder }); - } -} - -export default function UpdateFolderDescription() { - const router = useRouter(); - let { folderUid } = router.query; - folderUid = folderUid as string; - return ; -} From 25202a254279aaf74d5509e0e74ecda1b60e6e64 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 3 May 2023 16:33:16 +0200 Subject: [PATCH 2/3] :sparkles: Update users working --- .../SuperAdmin/Customers/Customers.ts | 22 +----- .../Layouts/Folder/UpdateClient/index.tsx | 79 ++++++++++++++++--- 2 files changed, 71 insertions(+), 30 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts index ad759e07..065b0a47 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Customers/Customers.ts @@ -1,5 +1,6 @@ +import { Customer } from "le-coffre-resources/dist/SuperAdmin"; import { Service } from "typedi"; -import Customer from "le-coffre-resources/dist/SuperAdmin"; + import BaseSuperAdmin from "../BaseSuperAdmin"; // TODO Type get query params -> Where + inclue + orderby @@ -31,9 +32,6 @@ export default class Customers extends BaseSuperAdmin { } } - /** - * @description : Get all Customers - */ public async get(q: IGetCustomersparams): Promise { const url = new URL(this.baseURl); Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); @@ -45,22 +43,10 @@ export default class Customers extends BaseSuperAdmin { } } - public async getOne(uid: string): Promise { - const url = new URL(this.baseURl.concat("/").concat(uid)); - try { - return await this.getRequest(url); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } - - /** - * @description : Get a folder by uid - */ public async getByUid(uid: string, q?: any): Promise { const url = new URL(this.baseURl.concat(`/${uid}`)); - if (q) 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/Components/Layouts/Folder/UpdateClient/index.tsx b/src/front/Components/Layouts/Folder/UpdateClient/index.tsx index eea7fa47..779fa406 100644 --- a/src/front/Components/Layouts/Folder/UpdateClient/index.tsx +++ b/src/front/Components/Layouts/Folder/UpdateClient/index.tsx @@ -1,5 +1,4 @@ -import "reflect-metadata"; - +import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Form from "@Front/Components/DesignSystem/Form"; import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField"; @@ -8,14 +7,13 @@ 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 Customer, { Contact } from "le-coffre-resources/dist/Customer"; import Link from "next/link"; import { NextRouter, useRouter } from "next/router"; import { ChangeEvent } from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; -import Customer from "le-coffre-resources/dist/Customer"; -import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers"; type IProps = {}; @@ -63,6 +61,7 @@ class UpdateClientClass extends BasePage { this.leavePage = this.leavePage.bind(this); this.onChangeBirthDateInput = this.onChangeBirthDateInput.bind(this); this.onChangeAddressInput = this.onChangeAddressInput.bind(this); + this.onFormSubmit = this.onFormSubmit.bind(this); } private backwardPath = Module.getInstance() @@ -77,13 +76,29 @@ class UpdateClientClass extends BasePage { Modifier les informations du client -
+
- - - + + + { /> { fakeplaceholder="Adresse" required={false} onChange={this.onChangeAddressInput} + defaultValue={this.state.customer?.contact.address?.address ?? ""} />
@@ -134,8 +151,46 @@ class UpdateClientClass extends BasePage { } public override async componentDidMount() { - const customer = await Customers.getInstance().getOne(this.props.customerUid); - console.log(customer); + const customer = await Customers.getInstance().getByUid(this.props.customerUid, { + contact: { + include: { + address: true, + }, + }, + }); + if (customer) { + this.setState({ + customer, + }); + } + } + + private async onFormSubmit( + e: React.FormEvent | null, + values: { + [key: string]: string; + }, + ) { + const contact = { + first_name: values["first_name"], + last_name: values["last_name"], + email: values["email"], + phone_number: values["phone_number"], + birthdate: values["birthdate"] === "" ? null : values["birthdate"], + address: + values["address"] === "" + ? null + : { + address: values["address"], + }, + } as Contact; + + try{ + await Customers.getInstance().put(this.props.customerUid, { contact }) + this.props.router.push(this.backwardPath); + } catch (e) { + console.error(e) + } } private leavePage() { From dea4f93915f7d304821f454172e0f8092dc7147d Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 3 May 2023 16:52:43 +0200 Subject: [PATCH 3/3] :sparkles: Update folder metadatas working --- .../DesignSystem/Select/classes.module.scss | 9 ++++++ .../Components/DesignSystem/Select/index.tsx | 14 ++++++++-- .../Folder/UpdateFolderMetadata/index.tsx | 28 ++++++++++++++----- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/front/Components/DesignSystem/Select/classes.module.scss b/src/front/Components/DesignSystem/Select/classes.module.scss index 50161650..89f6a04d 100644 --- a/src/front/Components/DesignSystem/Select/classes.module.scss +++ b/src/front/Components/DesignSystem/Select/classes.module.scss @@ -7,6 +7,13 @@ width: 100%; border: 1px solid $grey-medium; + &[data-disabled="true"]{ + .container-label{ + cursor: not-allowed; + } + opacity: 0.6; + } + .container-label { display: flex; justify-content: space-between; @@ -17,6 +24,8 @@ padding: 24px; z-index: 1; + + &[data-border-right-collapsed="true"] { border-radius: 8px 0 0 8px; } diff --git a/src/front/Components/DesignSystem/Select/index.tsx b/src/front/Components/DesignSystem/Select/index.tsx index 72425ece..3ea8698b 100644 --- a/src/front/Components/DesignSystem/Select/index.tsx +++ b/src/front/Components/DesignSystem/Select/index.tsx @@ -9,12 +9,13 @@ import classes from "./classes.module.scss"; type IProps = { selectedOption?: IOption; - onChange: (selectedOption: IOption) => void; + onChange?: (selectedOption: IOption) => void; options: IOption[]; hasBorderRightCollapsed?: boolean; placeholder?: string; className?: string; name?: string; + disabled: boolean; }; export type IOption = { @@ -35,6 +36,10 @@ export default class Select extends React.Component { private rootRef = React.createRef(); private removeOnresize = () => {}; + static defaultProps = { + disabled: false, + }; + constructor(props: IProps) { super(props); this.state = { @@ -50,7 +55,10 @@ export default class Select extends React.Component { public override render(): JSX.Element { const selectedOption = this.state.selectedOption ?? this.props.selectedOption; return ( -
+
{selectedOption && }