diff --git a/package-lock.json b/package-lock.json index 21bf7bf5..0b5a1fd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,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.84", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.85", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", @@ -394,9 +394,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.8.2", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.8.2.tgz", - "integrity": "sha512-0MGxAVt1m/ZK+LTJp/j0qF7Hz97D9O/FH9Ms3ltnyIdDD57cbb1ACIQTkbHvNXtWDv5TPq7w5Kq56+cNukbo7g==", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.0.tgz", + "integrity": "sha512-zJmuCWj2VLBt4c25CfBIbMZLGLyhkvs7LznyVX5HfpzeocThgIj5XQK4L+g3U36mMcx8bPMhGyPpwCATamC4jQ==", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } @@ -1016,9 +1016,9 @@ } }, "node_modules/@types/react-transition-group": { - "version": "4.4.6", - "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.6.tgz", - "integrity": "sha512-VnCdSxfcm08KjsJVQcfBmhEQAPnLB8G08hAxn39azX1qYBQ/5RVQuoHuKIcfKOdncuaUvEpFKFzEvbtIMsfVew==", + "version": "4.4.7", + "resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.7.tgz", + "integrity": "sha512-ICCyBl5mvyqYp8Qeq9B5G/fyBSRC0zx3XM3sCC6KkcMsNeAHqXBKkmat4GqdJET5jtYUpZXrxI5flve5qhi2Eg==", "dependencies": { "@types/react": "*" } @@ -1507,9 +1507,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001539", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001539.tgz", - "integrity": "sha512-hfS5tE8bnNiNvEOEkm8HElUHroYwlqMMENEzELymy77+tJ6m+gA2krtHl5hxJaj71OlpC2cHZbdSMX1/YEqEkA==", + "version": "1.0.30001541", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001541.tgz", + "integrity": "sha512-bLOsqxDgTqUBkzxbNlSBt8annkDpQB9NdzdTbO2ooJ+eC/IQcvDspDc058g84ejCelF7vHUx57KIOjEecOHXaw==", "funding": [ { "type": "opencollective", @@ -3361,7 +3361,7 @@ } }, "node_modules/le-coffre-resources": { - "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#e28887de459d0820c732bd4eed3c422a4b3aad90", + "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#0e1663716a698cc584a89e5e2a03b72113702d55", "license": "MIT", "dependencies": { "class-transformer": "^0.5.1", @@ -3382,9 +3382,9 @@ } }, "node_modules/libphonenumber-js": { - "version": "1.10.44", - "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.44.tgz", - "integrity": "sha512-svlRdNBI5WgBjRC20GrCfbFiclbF0Cx+sCcQob/C1r57nsoq0xg8r65QbTyVyweQIlB33P+Uahyho6EMYgcOyQ==" + "version": "1.10.45", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.45.tgz", + "integrity": "sha512-eeHcvGafEYCaKB4fo2uBINfG7j7PcGwBHUaTVfbwl/6KcjCgIKNlIOsSXVRp9BH10NQwmvvk+nQ1e/Yp4BGB7w==" }, "node_modules/lines-and-columns": { "version": "1.2.4", diff --git a/package.json b/package.json index cc9c4d3e..53e1bb64 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.84", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.85", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", diff --git a/src/front/Api/LeCoffreApi/Customer/Customers/Customers.ts b/src/front/Api/LeCoffreApi/Customer/Customers/Customers.ts deleted file mode 100644 index b596a695..00000000 --- a/src/front/Api/LeCoffreApi/Customer/Customers/Customers.ts +++ /dev/null @@ -1,67 +0,0 @@ -import Customer, { Contact } from "le-coffre-resources/dist/Customer"; - -import BaseCustomer from "../BaseCustomer"; -import { ECivility } from "le-coffre-resources/dist/Customer/Contact"; - -// TODO Type get query params -> Where + inclue + orderby -export interface IGetCustomersparams { - where?: {}; - include?: {}; -} - -// TODO Type getbyuid query params - -export type IPutCustomersParams = { - uid?: Customer["uid"]; - contact?: Customer["contact"]; -}; - -export interface IPostCustomersParams { - first_name: string; - last_name: string; - email: string; - cell_phone_number: string; - civility: ECivility; - address?: Contact["address"]; -} - -export default class Customers extends BaseCustomer { - private static instance: Customers; - private readonly baseURl = this.namespaceUrl.concat("/customers"); - - private constructor() { - super(); - } - - public static getInstance() { - if (!this.instance) { - return new this(); - } else { - return this.instance; - } - } - - public async get(q: IGetCustomersparams): Promise { - const url = new URL(this.baseURl); - const query = { q }; - Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); - try { - return await this.getRequest(url); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } - - public async getByUid(uid: string, q?: any): Promise { - const url = new URL(this.baseURl.concat(`/${uid}`)); - const query = { q }; - if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); - try { - return await this.getRequest(url); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } -} diff --git a/src/front/Api/LeCoffreApi/Customer/Users/Users.ts b/src/front/Api/LeCoffreApi/Customer/Users/Users.ts deleted file mode 100644 index e64928bc..00000000 --- a/src/front/Api/LeCoffreApi/Customer/Users/Users.ts +++ /dev/null @@ -1,49 +0,0 @@ -import BaseNotary from "../BaseCustomer"; -import User from "le-coffre-resources/dist/Notary"; - -export default class Users extends BaseNotary { - private static instance: Users; - private readonly baseURl = this.namespaceUrl.concat("/Users"); - - private constructor() { - super(); - } - - public static getInstance() { - if (!this.instance) { - return new Users(); - } else { - return this.instance; - } - } - - public async get(): Promise { - const url = new URL(this.baseURl); - try { - return await this.getRequest(url); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } - - public async getOne(uid: string): Promise { - const url = new URL(this.baseURl.concat("/").concat(uid)); - try { - return await this.getRequest(url); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } - - // public async post(params: User): Promise { - // const url = new URL(this.baseURl); - // try { - // return await this.postRequest(url, params); - // } catch (err) { - // this.onError(err); - // return Promise.reject(err); - // } - // } -} diff --git a/src/front/Api/LeCoffreApi/Notifications/Notifications.ts b/src/front/Api/LeCoffreApi/Notary/Notifications/Notifications.ts similarity index 86% rename from src/front/Api/LeCoffreApi/Notifications/Notifications.ts rename to src/front/Api/LeCoffreApi/Notary/Notifications/Notifications.ts index d93becc2..bdecfcce 100644 --- a/src/front/Api/LeCoffreApi/Notifications/Notifications.ts +++ b/src/front/Api/LeCoffreApi/Notary/Notifications/Notifications.ts @@ -1,4 +1,4 @@ -import BaseApiService from "@Front/Api/BaseApiService"; +import BaseNotary from "../BaseNotary"; import { UserNotification } from "le-coffre-resources/dist/Notary"; // TODO Type get query params -> Where + inclue + orderby @@ -12,9 +12,9 @@ export type IPutNotificationsParams = { read?: boolean; }; -export default class Notifications extends BaseApiService { +export default class Notifications extends BaseNotary { private static instance: Notifications; - private baseUrl = this.getBaseUrl().concat("/notifications"); + private baseUrl = this.namespaceUrl.concat("/notifications"); private constructor() { super(); diff --git a/src/front/Components/DesignSystem/BlockList/classes.module.scss b/src/front/Components/DesignSystem/BlockList/classes.module.scss index ca2072d0..879ad55d 100644 --- a/src/front/Components/DesignSystem/BlockList/classes.module.scss +++ b/src/front/Components/DesignSystem/BlockList/classes.module.scss @@ -26,4 +26,10 @@ margin-left: 32px; } } + + .right-side { + display: flex; + align-items: center; + gap: 16px; + } } diff --git a/src/front/Components/DesignSystem/BlockList/index.tsx b/src/front/Components/DesignSystem/BlockList/index.tsx index 2f2b7410..6ce419a3 100644 --- a/src/front/Components/DesignSystem/BlockList/index.tsx +++ b/src/front/Components/DesignSystem/BlockList/index.tsx @@ -3,11 +3,13 @@ import classes from "./classes.module.scss"; import Typography, { ITypo } from "../Typography"; import ChevronIcon from "@Assets/Icons/chevron.svg"; import Image from "next/image"; +import WarningBadge from "../WarningBadge"; export type IBlock = { name: string; id: string; selected: boolean; + hasFlag?: boolean; }; type IProps = { @@ -30,7 +32,10 @@ export default function BlockList({ blocks, onSelectedBlock }: IProps) {
{folder.name}
- chevron +
+ {folder.hasFlag && } + chevron +
); diff --git a/src/front/Components/DesignSystem/FolderListContainer/index.tsx b/src/front/Components/DesignSystem/FolderListContainer/index.tsx index 47af85be..0ac30339 100644 --- a/src/front/Components/DesignSystem/FolderListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderListContainer/index.tsx @@ -108,6 +108,7 @@ class FolderListContainerClass extends React.Component { id: folder.uid!, name: folder.folder_number! + " - " + folder.name!, selected: this.props.selectedFolder === folder.uid, + hasFlag: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), }; }); } diff --git a/src/front/Components/DesignSystem/Header/Navigation/index.tsx b/src/front/Components/DesignSystem/Header/Navigation/index.tsx index 42f6ed43..71106d0c 100644 --- a/src/front/Components/DesignSystem/Header/Navigation/index.tsx +++ b/src/front/Components/DesignSystem/Header/Navigation/index.tsx @@ -6,7 +6,7 @@ import classes from "./classes.module.scss"; import Rules, { RulesMode } from "@Front/Components/Elements/Rules"; import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule"; import { usePathname } from "next/navigation"; -import Notifications from "@Front/Api/LeCoffreApi/Notifications/Notifications"; +import Notifications from "@Front/Api/LeCoffreApi/Notary/Notifications/Notifications"; import Toasts from "@Front/Stores/Toasts"; export default function Navigation() { const pathname = usePathname(); diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index 2985328c..de5609e4 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -1,5 +1,4 @@ "use client"; -import Customers from "@Front/Api/LeCoffreApi/Customer/Customers/Customers"; import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/Customer/Documents/Documents"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import DepositDocument from "@Front/Components/DesignSystem/DepositDocument"; @@ -10,7 +9,7 @@ import React, { useCallback, useEffect, useState } from "react"; import classes from "./classes.module.scss"; import { useRouter } from "next/router"; -import JwtService from "@Front/Services/JwtService/JwtService"; +import JwtService, { ICustomerJwtPayload } from "@Front/Services/JwtService/JwtService"; import DepositOtherDocument from "@Front/Components/DesignSystem/DepositOtherDocument"; import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders"; @@ -25,15 +24,15 @@ export default function ClientDashboard(props: IProps) { const [isAddDocumentModalVisible, setIsAddDocumentModalVisible] = useState(false); const getDocuments = useCallback(async () => { - let jwt; + let jwt: ICustomerJwtPayload | undefined;; if (typeof document !== "undefined") { - jwt = JwtService.getInstance().decodeJwt(); + jwt = JwtService.getInstance().decodeCustomerJwt(); } - if (!jwt || !jwt.email) return; - const customers = await Customers.getInstance().get({ - where: { contact: { email: jwt.email }, office_folders: { some: { uid: folderUid } } }, - }); - const actualCustomer: Customer = customers[0]!; + + const folder = await Folders.getInstance().getByUid(folderUid as string, { q: { office: true, customers: true } }); + console.log(folder) + const actualCustomer = folder?.customers?.find((customer) => customer.uid === jwt?.customerId); + if(!actualCustomer) throw new Error("Customer not found"); const query: IGetDocumentsparams = { where: { depositor: { uid: actualCustomer.uid }, folder_uid: folderUid as string }, @@ -47,7 +46,8 @@ export default function ClientDashboard(props: IProps) { const documentList = await Documents.getInstance().get(query); - const folder = await Folders.getInstance().getByUid(folderUid as string, { q: { office: true } }); + //const folder = await Folders.getInstance().getByUid(folderUid as string, { q: { office: true, customers: true } }); + setFolder(folder); setDocuments(documentList); setCustomer(actualCustomer); @@ -67,7 +67,6 @@ export default function ClientDashboard(props: IProps) { }, [folderUid, getDocuments]); const renderHeader = useCallback(() => { - console.log("Dossier : ", customer); return (
diff --git a/src/front/Components/Layouts/ClientDashboard/index2.tsx b/src/front/Components/Layouts/ClientDashboard/index2.tsx index ee472c3e..226c45d1 100644 --- a/src/front/Components/Layouts/ClientDashboard/index2.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index2.tsx @@ -1,5 +1,4 @@ -import Customers from "@Front/Api/LeCoffreApi/Customer/Customers/Customers"; -import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/Customer/Documents/Documents"; +//import Customers from "@Front/Api/LeCoffreApi/Customer/Customers/Customers"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import DepositDocument from "@Front/Components/DesignSystem/DepositDocument"; import TextField from "@Front/Components/DesignSystem/Form/TextField"; @@ -11,7 +10,6 @@ import Customer, { Document, DocumentType } from "le-coffre-resources/dist/Custo import React from "react"; import classes from "./classes.module.scss"; -import JwtService from "@Front/Services/JwtService/JwtService"; type IProps = {}; type IState = { @@ -109,27 +107,27 @@ export default class ClientDashboard extends Base { ); } - public override async componentDidMount() { - // TODO Get documents of the current customer according to userStore - // REMOVE this mock + // public override async componentDidMount() { + // // TODO Get documents of the current customer according to userStore + // // REMOVE this mock - const jwt = JwtService.getInstance().decodeJwt(); - const mockedCustomers = await Customers.getInstance().get({ - where: { contact: { email: jwt?.email } }, - }); - const mockedCustomer: Customer = mockedCustomers[0]!; + // const jwt = JwtService.getInstance().decodeJwt(); + // const mockedCustomers = await Customers.getInstance().get({ + // where: { contact: { email: jwt?.email } }, + // }); + // const mockedCustomer: Customer = mockedCustomers[0]!; - const query: IGetDocumentsparams = { - where: { depositor: { uid: mockedCustomer.uid } }, - include: { - files: true, - document_history: true, - document_type: true, - }, - }; - const documents: Document[] = await Documents.getInstance().get(query); - this.setState({ documents, mockedCustomer }); - } + // const query: IGetDocumentsparams = { + // where: { depositor: { uid: mockedCustomer.uid } }, + // include: { + // files: true, + // document_history: true, + // document_type: true, + // }, + // }; + // const documents: Document[] = await Documents.getInstance().get(query); + // this.setState({ documents, mockedCustomer }); + // } private onCloseModalAddDocument() { this.setState({ isAddDocumentModalVisible: false }); diff --git a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx index c816aeea..098250b2 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/index.tsx @@ -274,7 +274,7 @@ class FolderInformationClass extends BasePage { if (!uid) return; const anchor = await OfficeFolderAnchors.getInstance().get(uid); - if (anchor.transactions[0].status !== "VERIFIED_ON_CHAIN") return; + if (anchor.status !== "VERIFIED_ON_CHAIN") return; try { const file: Blob = await OfficeFolderAnchors.getInstance().download(uid); diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index e7827e19..3dc4d9d1 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -15,7 +15,6 @@ import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; -import OcrResult from "./OcrResult"; import Files from "@Front/Api/LeCoffreApi/Notary/Files/Files"; import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField"; diff --git a/src/front/Components/Layouts/MyAccount/index.tsx b/src/front/Components/Layouts/MyAccount/index.tsx index 43863b7b..4ac8be58 100644 --- a/src/front/Components/Layouts/MyAccount/index.tsx +++ b/src/front/Components/Layouts/MyAccount/index.tsx @@ -116,10 +116,9 @@ export default class MyAccount extends Base { } public override async componentDidMount() { - const jwtUncoded = JwtService.getInstance().decodeCustomerJwt(); - console.log(jwtUncoded); - if (!jwtUncoded) return; - const user = await Users.getInstance().getByUid(jwtUncoded.userId, { + const jwtDecoded = JwtService.getInstance().decodeJwt(); + if (!jwtDecoded) return; + const user = await Users.getInstance().getByUid(jwtDecoded.userId, { q: { office_membership: { include: { diff --git a/src/front/Components/Layouts/Roles/RolesInformations/index.tsx b/src/front/Components/Layouts/Roles/RolesInformations/index.tsx index 5da3eda9..88f55e1e 100644 --- a/src/front/Components/Layouts/Roles/RolesInformations/index.tsx +++ b/src/front/Components/Layouts/Roles/RolesInformations/index.tsx @@ -45,7 +45,11 @@ export default function RolesInformations(props: IProps) { }, }); - const rules = await Rules.getInstance().get({}); + const rules = await Rules.getInstance().get({ + where: { + namespace: "notary", + }, + }); if (!role) return; setRoleSelected(role); if (!role.rules) return; @@ -124,7 +128,6 @@ export default function RolesInformations(props: IProps) { label: "Tout sélectionner", value: "all", }} - toolTip="Tout sélectionner" onChange={handleSelectAllChange} checked={selectAll} /> diff --git a/src/front/Components/Layouts/SelectFolder/index.tsx b/src/front/Components/Layouts/SelectFolder/index.tsx index 3f4f54d2..7650cc05 100644 --- a/src/front/Components/Layouts/SelectFolder/index.tsx +++ b/src/front/Components/Layouts/SelectFolder/index.tsx @@ -25,7 +25,7 @@ export default function SelectFolder() { where: { customers: { some: { - uid: jwt.userId || (jwt as any).customerId, + uid: jwt.customerId || (jwt as any).customerId, }, }, }, diff --git a/src/front/Services/JwtService/JwtService.ts b/src/front/Services/JwtService/JwtService.ts index a2fd9183..dd1dbf2c 100644 --- a/src/front/Services/JwtService/JwtService.ts +++ b/src/front/Services/JwtService/JwtService.ts @@ -20,7 +20,7 @@ export interface IUserJwtPayload { } export interface ICustomerJwtPayload { - userId: string; + customerId: string; email: string; } diff --git a/src/front/Stores/Toasts.tsx b/src/front/Stores/Toasts.tsx index 1bb11382..439e8537 100644 --- a/src/front/Stores/Toasts.tsx +++ b/src/front/Stores/Toasts.tsx @@ -1,4 +1,4 @@ -import Notifications from "@Front/Api/LeCoffreApi/Notifications/Notifications"; +import Notifications from "@Front/Api/LeCoffreApi/Notary/Notifications/Notifications"; import EventEmitter from "@Front/Services/EventEmitter"; // import I18n from "Components/Elements/I18n"; diff --git a/src/pages/login-customer.tsx b/src/pages/customer-login.tsx similarity index 100% rename from src/pages/login-customer.tsx rename to src/pages/customer-login.tsx