Merge branch 'dev' of https://github.com/smart-chain-fr/leCoffre-front into dev
This commit is contained in:
commit
78ec354c9c
@ -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<Customer[]> {
|
||||
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<Customer> {
|
||||
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||
try {
|
||||
return await this.getRequest<Customer>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Get a folder by uid
|
||||
*/
|
||||
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||
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<Customer>(url);
|
||||
} catch (err) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<IProps, IState> {
|
||||
private rootRef = React.createRef<HTMLDivElement>();
|
||||
private removeOnresize = () => {};
|
||||
|
||||
static defaultProps = {
|
||||
disabled: false,
|
||||
};
|
||||
|
||||
constructor(props: IProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@ -50,7 +55,10 @@ export default class Select extends React.Component<IProps, IState> {
|
||||
public override render(): JSX.Element {
|
||||
const selectedOption = this.state.selectedOption ?? this.props.selectedOption;
|
||||
return (
|
||||
<div className={classNames(classes["root"], this.props.className)} ref={this.rootRef}>
|
||||
<div
|
||||
className={classNames(classes["root"], this.props.className)}
|
||||
ref={this.rootRef}
|
||||
data-disabled={this.props.disabled.toString()}>
|
||||
{selectedOption && <input type="text" defaultValue={selectedOption.value as string} name={this.props.name} hidden />}
|
||||
<label
|
||||
className={classNames(classes["container-label"])}
|
||||
@ -126,6 +134,7 @@ export default class Select extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
private toggle(e: FormEvent) {
|
||||
if (this.props.disabled) return;
|
||||
e.preventDefault();
|
||||
let listHeight = 0;
|
||||
let listWidth = this.rootRef.current?.scrollWidth ?? 0;
|
||||
@ -140,6 +149,7 @@ export default class Select extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
private onSelect(option: IOption, e: React.MouseEvent<HTMLLIElement, MouseEvent>) {
|
||||
if (this.props.disabled) return;
|
||||
this.props.onChange && this.props.onChange(option);
|
||||
this.setState({
|
||||
selectedOption: option,
|
||||
|
@ -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<IPropsClass, IState> {
|
||||
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<IPropsClass, IState> {
|
||||
<BackArrow url={this.backwardPath} />
|
||||
</div>
|
||||
<Typography typo={ITypo.H1Bis}>Modifier les informations du client</Typography>
|
||||
<Form className={classes["form"]}>
|
||||
<Form className={classes["form"]} onSubmit={this.onFormSubmit}>
|
||||
<div className={classes["content"]}>
|
||||
<InputField name="input field" fakeplaceholder="Nom" onChange={this.onChangeNameInput} defaultValue={this.state.customer?.contact.first_name}/>
|
||||
<InputField name="input field" fakeplaceholder="Prénom" onChange={this.onChangeFirstNameInput} defaultValue={this.state.customer?.contact.last_name}/>
|
||||
<InputField name="input field" fakeplaceholder="E-mail" isEmail onChange={this.onChangeEmailInput} defaultValue={this.state.customer?.contact.email}/>
|
||||
<InputField
|
||||
name="input field"
|
||||
name="first_name"
|
||||
fakeplaceholder="Nom"
|
||||
onChange={this.onChangeNameInput}
|
||||
defaultValue={this.state.customer?.contact.first_name}
|
||||
/>
|
||||
<InputField
|
||||
name="last_name"
|
||||
fakeplaceholder="Prénom"
|
||||
onChange={this.onChangeFirstNameInput}
|
||||
defaultValue={this.state.customer?.contact.last_name}
|
||||
/>
|
||||
<InputField
|
||||
name="email"
|
||||
fakeplaceholder="E-mail"
|
||||
isEmail
|
||||
onChange={this.onChangeEmailInput}
|
||||
defaultValue={this.state.customer?.contact.email}
|
||||
/>
|
||||
<InputField
|
||||
name="phone_number"
|
||||
fakeplaceholder="Numéro de téléphone"
|
||||
isPositiveNumber
|
||||
onChange={this.onChangePhoneNumberInput}
|
||||
@ -91,10 +106,11 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
/>
|
||||
<InputField
|
||||
name="birthdate"
|
||||
type="date"
|
||||
type="text"
|
||||
fakeplaceholder="Date de naissance"
|
||||
required={false}
|
||||
onChange={this.onChangeBirthDateInput}
|
||||
defaultValue={this.state.customer?.contact.birthdate?.toString() ?? ""}
|
||||
/>
|
||||
<InputField
|
||||
name="address"
|
||||
@ -102,6 +118,7 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
fakeplaceholder="Adresse"
|
||||
required={false}
|
||||
onChange={this.onChangeAddressInput}
|
||||
defaultValue={this.state.customer?.contact.address?.address ?? ""}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -134,8 +151,46 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
}
|
||||
|
||||
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<HTMLFormElement> | 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() {
|
||||
|
@ -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<IPropsClass, IState> {
|
||||
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 (
|
||||
<DefaultNotaryDashboard title={"Ajouter client(s)"} onSelectedFolder={this.onSelectedFolder}>
|
||||
<div className={classes["root"]}>
|
||||
@ -55,6 +61,12 @@ class UpdateFolderMetadataClass extends BasePage<IPropsClass, IState> {
|
||||
fakeplaceholder="Numéro de dossier"
|
||||
defaultValue={this.state.selectedFolder?.folder_number}
|
||||
/>
|
||||
<Select options={[]} placeholder={"Type d'acte"} selectedOption={deedOption} disabled />
|
||||
<InputField
|
||||
fakeplaceholder="Ouverture du dossier"
|
||||
defaultValue={openingDate.toLocaleDateString("fr-FR")}
|
||||
disabled
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={classes["button-container"]}>
|
||||
@ -73,21 +85,23 @@ class UpdateFolderMetadataClass extends BasePage<IPropsClass, IState> {
|
||||
const folder = await this.getFolder();
|
||||
this.setState({
|
||||
selectedFolder: folder,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
private async onFormSubmit(
|
||||
e: React.FormEvent<HTMLFormElement> | null,
|
||||
values: {
|
||||
[key: string]: string;
|
||||
}
|
||||
},
|
||||
) {
|
||||
try {
|
||||
await Folders.getInstance().put(this.props.folderUid, values);
|
||||
const url = Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid);
|
||||
const url = Module.getInstance()
|
||||
.get()
|
||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folderUid);
|
||||
this.props.router.push(url);
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<IProps, IState> {
|
||||
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 (
|
||||
<DefaultNotaryDashboard title={"Ajouter client(s)"} onSelectedFolder={this.onSelectedFolder}>
|
||||
<div className={classes["root"]}>
|
||||
<div className={classes["back-arrow"]}>
|
||||
<BackArrow url={backwardPath} />
|
||||
</div>
|
||||
<Typography typo={ITypo.H1Bis}>Modifier la note du dossier</Typography>
|
||||
|
||||
<Form className={classes["form"]}>
|
||||
<div className={classes["content"]}>
|
||||
<InputField name="input field" fakeplaceholder="Note du dossier" textarea />
|
||||
</div>
|
||||
|
||||
<div className={classes["button-container"]}>
|
||||
<Link href={backwardPath} className={classes["cancel-button"]}>
|
||||
<Button variant={EButtonVariant.GHOST}>Annuler</Button>
|
||||
</Link>
|
||||
<Button type="submit">Enregistrer</Button>
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
</DefaultNotaryDashboard>
|
||||
);
|
||||
}
|
||||
|
||||
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 <UpdateFolderDescriptionClass selectedFolderUid={folderUid} />;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user