diff --git a/package.json b/package.json index 7d306a4d..9d3fba5b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "eslint-config-next": "13.2.4", "form-data": "^4.0.0", "jwt-decode": "^3.1.2", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.89", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.90", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", diff --git a/src/front/Api/Auth/IdNot/User.ts b/src/front/Api/Auth/IdNot/User.ts index 96c54a77..1854979a 100644 --- a/src/front/Api/Auth/IdNot/User.ts +++ b/src/front/Api/Auth/IdNot/User.ts @@ -27,7 +27,6 @@ export default class User extends BaseApiService { } public async verifyJwt(jwt: string) { - console.log(this.baseURl); const url = new URL(`${this.baseURl}/verify-token/${jwt}`); try { return await this.postRequest(url); diff --git a/src/front/Api/Auth/IdNot/index.ts b/src/front/Api/Auth/IdNot/index.ts index 58cd9933..b358b6c8 100644 --- a/src/front/Api/Auth/IdNot/index.ts +++ b/src/front/Api/Auth/IdNot/index.ts @@ -16,7 +16,6 @@ export default class Auth extends BaseApiService { public async logOutWithIdNot() { const variables = FrontendVariables.getInstance(); const url = new URL(`${variables.IDNOT_BASE_URL}/user/auth/logout?post_logout_redirect_uri=${variables.FRONT_APP_HOST}`); - console.log(url.toString()) try { return await fetch(url); } catch (err) { diff --git a/src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts b/src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts index 800d3c96..b7aa1342 100644 --- a/src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts +++ b/src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts @@ -1,7 +1,6 @@ import { type OfficeFolder } from "le-coffre-resources/dist/Notary"; import BaseNotary from "../BaseNotary"; -import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus"; // TODO Type get query params -> Where + inclue + orderby export interface IGetFoldersParams { @@ -97,20 +96,32 @@ export default class Folders extends BaseNotary { } } - public async archive(uid: string, body: Partial): Promise { - body.status = EFolderStatus.ARCHIVED; + public async archive(uid: string, archived_description: string): Promise { try { - return await this.put(uid, body); + const url = new URL(this.baseURl.concat(`/${uid}/archive`)); + try { + return await this.putRequest(url, { + archived_description, + }); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } } catch (err) { this.onError(err); return Promise.reject(err); } } - public async restore(uid: string, body: Partial): Promise { - body.status = EFolderStatus.LIVE; + public async restore(uid: string): Promise { try { - return await this.put(uid, body); + const url = new URL(this.baseURl.concat(`/${uid}/restore`)); + try { + return await this.putRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } } catch (err) { this.onError(err); return Promise.reject(err); diff --git a/src/front/Components/DesignSystem/DepositOtherDocument/index.tsx b/src/front/Components/DesignSystem/DepositOtherDocument/index.tsx index 7d84c26b..d2192944 100644 --- a/src/front/Components/DesignSystem/DepositOtherDocument/index.tsx +++ b/src/front/Components/DesignSystem/DepositOtherDocument/index.tsx @@ -121,7 +121,6 @@ export default class DepositOtherDocument extends React.Component 0 && (
{this.state.currentFiles.map((file) => { - console.log(file); const fileObj = file.file; @@ -237,9 +236,6 @@ export default class DepositOtherDocument extends React.Component file.index === parseInt(indexToRemove)); diff --git a/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx b/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx index a2e95014..48529ede 100644 --- a/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx +++ b/src/front/Components/DesignSystem/FolderBoxInformation/index.tsx @@ -8,11 +8,13 @@ import React from "react"; import Typography, { ITypo } from "../Typography"; import classes from "./classes.module.scss"; +import { AnchorStatus } from "@Front/Components/Layouts/Folder/FolderInformation"; type IProps = { folder: OfficeFolder; type: EFolderBoxInformationType; isArchived?: boolean; + anchorStatus: AnchorStatus; }; export enum EFolderBoxInformationType { @@ -34,7 +36,7 @@ export default function FolderBoxInformation(props: IProps) { return (
{renderContentByType(props.folder, type)}
- {!isArchived && ( + {!isArchived && props.anchorStatus === AnchorStatus.NOT_ANCHORED && ( edit informations diff --git a/src/front/Components/DesignSystem/UserFolder/index.tsx b/src/front/Components/DesignSystem/UserFolder/index.tsx index 3e2ca7da..62391808 100644 --- a/src/front/Components/DesignSystem/UserFolder/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/index.tsx @@ -16,6 +16,7 @@ import QuantityProgressBar from "../QuantityProgressBar"; import classes from "./classes.module.scss"; import DocumentList from "./DocumentList"; import UserFolderHeader from "./UserFolderHeader"; +import { AnchorStatus } from "@Front/Components/Layouts/Folder/FolderInformation"; type IProps = { customer: Customer; @@ -24,6 +25,7 @@ type IProps = { isArchived?: boolean; isOpened: boolean; onChange: (id: string) => void; + anchorStatus: AnchorStatus; }; type IState = { isOpenDeletionModal: boolean; @@ -89,25 +91,35 @@ export default class UserFolder extends React.Component { currentNumber={this.calculateDocumentsPercentageProgress()} />
- + {this.props.anchorStatus === AnchorStatus.NOT_ANCHORED && ( + + )} + 0 - ? "Vous avez des documents à valider." + ? this.props.anchorStatus !== AnchorStatus.NOT_ANCHORED + ? "" + : "Vous avez des documents à valider." : "Vous n'avez aucun document à valider" } openDeletionModal={this.openDeletionModal} folderUid={this.props.folder.uid!} /> - {!this.props.isArchived && ( + + {!this.props.isArchived && this.props.anchorStatus === AnchorStatus.NOT_ANCHORED && (
- + {this.props.anchorStatus === AnchorStatus.NOT_ANCHORED && ( + + + + )} ) : (
@@ -48,11 +52,13 @@ export default class ClientSection extends React.Component { Aucun client n'est associé au dossier.
- - - + {this.props.anchorStatus === AnchorStatus.NOT_ANCHORED && ( + + + + )}
)}
@@ -69,6 +75,7 @@ export default class ClientSection extends React.Component { key={customer.uid} isOpened={this.state.openedCustomer === customer.uid} onChange={this.changeUserFolder} + anchorStatus={this.props.anchorStatus} /> ); }); diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index 9c116b19..8d324b13 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -23,7 +23,7 @@ import ClientSection from "./ClientSection"; import CheckBox from "@Front/Components/DesignSystem/CheckBox"; import Loader from "@Front/Components/DesignSystem/Loader"; -enum AnchorStatus { +export enum AnchorStatus { "VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN", "ANCHORING" = "ANCHORING", "NOT_ANCHORED" = "NOT_ANCHORED", @@ -97,11 +97,13 @@ class FolderInformationClass extends BasePage {
@@ -113,10 +115,14 @@ class FolderInformationClass extends BasePage { currentNumber={this.getCompletionNumber()} />
- {this.doesFolderHaveCustomer() && } + {this.doesFolderHaveCustomer() && ( + + )}
- {!this.doesFolderHaveCustomer() && } + {!this.doesFolderHaveCustomer() && ( + + )}
)} + )} + {this.props.isLoading && ( +
+
+ +
+
+ )} ); } @@ -123,9 +141,7 @@ class FolderInformationClass extends BasePage { private async restoreFolder() { if (!this.state.selectedFolder) return; - const ressourceFolder = OfficeFolder.hydrate(this.state.selectedFolder); - ressourceFolder.archived_description = null; - await Folders.getInstance().restore(this.state.selectedFolder.uid ?? "", ressourceFolder); + await Folders.getInstance().restore(this.state.selectedFolder.uid ?? ""); this.props.router.push( Module.getInstance() .get() @@ -156,7 +172,69 @@ class FolderInformationClass extends BasePage { export default function FolderInformation(props: IProps) { const router = useRouter(); + const [isAnchored, setIsAnchored] = useState(AnchorStatus.NOT_ANCHORED); + const [isLoading, setIsLoading] = useState(true); + const [selectedFolder, setSelectedFolder] = useState(null); + let { folderUid } = router.query; folderUid = folderUid as string; - return ; + + const getAnchoringStatus = useCallback(async () => { + if(!folderUid) return; + setIsLoading(true); + 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); + } + setIsLoading(false); + }, [folderUid]); + + const getFolder = useCallback(async () => { + if (!folderUid) return; + setIsLoading(true); + const query = { + q: { + deed: { include: { deed_type: true } }, + office: true, + customers: { + include: { + contact: true, + documents: { + include: { + folder: true, + document_type: true, + files: true, + }, + }, + }, + }, + documents: { + include: { + depositor: { + include: { + contact: true, + }, + }, + }, + }, + folder_anchor: true, + }, + }; + const folder = await Folders.getInstance().getByUid(folderUid as string, query); + if (folder) { + setSelectedFolder(folder); + getAnchoringStatus(); + } + + setIsLoading(false); + }, [folderUid, getAnchoringStatus]); + + useEffect(() => { + setIsLoading(true); + getFolder(); + }, [getFolder]); + + return ; } diff --git a/src/front/Components/Layouts/LoginCallback/index.tsx b/src/front/Components/Layouts/LoginCallback/index.tsx index 12d2293c..86b3a6e2 100644 --- a/src/front/Components/Layouts/LoginCallback/index.tsx +++ b/src/front/Components/Layouts/LoginCallback/index.tsx @@ -22,6 +22,7 @@ export default function LoginCallBack() { if (!code) return; try { const token = await Auth.getInstance().getIdnotJwt(code as string); + if (!token) return router.push(Module.getInstance().get().modules.pages.Login.props.path); await UserStore.instance.connect(token.accessToken, token.refreshToken); return router.push(Module.getInstance().get().modules.pages.Folder.props.path); } catch (e) { diff --git a/src/front/Components/Layouts/Users/UserInformations/index.tsx b/src/front/Components/Layouts/Users/UserInformations/index.tsx index 9962f139..9f393bd0 100644 --- a/src/front/Components/Layouts/Users/UserInformations/index.tsx +++ b/src/front/Components/Layouts/Users/UserInformations/index.tsx @@ -165,7 +165,7 @@ export default function UserInformations(props: IProps) { let vote = Vote.hydrate({ appointment: Appointment.hydrate({ uid: currentAppointment?.uid ?? undefined, - targeted_user: User.hydrate({ + user: User.hydrate({ uid: userSelected.uid, }), choice: superAdminModalType === "add" ? EVote.NOMINATE : EVote.DISMISS,