Merge Dev in Staging

This commit is contained in:
Arnaud D. Natali 2023-09-29 17:25:31 +02:00 committed by GitHub
commit 0fd6c35f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 74 additions and 180 deletions

28
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -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<Customer[]> {
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<Customer[]>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
public async getByUid(uid: string, q?: any): Promise<Customer> {
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<Customer>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
}

View File

@ -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<User[]> {
const url = new URL(this.baseURl);
try {
return await this.getRequest<User[]>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
public async getOne(uid: string): Promise<User> {
const url = new URL(this.baseURl.concat("/").concat(uid));
try {
return await this.getRequest<User>(url);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
// public async post(params: User): Promise<User> {
// const url = new URL(this.baseURl);
// try {
// return await this.postRequest<User>(url, params);
// } catch (err) {
// this.onError(err);
// return Promise.reject(err);
// }
// }
}

View File

@ -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();

View File

@ -26,4 +26,10 @@
margin-left: 32px;
}
}
.right-side {
display: flex;
align-items: center;
gap: 16px;
}
}

View File

@ -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) {
<div className={classes["left-side"]}>
<Typography typo={ITypo.P_16}>{folder.name}</Typography>
</div>
<Image alt="chevron" src={ChevronIcon} />
<div className={classes["right-side"]}>
{folder.hasFlag && <WarningBadge />}
<Image alt="chevron" src={ChevronIcon} />
</div>
</div>
</div>
);

View File

@ -108,6 +108,7 @@ class FolderListContainerClass extends React.Component<IPropsClass, IState> {
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),
};
});
}

View File

@ -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();

View File

@ -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<boolean>(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 (
<div className={classes["header"]}>
<div className={classes["text-container"]}>

View File

@ -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<IProps, IState> {
);
}
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 });

View File

@ -274,7 +274,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
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);

View File

@ -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";

View File

@ -116,10 +116,9 @@ export default class MyAccount extends Base<IProps, IState> {
}
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: {

View File

@ -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}
/>

View File

@ -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,
},
},
},

View File

@ -20,7 +20,7 @@ export interface IUserJwtPayload {
}
export interface ICustomerJwtPayload {
userId: string;
customerId: string;
email: string;
}

View File

@ -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";