update middleware and add correct namespace for API
This commit is contained in:
parent
ecf4f9ddb3
commit
3012d5045e
@ -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.69",
|
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.71",
|
||||||
"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,4 +1,4 @@
|
|||||||
import { DocumentType } from "le-coffre-resources/dist/SuperAdmin";
|
import { DocumentType } from "le-coffre-resources/dist/Admin";
|
||||||
|
|
||||||
import BaseAdmin from "../BaseAdmin";
|
import BaseAdmin from "../BaseAdmin";
|
||||||
|
|
||||||
|
90
src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
90
src/front/Api/LeCoffreApi/Notary/Customers/Customers.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { Contact, Customer } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
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 BaseNotary {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Customer
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Customer>(url, body);
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutCustomersParams): Promise<Customer> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Customer>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
src/front/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
84
src/front/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes.ts
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
export type IPutDeedTypesParams = {
|
||||||
|
uid?: DeedType["uid"];
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
deed?: DeedType["deed"];
|
||||||
|
office?: DeedType["office"];
|
||||||
|
archived_at?: DeedType["archived_at"];
|
||||||
|
document_types?: DeedType["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPostDeedTypesParams = {
|
||||||
|
name?: DeedType["name"];
|
||||||
|
description?: DeedType["description"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IGetDeedTypesParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class DeedTypes extends BaseNotary {
|
||||||
|
private static instance: DeedTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deed-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new DeedTypes();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q?: IGetDeedTypesParams): Promise<DeedType[]> {
|
||||||
|
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<DeedType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DeedType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DeedType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async post(body: IPostDeedTypesParams) {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DeedType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
72
src/front/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
72
src/front/Api/LeCoffreApi/Notary/Deeds/Deeds.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import { Deed, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseAdmin from "../BaseNotary";
|
||||||
|
|
||||||
|
export type IGetDeedsParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IPutDeedsParams = {
|
||||||
|
uid?: OfficeFolder["uid"];
|
||||||
|
folder_number?: OfficeFolder["folder_number"];
|
||||||
|
name?: OfficeFolder["name"];
|
||||||
|
description?: OfficeFolder["description"];
|
||||||
|
archived_description?: OfficeFolder["archived_description"];
|
||||||
|
status?: OfficeFolder["status"];
|
||||||
|
document_types?: Deed["document_types"];
|
||||||
|
};
|
||||||
|
|
||||||
|
export default class Deeds extends BaseAdmin {
|
||||||
|
private static instance: Deeds;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/deeds");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new Deeds();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDeedsParams): Promise<Deed[]> {
|
||||||
|
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<Deed[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Deed>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: IPutDeedsParams): Promise<Deed> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Deed>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
import { DocumentType } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentTypesparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentTypesParams = {};
|
||||||
|
|
||||||
|
export interface IPostDocumentTypesParams {
|
||||||
|
name: string;
|
||||||
|
public_description: string;
|
||||||
|
private_description: string | null;
|
||||||
|
office?: {
|
||||||
|
uid?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class DocumentTypes extends BaseNotary {
|
||||||
|
private static instance: DocumentTypes;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/document-types");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentTypesparams): Promise<DocumentType[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<DocumentType[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: IPostDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<DocumentType>(url, body as any);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<DocumentType> {
|
||||||
|
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<DocumentType>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentTypesParams): Promise<DocumentType> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<DocumentType>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
src/front/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
93
src/front/Api/LeCoffreApi/Notary/Documents/Documents.ts
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
import { Document } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
import BaseNotary from "../BaseNotary";
|
||||||
|
|
||||||
|
// TODO Type get query params -> Where + inclue + orderby
|
||||||
|
export interface IGetDocumentsparams {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Type getbyuid query params
|
||||||
|
|
||||||
|
export type IPutDocumentsParams = {
|
||||||
|
document_status?: EDocumentStatus;
|
||||||
|
refused_reason?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface IPostDocumentsParams {}
|
||||||
|
|
||||||
|
export default class Documents extends BaseNotary {
|
||||||
|
private static instance: Documents;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/documents");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async get(q: IGetDocumentsparams): Promise<Document[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<Document[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a Document
|
||||||
|
*/
|
||||||
|
public async post(body: any): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<Document> {
|
||||||
|
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<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest<Document>(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async delete(uid: string): Promise<Document> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest<Document>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
119
src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
119
src/front/Api/LeCoffreApi/Notary/Folders/Folders.ts
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
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 {
|
||||||
|
q?: {
|
||||||
|
select?: {};
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Folders extends BaseNotary {
|
||||||
|
private static instance: Folders;
|
||||||
|
private readonly baseURl = this.namespaceUrl.concat("/folders");
|
||||||
|
|
||||||
|
private constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
if (!this.instance) {
|
||||||
|
return new this();
|
||||||
|
} else {
|
||||||
|
return this.instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get all folders
|
||||||
|
*/
|
||||||
|
public async get(q: IGetFoldersParams): Promise<OfficeFolder[]> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder[]>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Get a folder by uid
|
||||||
|
*/
|
||||||
|
public async getByUid(uid: string, q?: any): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
if (q) Object.entries(q).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
|
try {
|
||||||
|
return await this.getRequest<OfficeFolder>(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Create a folder
|
||||||
|
*/
|
||||||
|
public async post(officeFolder: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl);
|
||||||
|
try {
|
||||||
|
return await this.postRequest(url, officeFolder);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Update the folder description
|
||||||
|
*/
|
||||||
|
public async put(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
try {
|
||||||
|
return await this.putRequest(url, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description : Delete a folder only if the folder don't contains customers
|
||||||
|
*/
|
||||||
|
public async delete(uid: string): Promise<OfficeFolder> {
|
||||||
|
const url = new URL(this.baseURl.concat(`/${uid}`));
|
||||||
|
const targetedFolder = await this.getByUid(uid);
|
||||||
|
if (targetedFolder.customers) return Promise.reject(`The folder ${uid} contains customers`);
|
||||||
|
try {
|
||||||
|
return await this.deleteRequest(url);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async archive(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
body.status = EFolderStatus.ARCHIVED;
|
||||||
|
try {
|
||||||
|
return await this.put(uid, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async restore(uid: string, body: Partial<OfficeFolder>): Promise<OfficeFolder> {
|
||||||
|
body.status = EFolderStatus.LIVE;
|
||||||
|
try {
|
||||||
|
return await this.put(uid, body);
|
||||||
|
} catch (err) {
|
||||||
|
this.onError(err);
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,15 @@
|
|||||||
import BaseNotary from "../BaseNotary";
|
import BaseNotary from "../BaseNotary";
|
||||||
import User from "le-coffre-resources/dist/Notary";
|
import User from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
|
export type IGetUsersParams = {
|
||||||
|
where?: {};
|
||||||
|
include?: {};
|
||||||
|
select?: {};
|
||||||
|
};
|
||||||
|
|
||||||
export default class Users extends BaseNotary {
|
export default class Users extends BaseNotary {
|
||||||
private static instance: Users;
|
private static instance: Users;
|
||||||
private readonly baseURl = this.namespaceUrl.concat("/Users");
|
private readonly baseURl = this.namespaceUrl.concat("/users");
|
||||||
|
|
||||||
private constructor() {
|
private constructor() {
|
||||||
super();
|
super();
|
||||||
@ -17,8 +23,10 @@ export default class Users extends BaseNotary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async get(): Promise<User[]> {
|
public async get(q?: IGetUsersParams): Promise<User[]> {
|
||||||
const url = new URL(this.baseURl);
|
const url = new URL(this.baseURl);
|
||||||
|
const query = { q };
|
||||||
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
try {
|
try {
|
||||||
return await this.getRequest<User[]>(url);
|
return await this.getRequest<User[]>(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -27,21 +35,6 @@ export default class Users extends BaseNotary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getAuthorizationCode(): Promise<any> {
|
|
||||||
try {
|
|
||||||
const url = new URL(`https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1?
|
|
||||||
client_id=4501646203F3EF67
|
|
||||||
&redirect_uri=https://app.stg.lecoffre.smart-chain.fr/
|
|
||||||
&scope=openid,profile,offline_access
|
|
||||||
&response_type=code`);
|
|
||||||
// const url = new URL("https://jsonplaceholder.typicode.com/todos/1");
|
|
||||||
await this.getRequest(url);
|
|
||||||
} catch (err) {
|
|
||||||
this.onError(err);
|
|
||||||
return Promise.reject(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async getByUid(uid: string): Promise<User> {
|
public async getByUid(uid: string): Promise<User> {
|
||||||
const url = new URL(this.baseURl.concat("/").concat(uid));
|
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||||
try {
|
try {
|
||||||
@ -51,14 +44,4 @@ export default class Users extends BaseNotary {
|
|||||||
return Promise.reject(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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -4,28 +4,28 @@ import Typography, { ITypo } from "../Typography";
|
|||||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
||||||
export type IFolder = {
|
export type IBlock = {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
list: IFolder[];
|
blocks: IBlock[];
|
||||||
onSelectedFolder: (block: IFolder) => void;
|
onSelectedBlock: (block: IBlock) => void;
|
||||||
};
|
};
|
||||||
export default function FolderList({ list, onSelectedFolder }: IProps) {
|
export default function BlockList({ blocks, onSelectedBlock }: IProps) {
|
||||||
const selectFolder = useCallback(
|
const selectBlock = useCallback(
|
||||||
(e: React.MouseEvent<HTMLDivElement>) => {
|
(e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
onSelectedFolder && onSelectedFolder(list.find((folder) => folder.id === e.currentTarget.id)!);
|
onSelectedBlock && onSelectedBlock(blocks.find((folder) => folder.id === e.currentTarget.id)!);
|
||||||
},
|
},
|
||||||
[list, onSelectedFolder],
|
[blocks, onSelectedBlock],
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{list.map((folder) => {
|
{blocks.map((folder) => {
|
||||||
return (
|
return (
|
||||||
<div onClick={selectFolder} key={folder.id} id={folder.id}>
|
<div onClick={selectBlock} key={folder.id} id={folder.id}>
|
||||||
<div className={classes["root"]} data-selected={folder.selected.toString()}>
|
<div className={classes["root"]} data-selected={folder.selected.toString()}>
|
||||||
<div className={classes["left-side"]}>
|
<div className={classes["left-side"]}>
|
||||||
<Typography typo={ITypo.P_16}>{folder.name}</Typography>
|
<Typography typo={ITypo.P_16}>{folder.name}</Typography>
|
||||||
|
@ -7,7 +7,7 @@ import BackArrow from "@Front/Components/Elements/BackArrow";
|
|||||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
import WindowStore from "@Front/Stores/WindowStore";
|
import WindowStore from "@Front/Stores/WindowStore";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import User from "le-coffre-resources/dist/Notary";
|
import User from "le-coffre-resources/dist/Admin";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import React, { ReactNode } from "react";
|
import React, { ReactNode } from "react";
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||||
import DeedTypes, { IGetDeedTypesParams } from "@Front/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes";
|
import DeedTypes, { IGetDeedTypesParams } from "@Front/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Header from "@Front/Components/DesignSystem/Header";
|
import Header from "@Front/Components/DesignSystem/Header";
|
||||||
import Version from "@Front/Components/DesignSystem/Version";
|
import Version from "@Front/Components/DesignSystem/Version";
|
||||||
import BackArrow from "@Front/Components/Elements/BackArrow";
|
import BackArrow from "@Front/Components/Elements/BackArrow";
|
||||||
import WindowStore from "@Front/Stores/WindowStore";
|
import WindowStore from "@Front/Stores/WindowStore";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Deed, DeedType } from "le-coffre-resources/dist/Admin";
|
import { Deed, DeedType } from "le-coffre-resources/dist/Notary";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import React, { ReactNode } from "react";
|
import React, { ReactNode } from "react";
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||||
import DocumentTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes";
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Header from "@Front/Components/DesignSystem/Header";
|
import Header from "@Front/Components/DesignSystem/Header";
|
||||||
import Version from "@Front/Components/DesignSystem/Version";
|
import Version from "@Front/Components/DesignSystem/Version";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||||
import Folders, { IGetFoldersParams } from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
|
import Folders, { IGetFoldersParams } from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import FolderListContainer from "@Front/Components/DesignSystem/FolderListContainer";
|
import FolderListContainer from "@Front/Components/DesignSystem/FolderListContainer";
|
||||||
import Header from "@Front/Components/DesignSystem/Header";
|
import Header from "@Front/Components/DesignSystem/Header";
|
||||||
|
@ -6,7 +6,7 @@ import Version from "@Front/Components/DesignSystem/Version";
|
|||||||
import BackArrow from "@Front/Components/Elements/BackArrow";
|
import BackArrow from "@Front/Components/Elements/BackArrow";
|
||||||
import WindowStore from "@Front/Stores/WindowStore";
|
import WindowStore from "@Front/Stores/WindowStore";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import User from "le-coffre-resources/dist/Notary";
|
import User from "le-coffre-resources/dist/SuperAdmin";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import React, { ReactNode } from "react";
|
import React, { ReactNode } from "react";
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import DocumentTypes from "@Front/Api/LeCoffreApi/Admin/DocumentTypes/DocumentTypes";
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||||
@ -8,7 +8,7 @@ import DefaultDocumentTypesDashboard from "@Front/Components/LayoutTemplates/Def
|
|||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
import { validateOrReject, ValidationError } from "class-validator";
|
import { validateOrReject, ValidationError } from "class-validator";
|
||||||
import { DocumentType, Office } from "le-coffre-resources/dist/Admin";
|
import { DocumentType, Office } from "le-coffre-resources/dist/Notary";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
@ -24,11 +24,12 @@ export default function DocumentTypesCreate(props: IProps) {
|
|||||||
try {
|
try {
|
||||||
const jwt = JwtService.getInstance().decodeJwt();
|
const jwt = JwtService.getInstance().decodeJwt();
|
||||||
if (!jwt) return;
|
if (!jwt) return;
|
||||||
|
const office = Office.hydrate<Office>({
|
||||||
|
uid: jwt.office_Id,
|
||||||
|
});
|
||||||
const documentToCreate = DocumentType.hydrate<DocumentType>({
|
const documentToCreate = DocumentType.hydrate<DocumentType>({
|
||||||
...values,
|
...values,
|
||||||
office: Office.hydrate<Office>({
|
office: office
|
||||||
uid: jwt.office_Id,
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
await validateOrReject(documentToCreate, { groups: ["createDocumentType"] });
|
await validateOrReject(documentToCreate, { groups: ["createDocumentType"] });
|
||||||
const documentTypeCreated = await DocumentTypes.getInstance().post(documentToCreate);
|
const documentTypeCreated = await DocumentTypes.getInstance().post(documentToCreate);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import DocumentTypes from "@Front/Api/LeCoffreApi/Admin/DocumentTypes/DocumentTypes";
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||||
@ -7,7 +7,7 @@ import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
|||||||
import DefaultDocumentTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDocumentTypesDashboard";
|
import DefaultDocumentTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDocumentTypesDashboard";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { validateOrReject } from "class-validator";
|
import { validateOrReject } from "class-validator";
|
||||||
import { DocumentType } from "le-coffre-resources/dist/Admin";
|
import { DocumentType } from "le-coffre-resources/dist/Notary";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import PenICon from "@Assets/Icons/pen.svg";
|
import PenICon from "@Assets/Icons/pen.svg";
|
||||||
import DocumentTypes from "@Front/Api/LeCoffreApi/Admin/DocumentTypes/DocumentTypes";
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
import DefaultDocumentTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDocumentTypesDashboard";
|
import DefaultDocumentTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDocumentTypesDashboard";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { DocumentType } from "le-coffre-resources/dist/Admin";
|
import { DocumentType } from "le-coffre-resources/dist/Notary";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers";
|
import Customers from "@Front/Api/LeCoffreApi/Notary/Customers/Customers";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/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 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";
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import PlusIcon from "@Assets/Icons/plus.svg";
|
import PlusIcon from "@Assets/Icons/plus.svg";
|
||||||
import Deeds from "@Front/Api/LeCoffreApi/SuperAdmin/Deeds/Deeds";
|
import Deeds from "@Front/Api/LeCoffreApi/Notary/Deeds/Deeds";
|
||||||
import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents";
|
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
||||||
import DocumentTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DocumentTypes/DocumentTypes";
|
import DocumentTypes from "@Front/Api/LeCoffreApi/Notary/DocumentTypes/DocumentTypes";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/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";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import backgroundImage from "@Assets/images/404-background-image.jpeg";
|
import backgroundImage from "@Assets/images/404-background-image.jpeg";
|
||||||
import DeedTypes from "@Front/Api/LeCoffreApi/SuperAdmin/DeedTypes/DeedTypes";
|
import DeedTypes from "@Front/Api/LeCoffreApi/Notary/DeedTypes/DeedTypes";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
|
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||||
import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users";
|
import Users from "@Front/Api/LeCoffreApi/Notary/Users/Users";
|
||||||
import Button from "@Front/Components/DesignSystem/Button";
|
import Button from "@Front/Components/DesignSystem/Button";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import SelectField, { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
|
import SelectField, { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
|
||||||
@ -152,13 +152,8 @@ class CreateFolderClass extends BasePage<IPropsClass, IState> {
|
|||||||
|
|
||||||
public override async componentDidMount() {
|
public override async componentDidMount() {
|
||||||
const deedTypes = await DeedTypes.getInstance().get();
|
const deedTypes = await DeedTypes.getInstance().get();
|
||||||
|
// no need to pass query 'where' param here, default query for notaries include only users which are in the same office as the caller
|
||||||
// TODO SETUP userStore and get the user's office membership -> Replace IwJ70M471c by the user's office membership uid
|
|
||||||
const usersMock = await Users.getInstance().get({ include: { office_membership: true } });
|
|
||||||
const userMock = usersMock[0];
|
|
||||||
// -------------------
|
|
||||||
const collaborators = await Users.getInstance().get({
|
const collaborators = await Users.getInstance().get({
|
||||||
where: { office_membership: { uid: userMock?.office_membership?.uid } },
|
|
||||||
include: { contact: true },
|
include: { contact: true },
|
||||||
});
|
});
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/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 FolderBoxInformation, { EFolderBoxInformationType } from "@Front/Components/DesignSystem/FolderBoxInformation";
|
import FolderBoxInformation, { EFolderBoxInformationType } from "@Front/Components/DesignSystem/FolderBoxInformation";
|
||||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Customers from "@Front/Api/LeCoffreApi/SuperAdmin/Customers/Customers";
|
import Customers from "@Front/Api/LeCoffreApi/Notary/Customers/Customers";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
import TextField from "@Front/Components/DesignSystem/Form/TextField";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders";
|
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||||
import Users, { IGetUsersparams } from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users";
|
import Users, { IGetUsersParams } from "@Front/Api/LeCoffreApi/Notary/Users/Users";
|
||||||
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
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";
|
||||||
@ -127,10 +127,8 @@ class UpdateFolderCollaboratorsClass extends BasePage<IPropsClass, IState> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userQuery: IGetUsersparams = {
|
// no need to pass query 'where' param here, default query for notaries include only users which are in the same office as the caller
|
||||||
where: {
|
const userQuery: IGetUsersParams = {
|
||||||
office_uid: folder.office?.uid,
|
|
||||||
},
|
|
||||||
include: {
|
include: {
|
||||||
contact: {
|
contact: {
|
||||||
select: {
|
select: {
|
||||||
@ -142,6 +140,7 @@ class UpdateFolderCollaboratorsClass extends BasePage<IPropsClass, IState> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const availableCollaborators = await Users.getInstance().get(userQuery);
|
const availableCollaborators = await Users.getInstance().get(userQuery);
|
||||||
|
console.log(availableCollaborators)
|
||||||
this.setState({ availableCollaborators });
|
this.setState({ availableCollaborators });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/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 Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/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 Form from "@Front/Components/DesignSystem/Form";
|
import Form from "@Front/Components/DesignSystem/Form";
|
||||||
import Select, { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
|
import Select, { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import LeftArrowIcon from "@Assets/Icons/left-arrow.svg";
|
import LeftArrowIcon from "@Assets/Icons/left-arrow.svg";
|
||||||
import RightArrowIcon from "@Assets/Icons/right-arrow.svg";
|
import RightArrowIcon from "@Assets/Icons/right-arrow.svg";
|
||||||
import Documents from "@Front/Api/LeCoffreApi/SuperAdmin/Documents/Documents";
|
import Documents from "@Front/Api/LeCoffreApi/Notary/Documents/Documents";
|
||||||
import ValidateAnchoringGif from "@Front/Assets/images/validate_anchoring.gif";
|
import ValidateAnchoringGif from "@Front/Assets/images/validate_anchoring.gif";
|
||||||
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";
|
||||||
@ -9,8 +9,8 @@ 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 DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { Document, File } from "le-coffre-resources/dist/Customer";
|
import { Document, File } from "le-coffre-resources/dist/Notary";
|
||||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { NextRouter, useRouter } from "next/router";
|
import { NextRouter, useRouter } from "next/router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
import ChevronIcon from "@Assets/Icons/chevron.svg";
|
||||||
import Folders from "@Front/Api/LeCoffreApi/SuperAdmin/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 FolderBoxInformation, { EFolderBoxInformationType } from "@Front/Components/DesignSystem/FolderBoxInformation";
|
import FolderBoxInformation, { EFolderBoxInformationType } from "@Front/Components/DesignSystem/FolderBoxInformation";
|
||||||
import QuantityProgressBar from "@Front/Components/DesignSystem/QuantityProgressBar";
|
import QuantityProgressBar from "@Front/Components/DesignSystem/QuantityProgressBar";
|
||||||
|
@ -19,7 +19,7 @@ export default function Login() {
|
|||||||
const redirectUserOnConnection = useCallback(() => {
|
const redirectUserOnConnection = useCallback(() => {
|
||||||
async function getUser() {
|
async function getUser() {
|
||||||
try {
|
try {
|
||||||
await UserStore.instance.connect("er3ojfdlfnd");
|
await UserStore.instance.connect("ljfeflecnmd");
|
||||||
await JwtService.getInstance().checkJwt();
|
await JwtService.getInstance().checkJwt();
|
||||||
router.push(Module.getInstance().get().modules.pages.Folder.props.path);
|
router.push(Module.getInstance().get().modules.pages.Folder.props.path);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
import Folders from "@Front/Api/LeCoffreApi/Customer/Folders/Folders";
|
||||||
import FolderList, { IFolder } from "@Front/Components/DesignSystem/BlockList";
|
import BlockList, { IBlock } from "@Front/Components/DesignSystem/BlockList";
|
||||||
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage";
|
||||||
import { OfficeFolder } from "le-coffre-resources/dist/Customer";
|
import { OfficeFolder } from "le-coffre-resources/dist/Customer";
|
||||||
@ -16,15 +16,16 @@ export default function SelectFolder() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getFolders() {
|
async function getFolders() {
|
||||||
const jwt = JwtService.getInstance().decodeJwt();
|
const jwt = JwtService.getInstance().decodeCustomerJwt();
|
||||||
if (!jwt) return;
|
if (!jwt) return;
|
||||||
|
console.log(jwt)
|
||||||
|
|
||||||
const folders = await Folders.getInstance().get({
|
const folders = await Folders.getInstance().get({
|
||||||
q: {
|
q: {
|
||||||
where: {
|
where: {
|
||||||
customers: {
|
customers: {
|
||||||
some: {
|
some: {
|
||||||
uid: jwt.userId,
|
uid: jwt.customerId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -36,8 +37,8 @@ export default function SelectFolder() {
|
|||||||
getFolders();
|
getFolders();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSelectFolder = useCallback(
|
const handleSelectBlock = useCallback(
|
||||||
(folder: IFolder) => {
|
(folder: IBlock) => {
|
||||||
router.push("/client-dashboard/" + folder.id);
|
router.push("/client-dashboard/" + folder.id);
|
||||||
},
|
},
|
||||||
[router],
|
[router],
|
||||||
@ -51,9 +52,9 @@ export default function SelectFolder() {
|
|||||||
<Typography typo={ITypo.H1}>Vos dossiers</Typography>
|
<Typography typo={ITypo.H1}>Vos dossiers</Typography>
|
||||||
</div>
|
</div>
|
||||||
<div className={classes["folders-container"]}>
|
<div className={classes["folders-container"]}>
|
||||||
<FolderList
|
<BlockList
|
||||||
onSelectedFolder={handleSelectFolder}
|
onSelectedBlock={handleSelectBlock}
|
||||||
list={folders.map((folder) => {
|
blocks={folders.map((folder) => {
|
||||||
return {
|
return {
|
||||||
id: folder.uid!,
|
id: folder.uid!,
|
||||||
name: folder.name!,
|
name: folder.name!,
|
||||||
|
@ -38,6 +38,12 @@ export default class JwtService {
|
|||||||
return jwt_decode(accessToken);
|
return jwt_decode(accessToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public decodeCustomerJwt(): ICustomerJwtPayload | undefined {
|
||||||
|
const accessToken = CookieService.getInstance().getCookie("leCoffreAccessToken");
|
||||||
|
if (!accessToken) return;
|
||||||
|
return jwt_decode(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description : set a cookie with a name and a value that expire in 7 days
|
* @description : set a cookie with a name and a value that expire in 7 days
|
||||||
* @throws {Error} If the name or the value is empty
|
* @throws {Error} If the name or the value is empty
|
||||||
|
@ -12,7 +12,7 @@ export async function middleware(request: NextRequest) {
|
|||||||
const requestUrlPath = request.nextUrl.pathname;
|
const requestUrlPath = request.nextUrl.pathname;
|
||||||
if (
|
if (
|
||||||
requestUrlPath.startsWith("/collaborators") ||
|
requestUrlPath.startsWith("/collaborators") ||
|
||||||
requestUrlPath.startsWith("/document-types") ||
|
requestUrlPath.startsWith("/deed-types") ||
|
||||||
requestUrlPath.startsWith("/customer") ||
|
requestUrlPath.startsWith("/customer") ||
|
||||||
requestUrlPath.startsWith("/offices") ||
|
requestUrlPath.startsWith("/offices") ||
|
||||||
requestUrlPath.startsWith("/roles") ||
|
requestUrlPath.startsWith("/roles") ||
|
||||||
@ -21,7 +21,7 @@ export async function middleware(request: NextRequest) {
|
|||||||
if (userDecodedToken.role !== "admin" && userDecodedToken.role !== "super-admin")
|
if (userDecodedToken.role !== "admin" && userDecodedToken.role !== "super-admin")
|
||||||
return NextResponse.redirect(new URL("/404", request.url));
|
return NextResponse.redirect(new URL("/404", request.url));
|
||||||
}
|
}
|
||||||
if (requestUrlPath.startsWith("/my-account") && !userDecodedToken) return NextResponse.redirect(new URL("/404", request.url));
|
if ((requestUrlPath.startsWith("/my-account") || requestUrlPath.startsWith("/document-types")) && !userDecodedToken) return NextResponse.redirect(new URL("/404", request.url));
|
||||||
if (requestUrlPath.startsWith("/client-dashboard") && !customerDecodedToken) return NextResponse.redirect(new URL("/404", request.url));
|
if (requestUrlPath.startsWith("/client-dashboard") && !customerDecodedToken) return NextResponse.redirect(new URL("/404", request.url));
|
||||||
|
|
||||||
return NextResponse.next();
|
return NextResponse.next();
|
||||||
@ -33,6 +33,7 @@ export const config = {
|
|||||||
"/collaborators/:path*",
|
"/collaborators/:path*",
|
||||||
"/customer/:path*",
|
"/customer/:path*",
|
||||||
"/document-types/:path*",
|
"/document-types/:path*",
|
||||||
|
"/deed-types/:path*",
|
||||||
"/folders/:path*",
|
"/folders/:path*",
|
||||||
"/my-account/:path*",
|
"/my-account/:path*",
|
||||||
"/offices/:path*",
|
"/offices/:path*",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user