🐛 Autofill update client
This commit is contained in:
parent
5feca67743
commit
af66c5bcae
@ -29,7 +29,6 @@ class FolderListClass extends React.Component<IPropsClass, IState> {
|
|||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
{this.props.folders.sort((folder) => {
|
{this.props.folders.sort((folder) => {
|
||||||
const pendingDocuments = folder.documents!.filter((document) => document.document_status === "PENDING");
|
const pendingDocuments = folder.documents!.filter((document) => document.document_status === "PENDING");
|
||||||
console.log(pendingDocuments.length);
|
|
||||||
return pendingDocuments.length >= 1 ? -1 : 1;
|
return pendingDocuments.length >= 1 ? -1 : 1;
|
||||||
}).map((folder) => {
|
}).map((folder) => {
|
||||||
return (
|
return (
|
||||||
|
@ -66,6 +66,7 @@ export default class InputField extends BaseField<IProps> {
|
|||||||
className={
|
className={
|
||||||
this.props.className ? [classes["input"], classes[this.props.className]].join(" ") : classes["input"]
|
this.props.className ? [classes["input"], classes[this.props.className]].join(" ") : classes["input"]
|
||||||
}
|
}
|
||||||
|
value={value}
|
||||||
/>
|
/>
|
||||||
<div className={classes["fake-placeholder"]}>{this.props.fakeplaceholder}</div>
|
<div className={classes["fake-placeholder"]}>{this.props.fakeplaceholder}</div>
|
||||||
</div>
|
</div>
|
||||||
@ -74,6 +75,12 @@ export default class InputField extends BaseField<IProps> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override componentDidMount() {
|
||||||
|
this.setState({
|
||||||
|
value: this.props.defaultValue ?? "",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// We filter the props we'll pass to the primitive input as they're useless for it
|
// We filter the props we'll pass to the primitive input as they're useless for it
|
||||||
// It also avoids the console warning because of passing useless props to a primitive DOM element
|
// It also avoids the console warning because of passing useless props to a primitive DOM element
|
||||||
private getHtmlAttributes() {
|
private getHtmlAttributes() {
|
||||||
|
@ -66,7 +66,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
<FolderBoxInformation folder={this.state.selectedFolder} type={EFolderBoxInformationType.DESCRIPTION} />
|
<FolderBoxInformation folder={this.state.selectedFolder} type={EFolderBoxInformationType.DESCRIPTION} />
|
||||||
</div>
|
</div>
|
||||||
<div className={classes["progress-bar"]}>
|
<div className={classes["progress-bar"]}>
|
||||||
<QuantityProgressBar title="Complétion du dossier" total={100} currentNumber={0} />
|
<QuantityProgressBar title="Complétion du dossier" total={100} currentNumber={34} />
|
||||||
</div>
|
</div>
|
||||||
{this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} />}
|
{this.doesFolderHaveCustomer() && <ClientSection folder={this.state.selectedFolder} />}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,20 +1,28 @@
|
|||||||
|
import "reflect-metadata";
|
||||||
|
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField";
|
import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField";
|
||||||
|
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
||||||
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
import BackArrow from "@Front/Components/Elements/BackArrow";
|
import BackArrow from "@Front/Components/Elements/BackArrow";
|
||||||
|
import { folders } from "@Front/Components/Layouts/DesignSystem/dummyData";
|
||||||
import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
||||||
import { useRouter } from "next/router";
|
import Module from "@Front/Config/Module";
|
||||||
|
import { 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 BasePage from "../../Base";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import Link from "next/link";
|
|
||||||
import { ChangeEvent } from "react";
|
|
||||||
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
|
||||||
import Module from "@Front/Config/Module";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {};
|
||||||
|
|
||||||
|
type IPropsClass = IProps & {
|
||||||
selectedFolderUid: string;
|
selectedFolderUid: string;
|
||||||
|
router: NextRouter;
|
||||||
|
client: Contact | null;
|
||||||
};
|
};
|
||||||
type IState = {
|
type IState = {
|
||||||
selectedFolder: IDashBoardFolder | null;
|
selectedFolder: IDashBoardFolder | null;
|
||||||
@ -25,8 +33,8 @@ type IState = {
|
|||||||
isOpenLeavingModal: boolean;
|
isOpenLeavingModal: boolean;
|
||||||
doesInputHaveValues: boolean;
|
doesInputHaveValues: boolean;
|
||||||
};
|
};
|
||||||
class UpdateClientClass extends BasePage<IProps, IState> {
|
class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||||
constructor(props: IProps) {
|
constructor(props: IPropsClass) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedFolder: null,
|
selectedFolder: null,
|
||||||
@ -44,34 +52,38 @@ class UpdateClientClass extends BasePage<IProps, IState> {
|
|||||||
this.onChangePhoneNumberInput = this.onChangePhoneNumberInput.bind(this);
|
this.onChangePhoneNumberInput = this.onChangePhoneNumberInput.bind(this);
|
||||||
this.openLeavingModal = this.openLeavingModal.bind(this);
|
this.openLeavingModal = this.openLeavingModal.bind(this);
|
||||||
this.closeLeavingModal = this.closeLeavingModal.bind(this);
|
this.closeLeavingModal = this.closeLeavingModal.bind(this);
|
||||||
|
this.leavePage = this.leavePage.bind(this);
|
||||||
}
|
}
|
||||||
public override render(): JSX.Element {
|
|
||||||
const backwardPath = Module.getInstance()
|
private backwardPath = Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.selectedFolderUid);
|
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.selectedFolderUid);
|
||||||
|
|
||||||
|
public override render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<DefaultNotaryDashboard title={"Ajouter client(s)"} onSelectedFolder={this.onSelectedFolder}>
|
<DefaultNotaryDashboard title={"Ajouter client(s)"} onSelectedFolder={this.onSelectedFolder}>
|
||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
<div className={classes["back-arrow"]}>
|
<div className={classes["back-arrow"]}>
|
||||||
<BackArrow url={backwardPath} />
|
<BackArrow url={this.backwardPath} />
|
||||||
</div>
|
</div>
|
||||||
<Typography typo={ITypo.H1Bis}>Modifier les informations du client</Typography>
|
<Typography typo={ITypo.H1Bis}>Modifier les informations du client</Typography>
|
||||||
<Form className={classes["form"]}>
|
<Form className={classes["form"]}>
|
||||||
<div className={classes["content"]}>
|
<div className={classes["content"]}>
|
||||||
<InputField name="input field" fakeplaceholder="Nom" onChange={this.onChangeNameInput} />
|
<InputField name="input field" fakeplaceholder="Nom" onChange={this.onChangeNameInput} defaultValue={this.props.client?.first_name}/>
|
||||||
<InputField name="input field" fakeplaceholder="Prénom" onChange={this.onChangeFirstNameInput} />
|
<InputField name="input field" fakeplaceholder="Prénom" onChange={this.onChangeFirstNameInput} defaultValue={this.props.client?.last_name}/>
|
||||||
<InputField name="input field" fakeplaceholder="E-mail" isEmail onChange={this.onChangeEmailInput} />
|
<InputField name="input field" fakeplaceholder="E-mail" isEmail onChange={this.onChangeEmailInput} defaultValue={this.props.client?.email}/>
|
||||||
<InputField
|
<InputField
|
||||||
name="input field"
|
name="input field"
|
||||||
fakeplaceholder="Numéro de téléphone"
|
fakeplaceholder="Numéro de téléphone"
|
||||||
isPositiveNumber
|
isPositiveNumber
|
||||||
onChange={this.onChangePhoneNumberInput}
|
onChange={this.onChangePhoneNumberInput}
|
||||||
|
defaultValue={this.props.client?.phone_number}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={classes["button-container"]}>
|
<div className={classes["button-container"]}>
|
||||||
{!this.doesInputsHaveValues() ? (
|
{!this.doesInputsHaveValues() ? (
|
||||||
<Link href={backwardPath} className={classes["cancel-button"]}>
|
<Link href={this.backwardPath} className={classes["cancel-button"]}>
|
||||||
<Button variant={EButtonVariant.GHOST}>Annuler</Button>
|
<Button variant={EButtonVariant.GHOST}>Annuler</Button>
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
@ -89,13 +101,18 @@ class UpdateClientClass extends BasePage<IProps, IState> {
|
|||||||
header={"Êtes-vous sur de vouloir quitter sans enregistrer ?"}
|
header={"Êtes-vous sur de vouloir quitter sans enregistrer ?"}
|
||||||
cancelText={"Annuler"}
|
cancelText={"Annuler"}
|
||||||
confirmText={"Quitter"}
|
confirmText={"Quitter"}
|
||||||
cancelPath={backwardPath}>
|
onAccept={this.leavePage}>
|
||||||
Si vous quittez, toutes les modifications que vous avez effectuées ne seront pas enregistrées.{" "}
|
Si vous quittez, toutes les modifications que vous avez effectuées ne seront pas enregistrées.{" "}
|
||||||
</Confirm>
|
</Confirm>
|
||||||
</div>
|
</div>
|
||||||
</DefaultNotaryDashboard>
|
</DefaultNotaryDashboard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private leavePage() {
|
||||||
|
this.props.router.push(this.backwardPath);
|
||||||
|
}
|
||||||
|
|
||||||
private openLeavingModal(): void {
|
private openLeavingModal(): void {
|
||||||
this.setState({ isOpenLeavingModal: true });
|
this.setState({ isOpenLeavingModal: true });
|
||||||
}
|
}
|
||||||
@ -132,9 +149,15 @@ class UpdateClientClass extends BasePage<IProps, IState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function UpdateClient() {
|
export default function UpdateClient(props: IProps) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
let { folderUid } = router.query;
|
let { folderUid, clientUid } = router.query;
|
||||||
folderUid = folderUid as string;
|
folderUid = folderUid as string;
|
||||||
return <UpdateClientClass selectedFolderUid={folderUid} />;
|
|
||||||
|
let client = null;
|
||||||
|
const folder = folders.find((folder) => folder.uid === folderUid) ?? null;
|
||||||
|
if (folder && folder.office_folder_has_customers) {
|
||||||
|
client = folder.office_folder_has_customers.find((client) => client.customer.contact.uid === clientUid) ?? null;
|
||||||
|
}
|
||||||
|
return <UpdateClientClass {...props} router={router} selectedFolderUid={folderUid} client={client?.customer.contact ?? null} />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user