Merge branch 'feature/front-services' into dev

This commit is contained in:
Maxime Lalo 2023-05-03 12:18:42 +02:00
commit cd06158e83
20 changed files with 424 additions and 100 deletions

View File

@ -0,0 +1,92 @@
import { Service } from "typedi";
import { Deed, DeedType } from "le-coffre-resources/dist/Notary";
import BaseSuperAdmin from "../BaseSuperAdmin";
// TODO Type get query params -> Where + inclue + orderby
export interface IGetDeedTypesParams {
q?: {};
}
// TODO Type getbyuid query params
export type IPutDeedTypesParams = {
uid?: DeedType["uid"];
name?: DeedType["name"];
description?: DeedType["description"];
deed?: DeedType["deed"];
office?: DeedType["office"];
archived_at?: DeedType["archived_at"];
deed_type_has_document_types?: DeedType["deed_type_has_document_types"];
};
@Service()
export default class DeedTypes extends BaseSuperAdmin {
private static instance: DeedTypes;
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
private constructor() {
super();
}
public static getInstance() {
if (!this.instance) {
return new this();
} else {
return this.instance;
}
}
/**
* @description : Get all DeedTypes
*/
public async get(q: IGetDeedTypesParams): Promise<DeedType[]> {
const url = new URL(this.baseURl);
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
try {
return await this.getRequest<DeedType[]>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
/**
* @description : Get a folder by uid
*/
public async getByUid(uid: string, q?: any): Promise<DeedType> {
const url = new URL(this.baseURl.concat(`/${uid}`));
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
try {
return await this.getRequest<DeedType>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
/**
* @description : Create a deed
*/
// public async post(body: IPostDeedTypesParams): Promise<OfficeFolder> {
// const url = new URL(this.baseURl);
// try {
// return await this.postRequest<OfficeFolder>(url, body);
// } catch (err) {
// this.onError(err);
// return Promise.reject(err);
// }
// }
/**
* @description : Update the folder description
*/
public async put(uid: string, body: IPutDeedTypesParams): Promise<DeedType> {
const url = new URL(this.baseURl.concat(`/${uid}`));
try {
return await this.putRequest<DeedType>(url, body);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
}

View File

@ -0,0 +1,91 @@
import { Service } from "typedi";
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
import BaseSuperAdmin from "../BaseSuperAdmin";
// TODO Type get query params -> Where + inclue + orderby
export interface IGetDeedsParams {
q?: {};
}
// TODO Type getbyuid query params
export type IPutDeedsParams = {
uid?: OfficeFolder["uid"];
folder_number?: OfficeFolder["folder_number"];
name?: OfficeFolder["name"];
description?: OfficeFolder["description"];
archived_description?: OfficeFolder["archived_description"];
status?: OfficeFolder["status"];
};
@Service()
export default class Deeds extends BaseSuperAdmin {
private static instance: Deeds;
private readonly baseURl = this.namespaceUrl.concat("/deeds");
private constructor() {
super();
}
public static getInstance() {
if (!this.instance) {
return new this();
} else {
return this.instance;
}
}
/**
* @description : Get all deeds
*/
public async get(q: IGetDeedsParams): Promise<Deed[]> {
const url = new URL(this.baseURl);
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
try {
return await this.getRequest<Deed[]>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
/**
* @description : Get a folder by uid
*/
public async getByUid(uid: string, q?: any): Promise<Deed> {
const url = new URL(this.baseURl.concat(`/${uid}`));
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
try {
return await this.getRequest<Deed>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
/**
* @description : Create a deed
*/
// public async post(body: IPostDeedsParams): Promise<OfficeFolder> {
// const url = new URL(this.baseURl);
// try {
// return await this.postRequest<OfficeFolder>(url, body);
// } catch (err) {
// this.onError(err);
// return Promise.reject(err);
// }
// }
/**
* @description : Update the folder description
*/
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
const url = new URL(this.baseURl.concat(`/${uid}`));
try {
return await this.putRequest<Deed>(url, body);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
}

View File

@ -11,7 +11,19 @@ export interface IGetFoldersParams {
};
}
// TODO Type getbyuid query params
// TODO Type getbyuid query searchParams
export type IPostFoldersParams = {
folder_number: OfficeFolder["folder_number"];
name: OfficeFolder["name"];
description: OfficeFolder["description"];
archived_description: OfficeFolder["archived_description"];
status: OfficeFolder["status"];
deed: OfficeFolder["deed"];
office: OfficeFolder["office"];
office_folder_has_customers?: OfficeFolder["office_folder_has_customers"];
office_folder_has_stakeholder?: OfficeFolder["office_folder_has_stakeholder"];
documents?: OfficeFolder["documents"];
};
export type IPutFoldersParams = {
uid?: OfficeFolder["uid"];
@ -70,15 +82,15 @@ export default class Folders extends BaseSuperAdmin {
/**
* @description : Create a folder
*/
// public async post(body: IPostFoldersParams): Promise<OfficeFolder> {
// const url = new URL(this.baseURl);
// try {
// return await this.postRequest<OfficeFolder>(url, body);
// } catch (err) {
// this.onError(err);
// return Promise.reject(err);
// }
// }
public async post(body: any): Promise<OfficeFolder> {
const url = new URL(this.baseURl);
try {
return await this.postRequest<OfficeFolder>(url, body);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
/**
* @description : Update the folder description

View File

@ -85,6 +85,7 @@ export default function FolderBoxInformation(props: IProps) {
function formatDate(date: Date | null): string {
if (!date) return "...";
if (!(date instanceof Date)) date = new Date(date);
return date.toLocaleDateString("fr-FR", {
year: "numeric",
month: "long",

View File

@ -28,7 +28,7 @@ class FolderListClass extends React.Component<IPropsClass, IState> {
return (
<div className={classes["root"]}>
{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");
return pendingDocuments.length >= 1 ? -1 : 1;
}).map((folder) => {
return (

View File

@ -1,5 +1,6 @@
import React, { ReactNode } from "react";
import BaseField, { IError, IProps as IBaseFieldProps } from "./Elements/BaseField";
import BaseField, { IProps as IBaseFieldProps, IError } from "./Elements/BaseField";
export type IBaseField = BaseField<IBaseFieldProps>;
@ -90,13 +91,41 @@ export default class Form extends React.Component<IProps, IState> {
if (this.props.onValidated) this.props.onValidated();
const elementsValues = this.getAllChildrenFields(e).reduce(
const allChildren = this.getAllChildrenFields(e);
const elementsValues = allChildren
.filter((e) => {
return e.getAttribute("type") !== "radio" && e.getAttribute("type") !== "checkbox";
})
.reduce((obj, element) => ({ ...obj, [element.getAttribute("name") ?? ""]: (element as any).value }), {});
const radioInputs = allChildren.filter((e) => e.getAttribute("type") === "radio").filter((e) => (e as any).checked);
const radioInputsValues = radioInputs.reduce(
(obj, element) => ({ ...obj, [element.getAttribute("name") ?? ""]: (element as any).value }),
{},
);
const checkBoxesInput = allChildren.filter((e) => e.getAttribute("type") === "checkbox").filter((e) => (e as any).checked);
const checkBoxesValues = checkBoxesInput.reduce((obj, element) => {
const inputName = element.getAttribute("name") ?? "";
const inputValue = (element as any).value as string;
const newValue = (obj as any)[inputName] as string[] ?? [];
newValue.push(inputValue);
return {
...obj,
[inputName]: newValue,
};
}, {});
const allInputs = {
...elementsValues,
...radioInputsValues,
...checkBoxesValues,
};
// Deleting empty input
delete (allInputs as any)[""];
if (this.props.onSubmit) {
this.props.onSubmit(e, elementsValues, this.onSubmitErrorApi);
this.props.onSubmit(e, allInputs, this.onSubmitErrorApi);
}
return { values: elementsValues };

View File

@ -43,7 +43,7 @@ export default class NotificationModal extends React.Component<IProps, IState> {
{Toasts.getInstance().toasts.length === 0 ? (
<div className={classes["missing-notification"]}>
<Typography typo={ITypo.P_18} color={ITypoColor.GREY}>
Vous navez pas de notifications.
Vous n'avez pas de notifications.
</Typography>
</div>
) : (

View File

@ -14,6 +14,7 @@ type IProps = {
hasBorderRightCollapsed?: boolean;
placeholder?: string;
className?: string;
name?: string;
};
export type IOption = {
@ -50,6 +51,7 @@ export default class Select extends React.Component<IProps, IState> {
const selectedOption = this.state.selectedOption ?? this.props.selectedOption;
return (
<div className={classNames(classes["root"], this.props.className)} ref={this.rootRef}>
{selectedOption && <input type="text" defaultValue={selectedOption.value as string} name={this.props.name} hidden />}
<label
className={classNames(classes["container-label"])}
data-open={this.state.isOpen}

View File

@ -6,8 +6,6 @@ import FolderListContainer from "@Front/Components/DesignSystem/FolderListContai
import Header from "@Front/Components/DesignSystem/Header";
import Version from "@Front/Components/DesignSystem/Version";
import BackArrow from "@Front/Components/Elements/BackArrow";
import { folders } from "@Front/Components/Layouts/DesignSystem/dummyData";
import { foldersArchived } from "@Front/Components/Layouts/DesignSystem/dummyData";
import WindowStore from "@Front/Stores/WindowStore";
import classNames from "classnames";
import { OfficeFolder } from "le-coffre-resources/dist/Customer";
@ -15,7 +13,8 @@ import Image from "next/image";
import React, { ReactNode } from "react";
import classes from "./classes.module.scss";
import Folders, { IGetFoldersParams } from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
import { EFolderStatus } from "le-coffre-resources/dist/Customer/OfficeFolder";
type IProps = {
title: string;
@ -42,6 +41,7 @@ export type IDashBoardFolder = {
created_at: OfficeFolder["created_at"];
office_folder_has_customers?: OfficeFolder["office_folder_has_customers"];
archived_description: OfficeFolder["archived_description"];
status: OfficeFolder["status"];
};
export default class DefaultNotaryDashboard extends React.Component<IProps, IState> {
@ -108,18 +108,24 @@ export default class DefaultNotaryDashboard extends React.Component<IProps, ISta
);
}
public override componentDidMount(): void {
public override async componentDidMount() {
this.onWindowResize = WindowStore.getInstance().onResize((window) => this.onResize(window));
/**
* We set folders state according to the isArchived props
* TODO: Front connexion we need to get from bdd
*/
if (this.props.isArchived) {
this.setState({ folders: foldersArchived });
} else {
let targetedStatus: EFolderStatus = EFolderStatus["LIVE" as keyof typeof EFolderStatus];
if (this.props.isArchived) targetedStatus = EFolderStatus.ARCHIVED;
const query: IGetFoldersParams = {
q: {
where: { status: targetedStatus },
include: {
deed: { include: { deed_type: true } },
office: true,
office_folder_has_customers: { include: { customer: { include: { contact: true } } } },
},
},
};
const folders = await Folders.getInstance().get(query);
this.setState({ folders: folders });
}
}
public override componentWillUnmount() {
this.onWindowResize();
}

View File

@ -24,7 +24,6 @@ import Toasts, { IToast } from "@Front/Stores/Toasts";
import classes from "./classes.module.scss";
import { customer2, document, documentDeposited, documentPending, folder, folders, folderWithPendingDocument } from "./dummyData";
type IState = {
isModalDisplayed: boolean;
selectedOption?: IOption;
@ -203,7 +202,7 @@ export default class DesignSystem extends BasePage<IProps, IState> {
<Select
options={selectOptions}
onChange={this.onSelectedOption}
placeholder={"Type dacte"}
placeholder={"Type d'acte"}
selectedOption={this.state.selectedOption}
/>
</div>

View File

@ -66,7 +66,7 @@ export default class AskDocuments extends BasePage<IProps, IState> {
<div className={classes["form-container"]}>
<div className={classes["checkbox-container"]}>
{this.documentsType.map((documentType) => (
<CheckBox toolTip="Checkbox with tooltip" option={documentType} key={documentType.value as string} />
<CheckBox name="documents_type" toolTip="Checkbox with tooltip" option={documentType} key={documentType.value as string} />
))}
</div>
<div className={classes["add-document-container"]}>

View File

@ -14,9 +14,11 @@ import { ActionMeta, MultiValue } from "react-select";
import BasePage from "../../Base";
import classes from "./classes.module.scss";
import { Deed, DeedType, OfficeFolder, OfficeFolderHasStakeholder } from "le-coffre-resources/dist/Notary";
// import DeedTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes";
import DeedTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes";
import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users";
import User from "le-coffre-resources/dist/Notary";
import Folders, { IPostFoldersParams } from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
import { EFolderStatus } from "le-coffre-resources/dist/Customer/OfficeFolder";
type IFormValues = {
folder_number: number;
@ -127,14 +129,18 @@ export default class CreateFolder extends BasePage<IProps, IState> {
}
public override async componentDidMount() {
// const deedTypes = await DeedTypes.getInstance().get({ q: {} });
const deedTypes = await DeedTypes.getInstance().get({ q: {} });
// TODO SETUP userStore and get the user's office membership -> Replace IwJ70M471c by the user's office membership uid
const usersMock = await Users.getInstance().get({ q: { include: { office_membership: true } } });
const userMock = usersMock[0];
// -------------------
const collaborators = await Users.getInstance().get({
q: { where: { office_membership: { uid: "IwJ70M471c" } }, include: { contact: true } },
q: { where: { office_membership: { uid: userMock?.office_membership.uid } }, include: { contact: true } },
});
this.setState({
// deedTypes,
// deedTypesOptions: this.mapDeedOptions(deedTypes),
deedTypes,
deedTypesOptions: this.mapDeedOptions(deedTypes),
collaborators,
collaboratorsOptions: this.mapUsersOptions(collaborators),
});
@ -199,7 +205,7 @@ export default class CreateFolder extends BasePage<IProps, IState> {
});
}
private onFormSubmit(
private async onFormSubmit(
e: React.FormEvent<HTMLFormElement> | null,
values: {
[key: string]: any;
@ -219,16 +225,54 @@ export default class CreateFolder extends BasePage<IProps, IState> {
const deed = Deed.hydrate<Deed>({
deed_type: selectedDeedType,
});
const office_folder_has_customers = collaborators.map((collaborator) => {
let office_folder_has_stakeholders = collaborators.map((collaborator) => {
return OfficeFolderHasStakeholder.hydrate<OfficeFolderHasStakeholder>({
office_folder: new OfficeFolder(),
user_stakeholder: collaborator,
});
});
if (this.state.folder_access === "select_collaborators") {
office_folder_has_stakeholders = office_folder_has_stakeholders.filter((collaborator) => {
return this.state.formValues.collaborators?.some((selectedCollaborator) => {
return selectedCollaborator.value === collaborator.user_stakeholder.uid;
});
});
}
const usersMock = await Users.getInstance().get({ q: { include: { office_membership: true } } });
const userMock = usersMock[0];
values["deed"] = deed;
values["office_folder_has_customers"] = office_folder_has_customers;
console.log(values);
values["archived_description"] = "";
values["status"] = EFolderStatus.LIVE;
values["office"] = userMock?.office_membership;
values["office_folder_has_stakeholder"] = values["office_folder_has_stakeholders"] = office_folder_has_stakeholders;
const newobject = {
folder_number: "12312",
name: "Mon folder",
description: "dazdazf",
deed: {
deed_type: {
uid: "neNTaiiNVp",
},
},
office: {
uid: "R34T9DZ5ov",
},
office_folder_has_stakeholder: [
{
user_stakeholder: {
uid: "WYBnSyguqP",
},
},
],
};
console.log(newobject);
const created = await Folders.getInstance().post(newobject as any);
console.log(">>> ", created);
}
private isFormSubmittable(): boolean {

View File

@ -33,7 +33,7 @@ export default class ClientSection extends React.Component<IProps, IState> {
<div className={classes["no-client"]}>
<div className={classes["title"]}>
<Typography typo={ITypo.P_18} color={ITypoColor.GREY}>
Aucun client nest associé au dossier.
Aucun client n'est associé au dossier.
</Typography>
</div>
<Link href={navigatePath}>
@ -57,6 +57,7 @@ export default class ClientSection extends React.Component<IProps, IState> {
}
private doesFolderHaveCustomer(): boolean {
return this.props.folder.office_folder_has_customers !== undefined;
if (!this.props.folder?.office_folder_has_customers) return false;
return this.props.folder?.office_folder_has_customers!.length > 0;
}
}

View File

@ -7,20 +7,21 @@ import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField"
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
import QuantityProgressBar from "@Front/Components/DesignSystem/QuantityProgressBar";
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
import { folders } from "@Front/Components/Layouts/DesignSystem/dummyData";
import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
import Module from "@Front/Config/Module";
import Link from "next/link";
import { useRouter } from "next/router";
import { NextRouter, useRouter } from "next/router";
import BasePage from "../../Base";
import classes from "./classes.module.scss";
import ClientSection from "./ClientSection";
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
import { OfficeFolder } from "le-coffre-resources/dist/Customer";
type IProps = {};
type IPropsClass = IProps & {
router: NextRouter;
selectedFolderUid: string;
};
@ -38,6 +39,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.onSelectedFolder = this.onSelectedFolder.bind(this);
this.openArchivedModal = this.openArchivedModal.bind(this);
this.closeArchivedModal = this.closeArchivedModal.bind(this);
this.onArchivedModalAccepted = this.onArchivedModalAccepted.bind(this);
this.getCompletionNumber = this.getCompletionNumber.bind(this);
}
@ -87,6 +89,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
</div>
<Confirm
isOpen={this.state.isArchivedModalOpen}
onAccept={this.onArchivedModalAccepted}
onClose={this.closeArchivedModal}
closeBtn
header={"Archiver le dossier ?"}
@ -113,12 +116,9 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
);
}
public override async componentDidMount() {
for (const folder of folders) {
if (folder.uid === this.props.selectedFolderUid) {
this.setState({ selectedFolder: folder });
break;
}
}
this.setState({
selectedFolder: await this.getFolder(),
});
}
private getCompletionNumber(){
@ -132,7 +132,8 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
}
private doesFolderHaveCustomer(): boolean {
return this.state.selectedFolder?.office_folder_has_customers !== undefined;
if (!this.state.selectedFolder?.office_folder_has_customers) return false;
return this.state.selectedFolder?.office_folder_has_customers!.length > 0;
}
private onSelectedFolder(folder: IDashBoardFolder): void {
@ -146,11 +147,30 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
private closeArchivedModal(): void {
this.setState({ isArchivedModalOpen: false });
}
private async onArchivedModalAccepted() {
if (!this.state.selectedFolder) return;
await Folders.getInstance().archive(this.state.selectedFolder.uid, this.state.selectedFolder);
this.closeArchivedModal();
this.props.router.push(Module.getInstance().get().modules.pages.Folder.props.path);
}
private async getFolder(): Promise<OfficeFolder> {
const query = {
q: {
deed: { include: { deed_type: true } },
office: true,
office_folder_has_customers: { include: { customer: { include: { contact: true } } } },
},
};
const folder = await Folders.getInstance().getByUid(this.props.selectedFolderUid, query);
return folder;
}
}
export default function FolderInformation(props: IProps) {
const router = useRouter();
let { folderUid } = router.query;
folderUid = folderUid as string;
return <FolderInformationClass {...props} selectedFolderUid={folderUid} />;
return <FolderInformationClass {...props} selectedFolderUid={folderUid} router={router} />;
}

View File

@ -54,7 +54,7 @@ class UpdateFolderCollaboratorsClass extends BasePage<IPropsClass, IState> {
<Form className={classes["form"]}>
<div className={classes["content"]}>
<RadioBox name="office" value={ERadioBoxValue.ALL} defaultChecked onChange={this.onSelectedOptionAllOffice}>
Tout loffice
Tout l'office
</RadioBox>
<RadioBox name="office" value={ERadioBoxValue.SELECTION} onChange={this.onSelectedOptionSpecific}>
Sélectionner des collaborateurs

View File

@ -1,33 +1,40 @@
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 { folders } from "@Front/Components/Layouts/DesignSystem/dummyData";
import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
import Module from "@Front/Config/Module";
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
import Link from "next/link";
import { useRouter } from "next/router";
import BasePage from "../../Base";
import classes from "./classes.module.scss";
type IProps = {
folder: IDashBoardFolder | null;
import "reflect-metadata";
type IProps = {};
type IPropsClass = IProps & {
folderUid: string;
};
type IState = {
selectedFolder: IDashBoardFolder | null;
selectedOption?: IOption;
};
class UpdateFolderMetadataClass extends BasePage<IProps, IState> {
constructor(props: IProps) {
class UpdateFolderMetadataClass extends BasePage<IPropsClass, IState> {
constructor(props: IPropsClass) {
super(props);
this.state = {
selectedFolder: null,
};
this.onSelectedFolder = this.onSelectedFolder.bind(this);
this.onSelectedOption = this.onSelectedOption.bind(this);
this.getFolder = this.getFolder.bind(this);
}
public override render(): JSX.Element {
const selectOptions = [
@ -37,7 +44,7 @@ class UpdateFolderMetadataClass extends BasePage<IProps, IState> {
];
const backwardPath = Module.getInstance()
.get()
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.props.folder?.uid!);
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", this.state.selectedFolder?.uid!);
return (
<DefaultNotaryDashboard title={"Ajouter client(s)"} onSelectedFolder={this.onSelectedFolder}>
<div className={classes["root"]}>
@ -48,23 +55,24 @@ class UpdateFolderMetadataClass extends BasePage<IProps, IState> {
<Form className={classes["form"]}>
<div className={classes["content"]}>
<InputField name="input field" fakeplaceholder="Intitulé du dossier" defaultValue={this.props.folder?.name} />
<InputField name="input field" fakeplaceholder="Intitulé du dossier" defaultValue={this.state.selectedFolder?.name} />
<InputField
name="input field"
fakeplaceholder="Numéro de dossier"
defaultValue={this.props.folder?.folder_number}
defaultValue={this.state.selectedFolder?.folder_number}
/>
<Select
options={selectOptions}
onChange={this.onSelectedOption}
placeholder={"Type dacte"}
placeholder={"Type d'acte"}
selectedOption={this.state.selectedOption}
/>
<InputField
{/* <InputField
name="input field"
type="date"
fakeplaceholder="Ouverture du dossier"
defaultValue={formatDate(this.props.folder?.created_at!)}
/>
defaultValue={this.state.selectedFolder?.created_at?.toString() as string}
/> */}
</div>
<div className={classes["button-container"]}>
@ -79,13 +87,27 @@ class UpdateFolderMetadataClass extends BasePage<IProps, IState> {
);
}
public override componentDidMount(): void {
public override async componentDidMount() {
const folder = await this.getFolder();
this.setState({
selectedFolder: folder,
selectedOption: {
label: this.props.folder?.deed.deed_type?.name ?? "",
value: this.props.folder?.deed.deed_type?.uid ?? "",
label: folder?.deed.deed_type?.name ?? "",
value: folder?.deed.deed_type?.uid ?? "",
},
});
})
}
private async getFolder(): Promise<OfficeFolder> {
const query = {
q: {
deed: { include: { deed_type: true } },
office: true,
office_folder_has_customers: { include: { customer: { include: { contact: true } } } },
},
};
const folder = await Folders.getInstance().getByUid(this.props.folderUid, query);
return folder;
}
private onSelectedOption(option: IOption) {
@ -99,19 +121,9 @@ class UpdateFolderMetadataClass extends BasePage<IProps, IState> {
}
}
export default function UpdateFolderMetadata() {
export default function UpdateFolderMetadata(props: IProps) {
const router = useRouter();
let { folderUid } = router.query;
folderUid = folderUid as string;
const folder = folders.find((folder) => folder.uid === folderUid) ?? null;
return <UpdateFolderMetadataClass folder={folder} />;
}
function formatDate(date: Date | null): string {
if (!date) return "...";
return date.toLocaleDateString("fr-FR", {
year: "numeric",
month: "long",
day: "numeric",
});
return <UpdateFolderMetadataClass folderUid={folderUid} />;
}

View File

@ -5,17 +5,20 @@ import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
import FolderBoxInformation, { EFolderBoxInformationType } from "@Front/Components/DesignSystem/FolderBoxInformation";
import QuantityProgressBar from "@Front/Components/DesignSystem/QuantityProgressBar";
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
import { folders } from "@Front/Components/Layouts/DesignSystem/dummyData";
import DefaultNotaryDashboard, { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
import { useRouter } from "next/router";
import { NextRouter, useRouter } from "next/router";
import BasePage from "../../Base";
import classes from "./classes.module.scss";
import ClientSection from "./ClientSection";
import { OfficeFolder } from "le-coffre-resources/dist/Customer";
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
import Module from "@Front/Config/Module";
type IProps = {};
type IPropsClass = IProps & {
router: NextRouter;
selectedFolderUid: string;
};
@ -33,6 +36,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.onSelectedFolder = this.onSelectedFolder.bind(this);
this.openArchivedModal = this.openArchivedModal.bind(this);
this.closeArchivedModal = this.closeArchivedModal.bind(this);
this.restoreFolder = this.restoreFolder.bind(this);
}
// TODO: Message if the user has not created any folder yet
@ -101,13 +105,8 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
);
}
public override async componentDidMount() {
// TODO : GET Current folder from the api
for (const folder of folders) {
if (folder.uid === this.props.selectedFolderUid) {
const folder = await this.getFolder();
this.setState({ selectedFolder: folder });
break;
}
}
}
private doesFolderHaveCustomer(): boolean {
@ -118,8 +117,12 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.setState({ selectedFolder: folder });
}
private restoreFolder() {}
// should call the api to restore the folder
private async restoreFolder() {
if (!this.state.selectedFolder) return;
await Folders.getInstance().restore(this.state.selectedFolder.uid, this.state.selectedFolder);
this.props.router.push(Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.props.path);
}
private openArchivedModal(): void {
this.setState({ isArchivedModalOpen: true });
}
@ -127,11 +130,23 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
private closeArchivedModal(): void {
this.setState({ isArchivedModalOpen: false });
}
private async getFolder(): Promise<OfficeFolder> {
const query = {
q: {
deed: { include: { deed_type: "true" } },
office: "true",
office_folder_has_customers: { include: { customer: { include: { contact: true } } } },
},
};
const folder = await Folders.getInstance().getByUid(this.props.selectedFolderUid, query);
return folder;
}
}
export default function FolderInformation(props: IProps) {
const router = useRouter();
let { folderUid } = router.query;
folderUid = folderUid as string;
return <FolderInformationClass {...props} selectedFolderUid={folderUid} />;
return <FolderInformationClass {...props} selectedFolderUid={folderUid} router={router} />;
}

View File

@ -52,7 +52,7 @@ class UpdateFolderMetadataClass extends BasePage<IProps, IState> {
<Select
options={selectOptions}
onChange={this.onSelectedOption}
placeholder={"Type dacte"}
placeholder={"Type d'acte"}
selectedOption={this.state.selectedOption}
/>
<InputField name="input field" fakeplaceholder="Ouverture du dossier" />

View File

@ -17,11 +17,11 @@ export default class LoginClass extends BasePage {
<Typography typo={ITypo.H1}>
<div className={classes["title"]}>Connexion espace professionnel</div>
</Typography>
<Button onClick={this.redirectUserOnConnection}>Sidentifier avec ID.not</Button>
<Button onClick={this.redirectUserOnConnection}>S'identifier avec ID.not</Button>
<Typography typo={ITypo.P_18}>
<div className={classes["forget-password"]}>Vous narrivez pas à vous connecter ?</div>
<div className={classes["forget-password"]}>Vous n'arrivez pas à vous connecter ?</div>
</Typography>
<Button variant={EButtonVariant.LINE}>Contacter ladministrateur</Button>
<Button variant={EButtonVariant.LINE}>Contacter l'administrateur</Button>
</div>
</DefaultDoubleSidePage>
);

View File

@ -32,11 +32,11 @@ type IPropsClass = {};
// <Loader />
// <Typography typo={ITypo.P_18}>
// <div className={classes["forget-password"]}>
// Vous narrivez pas à vous connecter ?
// Vous n'arrivez pas à vous connecter ?
// </div>
// </Typography>
// <Button variant={EButtonVariant.LINE}>
// Contacter ladministrateur
// Contacter l'administrateur
// </Button>
// </div>
// </DefaultDoubleSidePage>