Merge Dev in Staging
This commit is contained in:
commit
897f75c698
16
package-lock.json
generated
16
package-lock.json
generated
@ -22,7 +22,7 @@
|
|||||||
"eslint-config-next": "13.2.4",
|
"eslint-config-next": "13.2.4",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.85",
|
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.89",
|
||||||
"next": "13.2.4",
|
"next": "13.2.4",
|
||||||
"prettier": "^2.8.7",
|
"prettier": "^2.8.7",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
@ -394,9 +394,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@eslint-community/regexpp": {
|
"node_modules/@eslint-community/regexpp": {
|
||||||
"version": "4.9.0",
|
"version": "4.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.1.tgz",
|
||||||
"integrity": "sha512-zJmuCWj2VLBt4c25CfBIbMZLGLyhkvs7LznyVX5HfpzeocThgIj5XQK4L+g3U36mMcx8bPMhGyPpwCATamC4jQ==",
|
"integrity": "sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
|
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
|
||||||
}
|
}
|
||||||
@ -1507,9 +1507,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001542",
|
"version": "1.0.30001543",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001542.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001543.tgz",
|
||||||
"integrity": "sha512-UrtAXVcj1mvPBFQ4sKd38daP8dEcXXr5sQe6QNNinaPd0iA/cxg9/l3VrSdL73jgw5sKyuQ6jNgiKO12W3SsVA==",
|
"integrity": "sha512-qxdO8KPWPQ+Zk6bvNpPeQIOH47qZSYdFZd6dXQzb2KzhnSXju4Kd7H1PkSJx6NICSMgo/IhRZRhhfPTHYpJUCA==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@ -3361,7 +3361,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/le-coffre-resources": {
|
"node_modules/le-coffre-resources": {
|
||||||
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#0e1663716a698cc584a89e5e2a03b72113702d55",
|
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#a100398ef5c1984ba74cb1c8c182648315accc3e",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"class-transformer": "^0.5.1",
|
"class-transformer": "^0.5.1",
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
"eslint-config-next": "13.2.4",
|
"eslint-config-next": "13.2.4",
|
||||||
"form-data": "^4.0.0",
|
"form-data": "^4.0.0",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.88",
|
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.89",
|
||||||
"next": "13.2.4",
|
"next": "13.2.4",
|
||||||
"prettier": "^2.8.7",
|
"prettier": "^2.8.7",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
import { ContentType } from "@Front/Api/BaseApiService";
|
import { ContentType } from "@Front/Api/BaseApiService";
|
||||||
import BaseNotary from "../BaseNotary";
|
import BaseNotary from "../BaseNotary";
|
||||||
|
import { OfficeFolderAnchor } from "le-coffre-resources/dist/Notary";
|
||||||
|
export interface IGetAnchorsParams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
}
|
||||||
|
|
||||||
export default class OfficeFolderAnchors extends BaseNotary {
|
export default class OfficeFolderAnchors extends BaseNotary {
|
||||||
private static instance: OfficeFolderAnchors;
|
private static instance: OfficeFolderAnchors;
|
||||||
private readonly baseURl = this.namespaceUrl.concat("/anchors");
|
private readonly baseUrl = this.namespaceUrl.concat("/anchors");
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
super();
|
super();
|
||||||
@ -17,20 +23,34 @@ export default class OfficeFolderAnchors extends BaseNotary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async get(uid: string): Promise<any> {
|
public async get(q?: IGetAnchorsParams): Promise<OfficeFolderAnchor[]> {
|
||||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
const url = new URL(this.baseUrl);
|
||||||
|
if (q) {
|
||||||
|
const query = { q };
|
||||||
|
Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return await this.getRequest<any>(url);
|
return await this.getRequest<OfficeFolderAnchor[]>(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.onError(err);
|
this.onError(err);
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async post(uid: string): Promise<any> {
|
public async getByUid(uid: string): Promise<OfficeFolderAnchor> {
|
||||||
const url = new URL(this.baseURl.concat(`/${uid}`));
|
const url = new URL(this.baseUrl.concat(`/${uid}`));
|
||||||
try {
|
try {
|
||||||
return await this.postRequest<any>(url, {});
|
return await this.getRequest<OfficeFolderAnchor>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(uid: string): Promise<OfficeFolderAnchor> {
|
||||||
|
const url = new URL(this.baseUrl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.postRequest<OfficeFolderAnchor>(url, {});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.onError(err);
|
this.onError(err);
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
@ -38,7 +58,7 @@ export default class OfficeFolderAnchors extends BaseNotary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async download(uid: string): Promise<any> {
|
public async download(uid: string): Promise<any> {
|
||||||
const url = new URL(this.baseURl.concat(`/download/${uid}`));
|
const url = new URL(this.baseUrl.concat(`/download/${uid}`));
|
||||||
try {
|
try {
|
||||||
return await this.getRequest<any>(url, undefined, ContentType.PDF, `${uid}.pdf`);
|
return await this.getRequest<any>(url, undefined, ContentType.PDF, `${uid}.pdf`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -8,10 +8,33 @@ import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule";
|
|||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import Notifications from "@Front/Api/LeCoffreApi/Notary/Notifications/Notifications";
|
import Notifications from "@Front/Api/LeCoffreApi/Notary/Notifications/Notifications";
|
||||||
import Toasts from "@Front/Stores/Toasts";
|
import Toasts from "@Front/Stores/Toasts";
|
||||||
|
import OfficeFolderAnchors from "@Front/Api/LeCoffreApi/Notary/OfficeFolderAnchors/OfficeFolderAnchors";
|
||||||
export default function Navigation() {
|
export default function Navigation() {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
const getAnchoringStatus = useCallback(async () => {
|
||||||
|
const anchors = await OfficeFolderAnchors.getInstance().get({
|
||||||
|
where: {
|
||||||
|
status: {
|
||||||
|
not: "VERIFIED_ON_CHAIN",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
folder: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (const anchor of anchors) {
|
||||||
|
await OfficeFolderAnchors.getInstance().getByUid(anchor.folder?.uid as string);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const getNotifications = useCallback(async () => {
|
const getNotifications = useCallback(async () => {
|
||||||
|
//await getAnchoringStatus();
|
||||||
const notifications = await Notifications.getInstance().get({
|
const notifications = await Notifications.getInstance().get({
|
||||||
where: {
|
where: {
|
||||||
read: false,
|
read: false,
|
||||||
@ -27,8 +50,9 @@ export default function Navigation() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
getAnchoringStatus();
|
||||||
getNotifications();
|
getNotifications();
|
||||||
}, [pathname, getNotifications]);
|
}, [pathname, getNotifications, getAnchoringStatus]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
|
@ -108,10 +108,12 @@ class ToastElementClass extends React.Component<IPropsClass, IState> {
|
|||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleClick(e: React.MouseEvent) {
|
private async handleClick(e: React.MouseEvent) {
|
||||||
|
console.log('redirectUrl', this.props.toast.redirectUrl);
|
||||||
if (this.props.toast.redirectUrl) {
|
if (this.props.toast.redirectUrl) {
|
||||||
this.props.router.push(this.props.toast.redirectUrl);
|
|
||||||
this.onClose(e);
|
this.onClose(e);
|
||||||
|
await this.props.router.push(this.props.toast.redirectUrl);
|
||||||
|
this.props.router.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ type IProps = {};
|
|||||||
type IState = {
|
type IState = {
|
||||||
toastList: IToast[];
|
toastList: IToast[];
|
||||||
};
|
};
|
||||||
export default class ToastsContainer extends React.Component<IProps, IState> {
|
export class ToastsContainerClass extends React.Component<IProps, IState> {
|
||||||
private removeOnChange = () => {};
|
private removeOnChange = () => {};
|
||||||
|
|
||||||
public constructor(props: IProps) {
|
public constructor(props: IProps) {
|
||||||
@ -25,7 +25,7 @@ export default class ToastsContainer extends React.Component<IProps, IState> {
|
|||||||
<div className={classNames(classes["root"], this.state.toastList.length > 0 && classes["open"])}>
|
<div className={classNames(classes["root"], this.state.toastList.length > 0 && classes["open"])}>
|
||||||
<>
|
<>
|
||||||
{this.state.toastList.map((toast) => {
|
{this.state.toastList.map((toast) => {
|
||||||
return <ToastElement toast={toast} key={toast.id} />;
|
return <ToastElement toast={toast} key={toast.id}/>;
|
||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
@ -44,3 +44,7 @@ export default class ToastsContainer extends React.Component<IProps, IState> {
|
|||||||
this.setState({ toastList });
|
this.setState({ toastList });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function ToastsContainer(props: IProps) {
|
||||||
|
return <ToastsContainerClass {...props}/>;
|
||||||
|
};
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
.add-document-form-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 24px;
|
||||||
|
|
||||||
|
.radiobox-container {
|
||||||
|
> :not(:last-child) {
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,159 @@
|
|||||||
|
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
||||||
|
import classes from "./classes.module.scss";
|
||||||
|
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
||||||
|
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||||
|
import { ChangeEvent, useCallback, useEffect, useState } from "react";
|
||||||
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
|
import { DocumentType, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
import Deeds from "@Front/Api/LeCoffreApi/Notary/Deeds/Deeds";
|
||||||
|
import MultiSelect from "@Front/Components/DesignSystem/MultiSelect";
|
||||||
|
import { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
|
||||||
|
import { MultiValue } from "react-select";
|
||||||
|
import RadioBox from "@Front/Components/DesignSystem/RadioBox";
|
||||||
|
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
|
|
||||||
|
type IProps = {
|
||||||
|
isCreateDocumentModalVisible: boolean;
|
||||||
|
closeModal: () => void;
|
||||||
|
folder: OfficeFolder;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function ParameterDocuments(props: IProps) {
|
||||||
|
const [visibleDescription, setVisibleDescription] = useState<string>("");
|
||||||
|
const [documentName, setDocumentName] = useState<string>("");
|
||||||
|
|
||||||
|
const [addOrEditDocument, setAddOrEditDocument] = useState<"add" | "edit">("edit");
|
||||||
|
|
||||||
|
const [selectedDocuments, setSelectedDocuments] = useState<IOption[]>([]);
|
||||||
|
const [formattedOptions, setFormattedOptions] = useState<IOption[]>([]);
|
||||||
|
|
||||||
|
const getAvailableDocuments = useCallback(async () => {
|
||||||
|
const documents = await DocumentTypes.getInstance().get({});
|
||||||
|
|
||||||
|
const formattedOptions: IOption[] = documents
|
||||||
|
.filter((document) => {
|
||||||
|
return !props.folder.deed?.document_types?.some((documentType) => documentType.uid === document.uid);
|
||||||
|
})
|
||||||
|
.map((document) => {
|
||||||
|
return {
|
||||||
|
label: document.name,
|
||||||
|
value: document.uid,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
setFormattedOptions(formattedOptions);
|
||||||
|
}, [props.folder.deed?.document_types]);
|
||||||
|
|
||||||
|
const onVisibleDescriptionChange = (event: ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
|
||||||
|
setVisibleDescription(event.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDocumentNameChange = (event: ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
|
||||||
|
setDocumentName(event.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDocumentChangeHandler = useCallback((values: MultiValue<IOption>) => {
|
||||||
|
setSelectedDocuments(values as IOption[]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleClose = useCallback(() => {
|
||||||
|
setFormattedOptions([]);
|
||||||
|
setSelectedDocuments([]);
|
||||||
|
setAddOrEditDocument("edit");
|
||||||
|
setVisibleDescription("");
|
||||||
|
setDocumentName("");
|
||||||
|
props.closeModal();
|
||||||
|
}, [props]);
|
||||||
|
|
||||||
|
const addDocument = useCallback(async () => {
|
||||||
|
if (addOrEditDocument === "add") {
|
||||||
|
try {
|
||||||
|
const documentType = await DocumentTypes.getInstance().post({
|
||||||
|
name: documentName,
|
||||||
|
private_description: visibleDescription,
|
||||||
|
office: {
|
||||||
|
uid: props.folder.office!.uid!,
|
||||||
|
},
|
||||||
|
public_description: visibleDescription,
|
||||||
|
});
|
||||||
|
|
||||||
|
const oldDocumentsType = props.folder.deed?.document_types!;
|
||||||
|
await Deeds.getInstance().put(props.folder.deed?.uid!, {
|
||||||
|
document_types: [...oldDocumentsType, documentType],
|
||||||
|
});
|
||||||
|
|
||||||
|
//await this.loadData();
|
||||||
|
handleClose();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const oldDocumentsType = props.folder.deed?.document_types!;
|
||||||
|
await Deeds.getInstance().put(props.folder.deed?.uid!, {
|
||||||
|
document_types: [
|
||||||
|
...oldDocumentsType,
|
||||||
|
...selectedDocuments.map((document) => DocumentType.hydrate<DocumentType>({ uid: document.value as string })),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
//await this.loadData();
|
||||||
|
handleClose();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [addOrEditDocument, documentName, handleClose, props, selectedDocuments, visibleDescription]);
|
||||||
|
|
||||||
|
const selectEditMode = () => {
|
||||||
|
setAddOrEditDocument("edit");
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectAddMode = () => {
|
||||||
|
setAddOrEditDocument("add");
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getAvailableDocuments();
|
||||||
|
}, [getAvailableDocuments, props.folder]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Confirm
|
||||||
|
isOpen={props.isCreateDocumentModalVisible}
|
||||||
|
onClose={handleClose}
|
||||||
|
onAccept={addDocument}
|
||||||
|
closeBtn
|
||||||
|
header={"Ajouter des documents demandables"}
|
||||||
|
cancelText={"Annuler"}
|
||||||
|
confirmText={"Ajouter"}>
|
||||||
|
<div className={classes["add-document-form-container"]}>
|
||||||
|
<div className={classes["radiobox-container"]}>
|
||||||
|
<RadioBox name="document" onChange={selectEditMode} checked={addOrEditDocument === "edit"} value={"existing client"}>
|
||||||
|
<Typography typo={ITypo.P_ERR_18}>Document existant</Typography>
|
||||||
|
</RadioBox>
|
||||||
|
|
||||||
|
<RadioBox name="document" onChange={selectAddMode} checked={addOrEditDocument === "add"} value={"new client"}>
|
||||||
|
<Typography typo={ITypo.P_ERR_18}>Créer un document</Typography>
|
||||||
|
</RadioBox>
|
||||||
|
</div>
|
||||||
|
{addOrEditDocument === "add" && (
|
||||||
|
<>
|
||||||
|
<TextField name="document_name" placeholder="Nom du document à ajouter" onChange={onDocumentNameChange} />
|
||||||
|
<TextAreaField
|
||||||
|
name="description"
|
||||||
|
placeholder="Description visible par le client"
|
||||||
|
onChange={onVisibleDescriptionChange}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{addOrEditDocument === "edit" && (
|
||||||
|
<MultiSelect
|
||||||
|
options={formattedOptions}
|
||||||
|
placeholder="Cliquez pour sélectionner des documents"
|
||||||
|
onChange={onDocumentChangeHandler}
|
||||||
|
defaultValue={selectedDocuments}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Confirm>
|
||||||
|
);
|
||||||
|
}
|
@ -37,10 +37,4 @@
|
|||||||
.buttons-container {
|
.buttons-container {
|
||||||
margin-top: 32px;
|
margin-top: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-document-form-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 24px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
import PlusIcon from "@Assets/Icons/plus.svg";
|
import PlusIcon from "@Assets/Icons/plus.svg";
|
||||||
import Deeds from "@Front/Api/LeCoffreApi/Notary/Deeds/Deeds";
|
|
||||||
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
||||||
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
|
||||||
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import CheckBox from "@Front/Components/DesignSystem/CheckBox";
|
import CheckBox from "@Front/Components/DesignSystem/CheckBox";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
|
import { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
|
||||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
|
||||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
|
||||||
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
|
|
||||||
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
import BackArrow from "@Front/Components/Elements/BackArrow";
|
import BackArrow from "@Front/Components/Elements/BackArrow";
|
||||||
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
||||||
@ -20,6 +15,7 @@ import React from "react";
|
|||||||
|
|
||||||
import BasePage from "../../Base";
|
import BasePage from "../../Base";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
import ParameterDocuments from "./ParameterDocuments";
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
type IPropsClass = IProps & {
|
type IPropsClass = IProps & {
|
||||||
@ -29,8 +25,6 @@ type IPropsClass = IProps & {
|
|||||||
};
|
};
|
||||||
type IState = {
|
type IState = {
|
||||||
isCreateDocumentModalVisible: boolean;
|
isCreateDocumentModalVisible: boolean;
|
||||||
documentName: string;
|
|
||||||
visibleDescription: string;
|
|
||||||
documentTypes: IOption[];
|
documentTypes: IOption[];
|
||||||
folder: OfficeFolder | null;
|
folder: OfficeFolder | null;
|
||||||
};
|
};
|
||||||
@ -41,8 +35,6 @@ class AskDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isCreateDocumentModalVisible: false,
|
isCreateDocumentModalVisible: false,
|
||||||
documentName: "",
|
|
||||||
visibleDescription: "",
|
|
||||||
documentTypes: [],
|
documentTypes: [],
|
||||||
folder: null,
|
folder: null,
|
||||||
};
|
};
|
||||||
@ -50,11 +42,6 @@ class AskDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
this.onFormSubmit = this.onFormSubmit.bind(this);
|
this.onFormSubmit = this.onFormSubmit.bind(this);
|
||||||
this.closeModal = this.closeModal.bind(this);
|
this.closeModal = this.closeModal.bind(this);
|
||||||
this.openModal = this.openModal.bind(this);
|
this.openModal = this.openModal.bind(this);
|
||||||
this.cancel = this.cancel.bind(this);
|
|
||||||
this.onVisibleDescriptionChange = this.onVisibleDescriptionChange.bind(this);
|
|
||||||
this.onDocumentNameChange = this.onDocumentNameChange.bind(this);
|
|
||||||
this.addDocument = this.addDocument.bind(this);
|
|
||||||
this.canAddDocument = this.canAddDocument.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override render(): JSX.Element {
|
public override render(): JSX.Element {
|
||||||
@ -101,25 +88,14 @@ class AskDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
<Confirm
|
</div>
|
||||||
isOpen={this.state.isCreateDocumentModalVisible}
|
{this.state.folder && (
|
||||||
onClose={this.closeModal}
|
<ParameterDocuments
|
||||||
onAccept={this.addDocument}
|
folder={this.state.folder}
|
||||||
canConfirm={this.canAddDocument()}
|
closeModal={this.closeModal}
|
||||||
closeBtn
|
isCreateDocumentModalVisible={this.state.isCreateDocumentModalVisible}
|
||||||
header={"Créer un type de document"}
|
|
||||||
cancelText={"Annuler"}
|
|
||||||
confirmText={"Ajouter"}>
|
|
||||||
<div className={classes["add-document-form-container"]}>
|
|
||||||
<TextField name="document_name" placeholder="Nom du document à ajouter" onChange={this.onDocumentNameChange} />
|
|
||||||
<TextAreaField
|
|
||||||
name="description"
|
|
||||||
placeholder="Description visible par le client"
|
|
||||||
onChange={this.onVisibleDescriptionChange}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
)}
|
||||||
</Confirm>
|
|
||||||
</div>
|
|
||||||
</DefaultNotaryDashboard>
|
</DefaultNotaryDashboard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -128,6 +104,8 @@ class AskDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
this.loadData();
|
this.loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private cancel() {}
|
||||||
|
|
||||||
private async loadData() {
|
private async loadData() {
|
||||||
try {
|
try {
|
||||||
const folder = await Folders.getInstance().getByUid(this.props.folderUid, {
|
const folder = await Folders.getInstance().getByUid(this.props.folderUid, {
|
||||||
@ -186,72 +164,16 @@ class AskDocumentsClass extends BasePage<IPropsClass, IState> {
|
|||||||
return documentTypesOptions;
|
return documentTypesOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private canAddDocument() {
|
|
||||||
if (this.state.documentName === "" || this.state.visibleDescription === "") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async addDocument() {
|
|
||||||
try {
|
|
||||||
const documentType = await DocumentTypes.getInstance().post({
|
|
||||||
name: this.state.documentName,
|
|
||||||
private_description: this.state.visibleDescription,
|
|
||||||
office: {
|
|
||||||
uid: this.state.folder?.office!.uid!,
|
|
||||||
},
|
|
||||||
public_description: this.state.visibleDescription,
|
|
||||||
});
|
|
||||||
|
|
||||||
const oldDocumentsType = this.state.folder?.deed?.document_types!;
|
|
||||||
await Deeds.getInstance().put(this.state.folder?.deed?.uid!, {
|
|
||||||
document_types: [...oldDocumentsType, documentType],
|
|
||||||
});
|
|
||||||
|
|
||||||
await this.loadData();
|
|
||||||
this.setState({
|
|
||||||
isCreateDocumentModalVisible: false,
|
|
||||||
documentName: "",
|
|
||||||
visibleDescription: "",
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private onVisibleDescriptionChange(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) {
|
|
||||||
this.setState({
|
|
||||||
visibleDescription: e.target.value,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private onDocumentNameChange(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) {
|
|
||||||
this.setState({
|
|
||||||
documentName: e.target.value,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private cancel() {
|
|
||||||
this.setState({
|
|
||||||
visibleDescription: "",
|
|
||||||
documentName: "",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private openModal() {
|
private openModal() {
|
||||||
this.setState({
|
this.setState({
|
||||||
isCreateDocumentModalVisible: true,
|
isCreateDocumentModalVisible: true,
|
||||||
visibleDescription: "",
|
|
||||||
documentName: "",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private closeModal() {
|
private closeModal() {
|
||||||
|
this.loadData();
|
||||||
this.setState({
|
this.setState({
|
||||||
isCreateDocumentModalVisible: false,
|
isCreateDocumentModalVisible: false,
|
||||||
visibleDescription: "",
|
|
||||||
documentName: "",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ type IPropsClass = IProps & {
|
|||||||
isAnchored: AnchorStatus;
|
isAnchored: AnchorStatus;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
selectedFolder: OfficeFolder | null;
|
selectedFolder: OfficeFolder | null;
|
||||||
|
getAnchoringStatus: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IState = {
|
type IState = {
|
||||||
@ -314,7 +315,8 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
private async anchorFolder() {
|
private async anchorFolder() {
|
||||||
if (!this.props.selectedFolder?.uid) return;
|
if (!this.props.selectedFolder?.uid) return;
|
||||||
return await OfficeFolderAnchors.getInstance().post(this.props.selectedFolder.uid);
|
await OfficeFolderAnchors.getInstance().post(this.props.selectedFolder.uid);
|
||||||
|
this.props.getAnchoringStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async downloadAnchoringProof(uid?: string) {
|
private async downloadAnchoringProof(uid?: string) {
|
||||||
@ -404,6 +406,16 @@ export default function FolderInformation(props: IProps) {
|
|||||||
let { folderUid } = router.query;
|
let { folderUid } = router.query;
|
||||||
folderUid = folderUid as string;
|
folderUid = folderUid as string;
|
||||||
|
|
||||||
|
const getAnchoringStatus = useCallback(async () => {
|
||||||
|
if (!folderUid) return;
|
||||||
|
try {
|
||||||
|
const anchorStatus = await OfficeFolderAnchors.getInstance().getByUid(folderUid as string);
|
||||||
|
setIsAnchored(anchorStatus.status === "VERIFIED_ON_CHAIN" ? AnchorStatus.VERIFIED_ON_CHAIN : AnchorStatus.ANCHORING);
|
||||||
|
} catch (e) {
|
||||||
|
setIsAnchored(AnchorStatus.NOT_ANCHORED);
|
||||||
|
}
|
||||||
|
}, [folderUid]);
|
||||||
|
|
||||||
const getFolder = useCallback(async () => {
|
const getFolder = useCallback(async () => {
|
||||||
if (!folderUid) return;
|
if (!folderUid) return;
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@ -439,17 +451,11 @@ export default function FolderInformation(props: IProps) {
|
|||||||
const folder = await Folders.getInstance().getByUid(folderUid as string, query);
|
const folder = await Folders.getInstance().getByUid(folderUid as string, query);
|
||||||
if (folder) {
|
if (folder) {
|
||||||
setSelectedFolder(folder);
|
setSelectedFolder(folder);
|
||||||
|
getAnchoringStatus();
|
||||||
try {
|
|
||||||
const anchorStatus = await OfficeFolderAnchors.getInstance().get(folderUid as string);
|
|
||||||
setIsAnchored(anchorStatus.status === "VERIFIED_ON_CHAIN" ? AnchorStatus.VERIFIED_ON_CHAIN : AnchorStatus.ANCHORING);
|
|
||||||
} catch (e) {
|
|
||||||
setIsAnchored(AnchorStatus.NOT_ANCHORED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}, [folderUid]);
|
}, [folderUid, getAnchoringStatus]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@ -464,6 +470,7 @@ export default function FolderInformation(props: IProps) {
|
|||||||
isAnchored={isAnchored}
|
isAnchored={isAnchored}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
selectedFolder={selectedFolder}
|
selectedFolder={selectedFolder}
|
||||||
|
getAnchoringStatus={getAnchoringStatus}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user