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/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 && }
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() { diff --git a/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx b/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx index df559708..dd06cdc1 100644 --- a/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx +++ b/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx @@ -4,6 +4,7 @@ import Folders 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"; +import Select, { 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"; @@ -39,6 +40,11 @@ class UpdateFolderMetadataClass extends BasePage { const backwardPath = Module.getInstance() .get() .modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.state.selectedFolder?.uid!); + const deedOption = { + label: this.state.selectedFolder?.deed?.deed_type?.name, + value: this.state.selectedFolder?.deed?.deed_type?.uid, + } as IOption; + const openingDate = new Date(this.state.selectedFolder?.created_at ?? ""); return (
@@ -55,6 +61,12 @@ class UpdateFolderMetadataClass extends BasePage { fakeplaceholder="Numéro de dossier" defaultValue={this.state.selectedFolder?.folder_number} /> +