From f134d115cda0d82cc668528d0c770778d69111f3 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 10 May 2023 19:34:35 +0200 Subject: [PATCH 01/10] :bug: Fixing env variables --- next.config.js | 17 ++++++++--------- src/front/Api/BaseApiService.ts | 1 - src/pages/_app.tsx | 33 +++++++++++++++++---------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/next.config.js b/next.config.js index 898d4a52..4a45c7f6 100644 --- a/next.config.js +++ b/next.config.js @@ -4,15 +4,14 @@ const nextConfig = { reactStrictMode: false, publicRuntimeConfig: { // Will be available on both server and client - BACK_API_PROTOCOL: process.env.BACK_API_PROTOCOL, - BACK_API_HOST: process.env.BACK_API_HOST, - BACK_API_PORT: process.env.BACK_API_PORT, - BACK_API_ROOT_URL: process.env.BACK_API_ROOT_URL, - BACK_API_VERSION: process.env.BACK_API_VERSION, - FRONT_APP_HOST: process.env.FRONT_APP_HOST, - FRONT_APP_PORT: process.env.FRONT_APP_PORT, - IDNOT_AUTHORIZE_ENDPOINT: process.env.IDNOT_AUTHORIZE_ENDPOINT, - IDNOT_CLIENT_ID: process.env.IDNOT_CLIENT_ID, + BACK_API_PROTOCOL: process.env.NEXT_PUBLIC_BACK_API_PROTOCOL, + BACK_API_HOST: process.env.NEXT_PUBLIC_BACK_API_HOST, + BACK_API_ROOT_URL: process.env.NEXT_PUBLIC_BACK_API_ROOT_URL, + BACK_API_VERSION: process.env.NEXT_PUBLIC_BACK_API_VERSION, + FRONT_APP_HOST: process.env.NEXT_PUBLIC_FRONT_APP_HOST, + FRONT_APP_PORT: process.env.NEXT_PUBLIC_FRONT_APP_PORT, + IDNOT_AUTHORIZE_ENDPOINT: process.env.NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT, + IDNOT_CLIENT_ID: process.env.NEXT_PUBLIC_IDNOT_CLIENT_ID, }, }; diff --git a/src/front/Api/BaseApiService.ts b/src/front/Api/BaseApiService.ts index f3786452..2992b609 100644 --- a/src/front/Api/BaseApiService.ts +++ b/src/front/Api/BaseApiService.ts @@ -17,7 +17,6 @@ export default abstract class BaseApiService { } protected getBaseUrl() { - console.log("BaseApiService.baseUrl >>> ", BaseApiService.baseUrl); return BaseApiService.baseUrl; } diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index be5cf63c..4e9c36fe 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -36,28 +36,29 @@ const MyApp = (({ }: AppPropsWithLayout) => { const getLayout = Component.getLayout ?? ((page) => ); - FrontendVariables.getInstance().BACK_API_PROTOCOL = backApiProtocol; - FrontendVariables.getInstance().BACK_API_HOST = backApiHost; - FrontendVariables.getInstance().BACK_API_ROOT_URL = backApiRootUrl; - FrontendVariables.getInstance().BACK_API_VERSION = backApiVersion; - FrontendVariables.getInstance().FRONT_APP_HOST = frontAppHost; - FrontendVariables.getInstance().FRONT_APP_PORT = frontAppPort; - FrontendVariables.getInstance().IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint; - FrontendVariables.getInstance().IDNOT_CLIENT_ID = idNotClientId; + const instance = FrontendVariables.getInstance(); + instance.BACK_API_PROTOCOL = backApiProtocol; + instance.BACK_API_HOST = backApiHost; + instance.BACK_API_ROOT_URL = backApiRootUrl; + instance.BACK_API_VERSION = backApiVersion; + instance.FRONT_APP_HOST = frontAppHost; + instance.FRONT_APP_PORT = frontAppPort; + instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint; + instance.IDNOT_CLIENT_ID = idNotClientId; return getLayout(); }) as AppType; MyApp.getInitialProps = async () => { return { - backApiProtocol: process.env["BACK_API_PROTOCOL"], - backApiHost: process.env["BACK_API_HOST"], - backApiRootUrl: process.env["BACK_API_ROOT_URL"], - backApiVersion: process.env["BACK_API_VERSION"], - frontAppHost: process.env["FRONT_APP_HOST"], - frontAppPort: process.env["FRONT_APP_PORT"], - idNotAuthorizeEndpoint: process.env["IDNOT_AUTHORIZE_ENDPOINT"], - idNotClientId: process.env["IDNOT_CLIENT_ID"], + backApiProtocol: process.env["NEXT_PUBLIC_BACK_API_PROTOCOL"], + backApiHost: process.env["NEXT_PUBLIC_BACK_API_HOST"], + backApiRootUrl: process.env["NEXT_PUBLIC_BACK_API_ROOT_URL"], + backApiVersion: process.env["NEXT_PUBLIC_BACK_API_VERSION"], + frontAppHost: process.env["NEXT_PUBLIC_FRONT_APP_HOST"], + frontAppPort: process.env["NEXT_PUBLIC_FRONT_APP_PORT"], + idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"], + idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"], }; }; From 4b8ed64001f7f9f9ccd45e05f4f017834a395014 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Thu, 11 May 2023 11:13:44 +0200 Subject: [PATCH 02/10] :sparkles: Hydrating my account --- src/front/Components/Layouts/MyAccount/index.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/front/Components/Layouts/MyAccount/index.tsx b/src/front/Components/Layouts/MyAccount/index.tsx index 03d5d198..4f892401 100644 --- a/src/front/Components/Layouts/MyAccount/index.tsx +++ b/src/front/Components/Layouts/MyAccount/index.tsx @@ -25,10 +25,10 @@ export default class MyAccount extends Base {
- - - - + + + +
@@ -42,11 +42,12 @@ export default class MyAccount extends Base { name="office_denomination" fakeplaceholder="Dénomination de l'office" type="text" + defaultValue="AP NOTAIRES" disabled /> - - - + + + From 85728353a019913ec574646eca28f0301ea47967 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Thu, 11 May 2023 11:33:52 +0200 Subject: [PATCH 03/10] :bug: Links in header on client dashboard --- .../LayoutTemplates/DefaultTemplate/index.tsx | 10 ++++++---- src/front/Components/Layouts/ClientDashboard/index.tsx | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx b/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx index f6dbe5a2..938ebea7 100644 --- a/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx @@ -1,9 +1,9 @@ - -import React, { ReactNode } from "react"; -import classes from "./classes.module.scss"; import Header from "@Front/Components/DesignSystem/Header"; import Version from "@Front/Components/DesignSystem/Version"; import classNames from "classnames"; +import React, { ReactNode } from "react"; + +import classes from "./classes.module.scss"; type IProps = { title: string; @@ -13,6 +13,7 @@ type IProps = { */ scrollTop: number | null; isPadding?: boolean; + hasHeaderLinks: boolean; }; type IState = {}; @@ -20,12 +21,13 @@ export default class DefaultTemplate extends React.Component { public static defaultProps = { scrollTop: 0, isPadding: true, + hasHeaderLinks: true, }; public override render(): JSX.Element { return ( <> -
+
{this.props.children}
diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index 6fe77df4..e861b1f8 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -31,7 +31,7 @@ export default class ClientDashboard extends Base { public override render(): JSX.Element { return ( - +
{this.renderHeader()}
From 04f366611d2f6b25653c1bf3db195ade46de2e24 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Tue, 9 May 2023 17:39:25 +0200 Subject: [PATCH 04/10] add france connect authorize --- package.json | 1 + .../Api/LeCoffreApi/SuperAdmin/Files/Files.ts | 5 +++++ .../Layouts/Folder/ViewDocuments/index.tsx | 5 +++-- .../Layouts/LoginCallback/index.tsx | 20 +++++++++---------- .../Layouts/LoginCustomer/index.tsx | 12 ++++++----- src/front/Config/VariablesFront.ts | 4 ++++ src/pages/_app.tsx | 8 ++++++++ src/pages/login-callback.tsx | 5 +++++ 8 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 src/pages/login-callback.tsx diff --git a/package.json b/package.json index 8f6f84e7..0ad651d1 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@types/react-dom": "18.0.11", "class-validator": "^0.14.0", "classnames": "^2.3.2", + "crypto-random-string": "^5.0.0", "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts index 219e507c..044ed4f1 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts @@ -58,6 +58,11 @@ export default class Files extends BaseSuperAdmin { } } + public getUploadLink(uid: string): string { + return this.baseURl.concat(`/upload/${uid}`); + } + + public async getByUid(uid: string, q?: any): Promise { const url = new URL(this.baseURl.concat(`/${uid}`)); const query = { q }; diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index c8a51fb9..9db8c4fd 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -20,6 +20,7 @@ import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; import OcrResult from "./OcrResult"; +import Files from "@Front/Api/LeCoffreApi/SuperAdmin/Files/Files"; type IProps = {}; @@ -90,7 +91,7 @@ class ViewDocumentsClass extends BasePage {
)}
- +
{this.state.document.files.length > 1 && (
{ private downloadFile() { const fileName = this.state.selectedFile?.file_path?.split("/").pop(); - fetch(this.state.selectedFile?.file_path as string) + fetch(Files.getInstance().getUploadLink(this.state.selectedFile?.uid as string)) .then((resp) => resp.blob()) .then((blob) => { const url = window.URL.createObjectURL(blob); diff --git a/src/front/Components/Layouts/LoginCallback/index.tsx b/src/front/Components/Layouts/LoginCallback/index.tsx index a794066e..67732034 100644 --- a/src/front/Components/Layouts/LoginCallback/index.tsx +++ b/src/front/Components/Layouts/LoginCallback/index.tsx @@ -10,7 +10,7 @@ import { useRouter } from "next/router"; //import React, { useEffect, useState } from "react"; import React from "react"; //import Loader from "@Front/Components/DesignSystem/Loader"; -import Auth from "@Front/Api/Auth/IdNot"; +//import Auth from "@Front/Api/Auth/IdNot"; import Folder from "../Folder"; import LoginClass from "../Login"; @@ -75,15 +75,15 @@ export default function LoginCallBack(props: IPropsClass) { const router = useRouter(); const { code } = router.query; if (code) { - const getIdNotJwt = async () => { - try { - const authService = Auth.getInstance(); - await authService.getIdnotJwt(code); - } catch (error) { - console.error(error); - } - }; - getIdNotJwt(); + // const getIdNotJwt = async () => { + // try { + // const authService = Auth.getInstance(); + // await authService.getIdnotJwt(code); + // } catch (error) { + // console.error(error); + // } + // }; + //getIdNotJwt(); return ; } return ; diff --git a/src/front/Components/Layouts/LoginCustomer/index.tsx b/src/front/Components/Layouts/LoginCustomer/index.tsx index ded0c9a6..fe5938c8 100644 --- a/src/front/Components/Layouts/LoginCustomer/index.tsx +++ b/src/front/Components/Layouts/LoginCustomer/index.tsx @@ -6,6 +6,8 @@ import Image from "next/image"; import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage"; import FranceConnectIcon from "./france-connect.svg"; import ExportIcon from "@Assets/Icons/export.svg"; +import { FrontendVariables } from "@Front/Config/VariablesFront"; +import cryptoRandomString from "crypto-random-string"; export default class LoginCustomer extends BasePage { public override render(): JSX.Element { @@ -35,12 +37,12 @@ export default class LoginCustomer extends BasePage { } private redirectUserOnConnection() { - // const variables = FrontendVariables.getInstance(); + const variables = FrontendVariables.getInstance(); // const baseFronturl = // variables.BACK_API_PROTOCOL + variables.FRONT_APP_HOST + (variables.FRONT_APP_PORT ? ":" + variables.FRONT_APP_PORT : ""); - // const authorizeEndPoint = variables.IDNOT_AUTHORIZE_ENDPOINT; - // const clientId = variables.IDNOT_CLIENT_ID; - // const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=${baseFronturl}/authorized-client&scope=openid,profile,offline_access&response_type=code`; - // window.location.assign(url); + const authorizeEndPoint = variables.FC_AUTHORIZE_ENDPOINT; + const clientId = variables.FC_CLIENT_ID; + const url = `${authorizeEndPoint}?client_id=${clientId}&redirect_uri=http://localhost:8080/login-callback&scope=openid&response_type=code&state=${cryptoRandomString({length: 64})}&nonce=${cryptoRandomString({length: 64})}&acr_values=eidas1`; + window.location.assign(url); } } diff --git a/src/front/Config/VariablesFront.ts b/src/front/Config/VariablesFront.ts index dd823f32..b2d11b4f 100644 --- a/src/front/Config/VariablesFront.ts +++ b/src/front/Config/VariablesFront.ts @@ -19,6 +19,10 @@ export class FrontendVariables { public KEY_DATA!: string; + public FC_AUTHORIZE_ENDPOINT!: string; + + public FC_CLIENT_ID!: string; + private constructor() {} public static getInstance(): FrontendVariables { diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 4e9c36fe..0e6998df 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -20,6 +20,8 @@ type AppPropsWithLayout = AppProps & { frontAppPort: string; idNotAuthorizeEndpoint: string; idNotClientId: string; + fcAuthorizeEndpoint: string; + fcClientId: string; }; const MyApp = (({ @@ -33,6 +35,8 @@ const MyApp = (({ frontAppPort, idNotAuthorizeEndpoint, idNotClientId, + fcAuthorizeEndpoint, + fcClientId }: AppPropsWithLayout) => { const getLayout = Component.getLayout ?? ((page) => ); @@ -45,6 +49,8 @@ const MyApp = (({ instance.FRONT_APP_PORT = frontAppPort; instance.IDNOT_AUTHORIZE_ENDPOINT = idNotAuthorizeEndpoint; instance.IDNOT_CLIENT_ID = idNotClientId; + instance.FC_AUTHORIZE_ENDPOINT= fcAuthorizeEndpoint; + instance.FC_CLIENT_ID = fcClientId return getLayout(); }) as AppType; @@ -59,6 +65,8 @@ MyApp.getInitialProps = async () => { frontAppPort: process.env["NEXT_PUBLIC_FRONT_APP_PORT"], idNotAuthorizeEndpoint: process.env["NEXT_PUBLIC_IDNOT_AUTHORIZE_ENDPOINT"], idNotClientId: process.env["NEXT_PUBLIC_IDNOT_CLIENT_ID"], + fcAuthorizeEndpoint: process.env["NEXT_PUBLIC_FC_AUTHORIZE_ENDPOINT"], + fcClientId: process.env["NEXT_PUBLIC_FC_CLIENT_ID"] }; }; diff --git a/src/pages/login-callback.tsx b/src/pages/login-callback.tsx new file mode 100644 index 00000000..eb839556 --- /dev/null +++ b/src/pages/login-callback.tsx @@ -0,0 +1,5 @@ +import ClientDashboard from "@Front/Components/Layouts/ClientDashboard"; + +export default function Route() { + return ; +} From 4fdb6ef2108c5e4c577ddb97c25c9e920e496c12 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Thu, 11 May 2023 11:52:42 +0200 Subject: [PATCH 05/10] :sparkles: Add mailto to contact my notary --- .../Layouts/ClientDashboard/index.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index e861b1f8..0c3fe27b 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -1,3 +1,5 @@ +import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; +import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import DepositDocument from "@Front/Components/DesignSystem/DepositDocument"; import InputField from "@Front/Components/DesignSystem/Form/Elements/InputField"; @@ -5,12 +7,11 @@ import Confirm from "@Front/Components/DesignSystem/Modal/Confirm"; import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import Base from "@Front/Components/Layouts/Base"; import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; +import { Document } from "le-coffre-resources/dist/Customer"; import React from "react"; + import { documentDeposited } from "../DesignSystem/dummyData"; import classes from "./classes.module.scss"; -import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; -import { Document } from "le-coffre-resources/dist/Customer"; -import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; type IProps = {}; type IState = { @@ -37,11 +38,7 @@ export default class ClientDashboard extends Base {
{this.state.documents?.map((document) => ( - + ))}
Documents supplémentaires (facultatif) @@ -97,7 +94,9 @@ export default class ClientDashboard extends Base { l’aide du bouton ci-dessus.
- + + +
); } From ad2b89367f50021c78d8d7e616763cecfa77ef44 Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Thu, 11 May 2023 12:28:43 +0200 Subject: [PATCH 06/10] :art: patch other document --- .../SuperAdmin/DocumentTypes/DocumentTypes.ts | 18 ++++++------- .../DesignSystem/DepositDocument/index.tsx | 1 - .../Layouts/ClientDashboard/index.tsx | 27 ++++++++++--------- .../Layouts/DesignSystem/dummyData.ts | 8 +++--- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts b/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts index 7904e6e5..1e8a09af 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes.ts @@ -10,16 +10,15 @@ export interface IGetDocumentTypesparams { // TODO Type getbyuid query params -export type IPutDocumentTypesParams = { -}; +export type IPutDocumentTypesParams = {}; export interface IPostDocumentTypesParams { - name: string; - public_description: string; - private_description: string; - office: { - uid: string; - }; + name: string; + public_description: string; + private_description: string; + office: { + uid: string; + }; } export default class DocumentTypes extends BaseSuperAdmin { @@ -40,7 +39,8 @@ export default class DocumentTypes extends BaseSuperAdmin { public async get(q: IGetDocumentTypesparams): Promise { const url = new URL(this.baseURl); - Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); + 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) { diff --git a/src/front/Components/DesignSystem/DepositDocument/index.tsx b/src/front/Components/DesignSystem/DepositDocument/index.tsx index fae00235..236c10e7 100644 --- a/src/front/Components/DesignSystem/DepositDocument/index.tsx +++ b/src/front/Components/DesignSystem/DepositDocument/index.tsx @@ -144,7 +144,6 @@ export default class DepositDocument extends React.Component {
- ; ); } diff --git a/src/front/Components/Layouts/ClientDashboard/index.tsx b/src/front/Components/Layouts/ClientDashboard/index.tsx index 6fe77df4..0b6fdea4 100644 --- a/src/front/Components/Layouts/ClientDashboard/index.tsx +++ b/src/front/Components/Layouts/ClientDashboard/index.tsx @@ -6,24 +6,27 @@ import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import Base from "@Front/Components/Layouts/Base"; import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; import React from "react"; -import { documentDeposited } from "../DesignSystem/dummyData"; import classes from "./classes.module.scss"; import Documents, { IGetDocumentsparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents"; -import { Document } from "le-coffre-resources/dist/Customer"; -import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; +import Customer, { Document } from "le-coffre-resources/dist/Customer"; +import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers"; +import { document } from "./../../../Components/Layouts/DesignSystem/dummyData"; type IProps = {}; type IState = { isAddDocumentModalVisible: boolean; documents: Document[]; + mockedCustomer: Customer | null; }; export default class ClientDashboard extends Base { + private currentClient: number = 0; public constructor(props: IProps) { super(props); this.state = { isAddDocumentModalVisible: false, documents: [], + mockedCustomer: null, }; this.onCloseModalAddDocument = this.onCloseModalAddDocument.bind(this); this.onOpenModalAddDocument = this.onOpenModalAddDocument.bind(this); @@ -37,11 +40,7 @@ export default class ClientDashboard extends Base {
{this.state.documents?.map((document) => ( - + ))}
Documents supplémentaires (facultatif) @@ -69,7 +68,7 @@ export default class ClientDashboard extends Base { Glissez / Déposez votre document dans la zone prévue à cet effet ou cliquez sur la zone puis sélectionnez le document correspondant. - +
@@ -83,7 +82,7 @@ export default class ClientDashboard extends Base {
{/* TODO Get name from userStore */} - Bonjour John Doe + Bonjour {this.state.mockedCustomer?.contact?.first_name.concat(" ", this.state.mockedCustomer?.contact?.last_name)} @@ -105,9 +104,11 @@ export default class ClientDashboard extends Base { public override async componentDidMount() { // TODO Get documents of the current customer according to userStore // REMOVE this mock - const mockUsers = (await Users.getInstance().get({}))[2]; + const mockedCustomers = await Customers.getInstance().get({}); + const mockedCustomer = mockedCustomers[this.currentClient]!; + const query: IGetDocumentsparams = { - where: { depositor: mockUsers?.uid }, + where: { depositor: { uid: mockedCustomer.uid } }, include: { files: true, document_history: true, @@ -115,7 +116,7 @@ export default class ClientDashboard extends Base { }, }; const documents: Document[] = await Documents.getInstance().get(query); - this.setState({ documents }); + this.setState({ documents, mockedCustomer }); } private onCloseModalAddDocument() { diff --git a/src/front/Components/Layouts/DesignSystem/dummyData.ts b/src/front/Components/Layouts/DesignSystem/dummyData.ts index 552a023f..57157d5b 100644 --- a/src/front/Components/Layouts/DesignSystem/dummyData.ts +++ b/src/front/Components/Layouts/DesignSystem/dummyData.ts @@ -78,7 +78,7 @@ export const contact2: Contact = { }; export const docType: DocumentType = { - name: "Acte de naissance", + name: "Votre document", uid: "fezezfazegezrgrezg", created_at: new Date(), updated_at: new Date(), @@ -146,7 +146,7 @@ export const fileMock: File = { file_name: "file_1", file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/Qmf_Yb_Eh_X9st_F_Srq_Ve_Bj_Yb_Aj56xv_AV_Nj6_Wjypo_B4r5ubce_U_ae3303e7ab.pdf", - iv: "1" + iv: "1", }; export const fileMock2: File = { @@ -157,7 +157,7 @@ export const fileMock2: File = { file_name: "file_2", file_path: "https://minteed-prod-euwest3-s3.s3.eu-west-3.amazonaws.com/Qm_Wq_En1_DCA_8yt_RX_Qx_QFA_9_Fm_ZKZH_Qqb_VH_1_Q_Mnv_G_Jtt1_FS_Xp_2a35a36e19", - iv: "2" + iv: "2", }; export const identityFile: File = { @@ -167,7 +167,7 @@ export const identityFile: File = { document: document, file_name: "file_3", file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/cni_fake_c7259d4923.png", - iv: "3" + iv: "3", }; export const documentIdentity: Document = { From fa1da23eb2145ae5c358c5e1ec5032f7f54c7a4a Mon Sep 17 00:00:00 2001 From: Vincent Alamelle Date: Thu, 11 May 2023 12:39:35 +0200 Subject: [PATCH 07/10] fix iv --- package-lock.json | 38 ++++++++++++++++--- package.json | 2 +- .../Api/LeCoffreApi/SuperAdmin/Files/Files.ts | 6 --- .../Layouts/DesignSystem/dummyData.ts | 6 +-- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76839135..f10b3e4e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,11 +16,12 @@ "@types/react-dom": "18.0.11", "class-validator": "^0.14.0", "classnames": "^2.3.2", + "crypto-random-string": "^5.0.0", "dotenv": "^16.0.3", "eslint": "8.36.0", "eslint-config-next": "13.2.4", "form-data": "^4.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.44", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.47", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", @@ -1535,6 +1536,20 @@ "node": ">= 8" } }, + "node_modules/crypto-random-string": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-5.0.0.tgz", + "integrity": "sha512-KWjTXWwxFd6a94m5CdRGW/t82Tr8DoBc9dNnPCAbFI1EBweN6v1tv8y4Y1m7ndkp/nkIBRxUxAzpaBnR2k3bcQ==", + "dependencies": { + "type-fest": "^2.12.2" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/csstype": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", @@ -2551,6 +2566,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globals/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globalthis": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", @@ -3202,7 +3228,7 @@ } }, "node_modules/le-coffre-resources": { - "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#30c8ee50b872a8bc6bec0f5d8c4626d8f4490177", + "resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#467b34a484adbd6dfa3fd6082bb7677f6178da51", "license": "MIT", "dependencies": { "class-transformer": "^0.5.1", @@ -4474,11 +4500,11 @@ } }, "node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", + "integrity": "sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==", "engines": { - "node": ">=10" + "node": ">=12.20" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" diff --git a/package.json b/package.json index 0ad651d1..9ebaabbc 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "eslint": "8.36.0", "eslint-config-next": "13.2.4", "form-data": "^4.0.0", - "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.44", + "le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.47", "next": "13.2.4", "prettier": "^2.8.7", "react": "18.2.0", diff --git a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts index 044ed4f1..db4f0e7f 100644 --- a/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts +++ b/src/front/Api/LeCoffreApi/SuperAdmin/Files/Files.ts @@ -1,7 +1,6 @@ import { File } from "le-coffre-resources/dist/SuperAdmin"; import BaseSuperAdmin from "../BaseSuperAdmin"; -import CryptoService from "@Front/Services/CryptoService/CryptoService"; // TODO Type get query params -> Where + inclue + orderby @@ -20,7 +19,6 @@ export default class Files extends BaseSuperAdmin { private static instance: Files; private readonly baseURl = this.namespaceUrl.concat("/files"); - private cryptoService: CryptoService = CryptoService.getInstance(); private constructor() { super(); } @@ -35,9 +33,6 @@ export default class Files extends BaseSuperAdmin { if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); try { const files = await this.getRequest(url); - files.forEach(async (file) => { - file.file_path = await this.cryptoService.decrypt(file.file_path!, file.iv); - }); return files; } catch (err) { this.onError(err); @@ -69,7 +64,6 @@ export default class Files extends BaseSuperAdmin { if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value))); try { const file = await this.getRequest(url); - file.file_path = await this.cryptoService.decrypt(file.file_path!, file.iv); return file; } catch (err) { this.onError(err); diff --git a/src/front/Components/Layouts/DesignSystem/dummyData.ts b/src/front/Components/Layouts/DesignSystem/dummyData.ts index 552a023f..ff72876b 100644 --- a/src/front/Components/Layouts/DesignSystem/dummyData.ts +++ b/src/front/Components/Layouts/DesignSystem/dummyData.ts @@ -146,7 +146,7 @@ export const fileMock: File = { file_name: "file_1", file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/Qmf_Yb_Eh_X9st_F_Srq_Ve_Bj_Yb_Aj56xv_AV_Nj6_Wjypo_B4r5ubce_U_ae3303e7ab.pdf", - iv: "1" + archived_at: null, }; export const fileMock2: File = { @@ -157,7 +157,7 @@ export const fileMock2: File = { file_name: "file_2", file_path: "https://minteed-prod-euwest3-s3.s3.eu-west-3.amazonaws.com/Qm_Wq_En1_DCA_8yt_RX_Qx_QFA_9_Fm_ZKZH_Qqb_VH_1_Q_Mnv_G_Jtt1_FS_Xp_2a35a36e19", - iv: "2" + archived_at: null, }; export const identityFile: File = { @@ -167,7 +167,7 @@ export const identityFile: File = { document: document, file_name: "file_3", file_path: "https://minteed-stg-euwest3-s3.s3.eu-west-3.amazonaws.com/cni_fake_c7259d4923.png", - iv: "3" + archived_at: null, }; export const documentIdentity: Document = { From c4ee5111d275e7ada3c465ac48253b25f9c265cf Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Thu, 11 May 2023 14:06:28 +0200 Subject: [PATCH 08/10] fix height --- .../Components/DesignSystem/FolderList/classes.module.scss | 3 +++ src/front/Components/DesignSystem/FolderList/index.tsx | 6 +----- .../DesignSystem/FolderListContainer/classes.module.scss | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/front/Components/DesignSystem/FolderList/classes.module.scss b/src/front/Components/DesignSystem/FolderList/classes.module.scss index 0bf5be03..b6ca5e4f 100644 --- a/src/front/Components/DesignSystem/FolderList/classes.module.scss +++ b/src/front/Components/DesignSystem/FolderList/classes.module.scss @@ -1,6 +1,9 @@ @import "@Themes/constants.scss"; .root { + height: calc(100vh - 290px); + overflow: scroll; + .active { background-color: var(--grey-medium); } diff --git a/src/front/Components/DesignSystem/FolderList/index.tsx b/src/front/Components/DesignSystem/FolderList/index.tsx index d98d432c..871eb511 100644 --- a/src/front/Components/DesignSystem/FolderList/index.tsx +++ b/src/front/Components/DesignSystem/FolderList/index.tsx @@ -26,11 +26,7 @@ class FolderListClass extends React.Component { ? Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.pages.FolderInformation.props.path : Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path; public override render(): JSX.Element { - return ( -
- {this.renderFolders()} -
- ); + return
{this.renderFolders()}
; } private renderFolders(): JSX.Element[] { diff --git a/src/front/Components/DesignSystem/FolderListContainer/classes.module.scss b/src/front/Components/DesignSystem/FolderListContainer/classes.module.scss index 588e1a18..b11dc6ba 100644 --- a/src/front/Components/DesignSystem/FolderListContainer/classes.module.scss +++ b/src/front/Components/DesignSystem/FolderListContainer/classes.module.scss @@ -1,8 +1,7 @@ @import "@Themes/constants.scss"; .root { - min-height: 100%; - width: 100%; + width: calc(100vh - 83px); display: flex; flex-direction: column; justify-content: space-between; From 48a8759e95559cdf7b79b00b4e5e7f38c9edfa30 Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Thu, 11 May 2023 14:10:06 +0200 Subject: [PATCH 09/10] :art: fix format number --- .../DesignSystem/UserFolder/UserFolderHeader/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx index bdc82961..c0749243 100644 --- a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx @@ -75,6 +75,7 @@ export default class UserFolderHeader extends React.Component { private formatPhoneNumber(phoneNumber: string): string { if (!phoneNumber) return ""; + phoneNumber = phoneNumber.replace(" ", ""); const output = phoneNumber.split("").map((char, index) => { if (index % 2) return char + " "; return char; From 3df721dad0200eca841cc3c1c8663678cf506660 Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Thu, 11 May 2023 14:18:18 +0200 Subject: [PATCH 10/10] fix format phone number --- .../DesignSystem/UserFolder/UserFolderHeader/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx index c0749243..1568a2c5 100644 --- a/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx +++ b/src/front/Components/DesignSystem/UserFolder/UserFolderHeader/index.tsx @@ -75,7 +75,7 @@ export default class UserFolderHeader extends React.Component { private formatPhoneNumber(phoneNumber: string): string { if (!phoneNumber) return ""; - phoneNumber = phoneNumber.replace(" ", ""); + phoneNumber = phoneNumber.replace(/ /g, ""); const output = phoneNumber.split("").map((char, index) => { if (index % 2) return char + " "; return char;