🎨 fixing build
This commit is contained in:
parent
9000820089
commit
4e4fc97ae5
4
package-lock.json
generated
4
package-lock.json
generated
@ -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.27",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.35",
|
||||
"next": "13.2.4",
|
||||
"prettier": "^2.8.7",
|
||||
"react": "18.2.0",
|
||||
@ -3166,7 +3166,7 @@
|
||||
}
|
||||
},
|
||||
"node_modules/le-coffre-resources": {
|
||||
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#84a49150d7e6e2856aa7e6f9337d603487b89594",
|
||||
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#5052051e1d3f56b8f895f7132090c77ff7bdd6bc",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"class-transformer": "^0.5.1",
|
||||
|
@ -21,7 +21,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.27",
|
||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.35",
|
||||
"next": "13.2.4",
|
||||
"prettier": "^2.8.7",
|
||||
"react": "18.2.0",
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Customer } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { Contact, Customer } from "le-coffre-resources/dist/SuperAdmin";
|
||||
import { Service } from "typedi";
|
||||
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
import { ECivility } from "le-coffre-resources/dist/Customer/Contact";
|
||||
|
||||
// TODO Type get query params -> Where + inclue + orderby
|
||||
export interface IGetCustomersparams {
|
||||
@ -16,6 +17,15 @@ export type IPutCustomersParams = {
|
||||
contact?: Customer["contact"];
|
||||
};
|
||||
|
||||
export interface IPostCustomersParams {
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
email: string;
|
||||
cell_phone_number: string;
|
||||
civility: ECivility;
|
||||
address?: Contact["address"];
|
||||
}
|
||||
|
||||
@Service()
|
||||
export default class Customers extends BaseSuperAdmin {
|
||||
private static instance: Customers;
|
||||
@ -44,6 +54,20 @@ export default class Customers extends BaseSuperAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create a Customer
|
||||
*/
|
||||
public async post(body: any): Promise<Customer> {
|
||||
const url = new URL(this.baseURl);
|
||||
console.log(body);
|
||||
try {
|
||||
return await this.postRequest<Customer>(url, body);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getByUid(uid: string, q?: any): Promise<Customer> {
|
||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||
const query = { q };
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Service } from "typedi";
|
||||
import User, { DeedType, Office, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import User, { Customer, DeedType, Office, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import BaseSuperAdmin from "../BaseSuperAdmin";
|
||||
import { EFolderStatus } from "le-coffre-resources/dist/Customer/OfficeFolder";
|
||||
|
||||
@ -39,6 +39,7 @@ export type IPutFoldersParams = {
|
||||
archived_description?: OfficeFolder["archived_description"];
|
||||
status?: OfficeFolder["status"];
|
||||
office_folder_has_stakeholder?: OfficeFolder["office_folder_has_stakeholder"];
|
||||
OfficeFolderHasCustomer?: { customer: { uid: Customer["uid"] } }[];
|
||||
};
|
||||
|
||||
@Service()
|
||||
|
@ -65,7 +65,7 @@ class DocumentNotaryClass extends React.Component<IPropsClass, IState> {
|
||||
|
||||
private onClick() {
|
||||
if (this.props.document.document_status !== "VALIDATED" && this.props.document.document_status !== "PENDING") return;
|
||||
this.props.router.push(`/folders/${this.props.document.folder.uid}/documents/${this.props.document.uid}`);
|
||||
this.props.router.push(`/folders/${this.props.document.folder?.uid}/documents/${this.props.document.uid}`);
|
||||
}
|
||||
|
||||
private renderIcon(): JSX.Element {
|
||||
|
@ -71,7 +71,7 @@ export default function FolderBoxInformation(props: IProps) {
|
||||
</div>
|
||||
<div className={classes["text-container"]}>
|
||||
<Typography typo={ITypo.NAV_INPUT_16}>Type d'acte</Typography>
|
||||
<Typography typo={ITypo.P_18}>{folder.deed.deed_type.name ?? ""}</Typography>
|
||||
<Typography typo={ITypo.P_18}>{folder.deed?.deed_type?.name ?? ""}</Typography>
|
||||
</div>
|
||||
<div className={classes["text-container"]}>
|
||||
<Typography typo={ITypo.NAV_INPUT_16}>Ouverture du dossier</Typography>
|
||||
|
@ -60,9 +60,11 @@ export default class SearchBar extends React.Component<IProps, IState> {
|
||||
const value = event.target.value.toLowerCase();
|
||||
|
||||
if (folder.office_folder_has_customers) {
|
||||
const customerNames = folder.office_folder_has_customers.map((customer) => {
|
||||
return `${customer.customer.contact.first_name.toLowerCase()} ${customer.customer.contact.last_name.toLowerCase()}`;
|
||||
}).join(", ");
|
||||
const customerNames = folder.office_folder_has_customers
|
||||
.map((customer) => {
|
||||
return `${customer.customer.contact?.first_name.toLowerCase()} ${customer.customer.contact?.last_name.toLowerCase()}`;
|
||||
})
|
||||
.join(", ");
|
||||
return name.includes(value) || number.includes(value) || customerNames.includes(value);
|
||||
}
|
||||
|
||||
|
@ -11,16 +11,17 @@
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.radiobox-container {
|
||||
margin: 32px 0;
|
||||
|
||||
> :not(:last-child) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.form {
|
||||
width: 100%;
|
||||
|
||||
.radiobox-container {
|
||||
margin: 32px 0;
|
||||
|
||||
> :not(:last-child) {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.button-container {
|
||||
width: 100%;
|
||||
|
@ -7,25 +7,32 @@ 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 { useRouter } from "next/router";
|
||||
import { NextRouter, useRouter } from "next/router";
|
||||
import { ActionMeta, MultiValue } from "react-select";
|
||||
|
||||
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 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 = {
|
||||
selectedFolderUid: string;
|
||||
};
|
||||
type IProps = {};
|
||||
type IState = {
|
||||
selectedFolder: IDashBoardFolder | null;
|
||||
isExistingClientSelected: boolean;
|
||||
isNewClientSelected: boolean;
|
||||
hasNewClientSelected: boolean;
|
||||
};
|
||||
class AddClientToFolderClass extends BasePage<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
|
||||
type IPropsClass = IProps & {
|
||||
selectedFolderUid: string;
|
||||
router: NextRouter;
|
||||
};
|
||||
class AddClientToFolderClass extends BasePage<IPropsClass, IState> {
|
||||
constructor(props: IPropsClass) {
|
||||
super(props);
|
||||
this.state = {
|
||||
selectedFolder: null,
|
||||
@ -37,6 +44,7 @@ class AddClientToFolderClass extends BasePage<IProps, IState> {
|
||||
this.onExistingClientSelected = this.onExistingClientSelected.bind(this);
|
||||
this.onNewClientSelected = this.onNewClientSelected.bind(this);
|
||||
this.onMutiSelectChange = this.onMutiSelectChange.bind(this);
|
||||
this.onFormSubmit = this.onFormSubmit.bind(this);
|
||||
}
|
||||
public override render(): JSX.Element {
|
||||
const selectOptions = [
|
||||
@ -54,24 +62,24 @@ class AddClientToFolderClass extends BasePage<IProps, IState> {
|
||||
<BackArrow url={backwardPath} />
|
||||
</div>
|
||||
<Typography typo={ITypo.H1Bis}>Associer un ou plusieurs client(s)</Typography>
|
||||
<Form className={classes["form"]}>
|
||||
<div className={classes["radiobox-container"]}>
|
||||
<RadioBox
|
||||
name="client"
|
||||
onChange={this.onExistingClientSelected}
|
||||
defaultChecked={this.state.isExistingClientSelected}
|
||||
value={"existing client"}>
|
||||
<Typography typo={ITypo.P_ERR_18}>Client existant</Typography>
|
||||
</RadioBox>
|
||||
<RadioBox
|
||||
name="client"
|
||||
onChange={this.onNewClientSelected}
|
||||
defaultChecked={this.state.isNewClientSelected}
|
||||
value={"new client"}>
|
||||
<Typography typo={ITypo.P_ERR_18}>Nouveau client</Typography>
|
||||
</RadioBox>
|
||||
</div>
|
||||
<div className={classes["radiobox-container"]}>
|
||||
<RadioBox
|
||||
name="client"
|
||||
onChange={this.onExistingClientSelected}
|
||||
defaultChecked={this.state.isExistingClientSelected}
|
||||
value={"existing client"}>
|
||||
<Typography typo={ITypo.P_ERR_18}>Client existant</Typography>
|
||||
</RadioBox>
|
||||
<RadioBox
|
||||
name="client"
|
||||
onChange={this.onNewClientSelected}
|
||||
defaultChecked={this.state.isNewClientSelected}
|
||||
value={"new client"}>
|
||||
<Typography typo={ITypo.P_ERR_18}>Nouveau client</Typography>
|
||||
</RadioBox>
|
||||
</div>
|
||||
|
||||
<Form className={classes["form"]} onSubmit={this.onFormSubmit}>
|
||||
{this.state.isExistingClientSelected && (
|
||||
<div className={classes["existing-client"]}>
|
||||
<MultiSelect options={selectOptions} placeholder="Client" onChange={this.onMutiSelectChange} />
|
||||
@ -88,10 +96,10 @@ class AddClientToFolderClass extends BasePage<IProps, IState> {
|
||||
|
||||
{this.state.isNewClientSelected && (
|
||||
<div className={classes["new-client"]}>
|
||||
<InputField name="input field" fakeplaceholder="Nom" />
|
||||
<InputField name="input field" fakeplaceholder="Prénom" />
|
||||
<InputField name="input field" fakeplaceholder="E-mail" isEmail />
|
||||
<InputField name="input field" fakeplaceholder="Numéro de téléphone" numbersOnly maxLength={10} />
|
||||
<InputField name="last_name" fakeplaceholder="Nom" />
|
||||
<InputField name="first_name" fakeplaceholder="Prénom" />
|
||||
<InputField name="email" fakeplaceholder="E-mail" isEmail />
|
||||
<InputField name="cell_phone_number" fakeplaceholder="Numéro de téléphone" numbersOnly maxLength={10} />
|
||||
<div className={classes["button-container"]}>
|
||||
<Link href={backwardPath} className={classes["cancel-button"]}>
|
||||
<Button variant={EButtonVariant.GHOST}>Annuler</Button>
|
||||
@ -125,11 +133,36 @@ class AddClientToFolderClass extends BasePage<IProps, IState> {
|
||||
private onNewClientSelected(): void {
|
||||
this.setState({ isExistingClientSelected: false, isNewClientSelected: true });
|
||||
}
|
||||
|
||||
private async onFormSubmit(
|
||||
e: React.FormEvent<HTMLFormElement> | null,
|
||||
values: {
|
||||
[key: string]: any;
|
||||
},
|
||||
) {
|
||||
values["civility"] = ECivility.MALE;
|
||||
const customer = {
|
||||
contact: values,
|
||||
};
|
||||
console.log(customer);
|
||||
|
||||
console.log("SELECTD >>>", this.props.selectedFolderUid);
|
||||
const newCustomerCreated: Customer = await Customers.getInstance().post(customer);
|
||||
|
||||
if (newCustomerCreated) {
|
||||
const query = {
|
||||
OfficeFolderHasCustomer: [{ customer: { uid: newCustomerCreated.uid } }],
|
||||
};
|
||||
|
||||
await Folders.getInstance().put(this.props.selectedFolderUid, query);
|
||||
this.props.router.push(`/folders/${this.props.selectedFolderUid}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default function AddClientToFolder() {
|
||||
export default function AddClientToFolder(props: IProps) {
|
||||
const router = useRouter();
|
||||
let { folderUid } = router.query;
|
||||
folderUid = folderUid as string;
|
||||
return <AddClientToFolderClass selectedFolderUid={folderUid} />;
|
||||
return <AddClientToFolderClass {...props} selectedFolderUid={folderUid} router={router} />;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@
|
||||
"AddClient": {
|
||||
"enabled": true,
|
||||
"props": {
|
||||
"path": "/folders/add/clients",
|
||||
"path": "/folders/[folderUid]/add/clients",
|
||||
"labelKey": "add_client_to_folder"
|
||||
}
|
||||
},
|
||||
|
@ -48,7 +48,7 @@
|
||||
"AddClient": {
|
||||
"enabled": true,
|
||||
"props": {
|
||||
"path": "/folders/add/clients",
|
||||
"path": "/folders/[folderUid]/add/clients",
|
||||
"labelKey": "add_client_to_folder"
|
||||
}
|
||||
},
|
||||
|
@ -48,7 +48,7 @@
|
||||
"AddClient": {
|
||||
"enabled": true,
|
||||
"props": {
|
||||
"path": "/folders/add/clients",
|
||||
"path": "/folders/[folderUid]/add/clients",
|
||||
"labelKey": "add_client_to_folder"
|
||||
}
|
||||
},
|
||||
|
@ -48,7 +48,7 @@
|
||||
"AddClient": {
|
||||
"enabled": true,
|
||||
"props": {
|
||||
"path": "/folders/add/clients",
|
||||
"path": "/folders/[folderUid]/add/clients",
|
||||
"labelKey": "add_client_to_folder"
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user