Fix some issues
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 3m59s
All checks were successful
Build and Push to Registry / build-and-push (push) Successful in 3m59s
This commit is contained in:
parent
0f28476aed
commit
87976783a3
@ -38,7 +38,7 @@ export default abstract class AbstractService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const now = Date.now();
|
const now: number = Date.now();
|
||||||
if ((now - item.timestamp) < this.CACHE_TTL) {
|
if ((now - item.timestamp) < this.CACHE_TTL) {
|
||||||
return item.process;
|
return item.process;
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ export default abstract class AbstractService {
|
|||||||
|
|
||||||
protected static getItems(key: string): any[] {
|
protected static getItems(key: string): any[] {
|
||||||
const list: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
const list: any[] = JSON.parse(sessionStorage.getItem(key) || '[]');
|
||||||
const now = Date.now();
|
const now: number = Date.now();
|
||||||
|
|
||||||
const items: any[] = [];
|
const items: any[] = [];
|
||||||
for (const item of list) {
|
for (const item of list) {
|
||||||
|
@ -15,7 +15,7 @@ export default class CollaboratorService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createCollaborator(collaboratorData: any, validatorId: string): Promise<any> {
|
public static createCollaborator(collaboratorData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -11,7 +11,7 @@ export default class CustomerService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createCustomer(customerData: any, validatorId: string): Promise<any> {
|
public static createCustomer(customerData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -13,7 +13,7 @@ export default class DeedTypeService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createDeedType(deedTypeData: any, validatorId: string): Promise<any> {
|
public static createDeedType(deedTypeData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
@ -91,7 +91,8 @@ export default class DeedTypeService extends AbstractService {
|
|||||||
publicValues['uid'] &&
|
publicValues['uid'] &&
|
||||||
publicValues['utype'] &&
|
publicValues['utype'] &&
|
||||||
publicValues['utype'] === 'deedType' &&
|
publicValues['utype'] === 'deedType' &&
|
||||||
publicValues['isDeleted'] && publicValues['isDeleted'] === 'false' &&
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false' &&
|
||||||
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
|
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
|
||||||
).then(async (processes: any[]) => {
|
).then(async (processes: any[]) => {
|
||||||
if (processes.length === 0) {
|
if (processes.length === 0) {
|
||||||
@ -176,18 +177,20 @@ export default class DeedTypeService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static updateDeedType(process: any, newData: any): Promise<void> {
|
public static updateDeedType(process: any, newData: any): Promise<void> {
|
||||||
|
console.log(process);
|
||||||
|
|
||||||
return new Promise<void>((resolve: () => void) => {
|
return new Promise<void>((resolve: () => void) => {
|
||||||
this.messageBus.updateProcess(process.processId, { updated_at: new Date().toISOString(), ...newData }, [], null).then((processUpdated: any) => {
|
this.messageBus.updateProcess(process.processId, { updated_at: new Date().toISOString(), ...newData }, [], null).then((processUpdated: any) => {
|
||||||
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
const newStateId: string = processUpdated.diffs[0]?.state_id;
|
||||||
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
|
||||||
this.messageBus.validateState(process.processId, newStateId).then(() => {
|
this.messageBus.validateState(process.processId, newStateId).then(() => {
|
||||||
// Update cache
|
// Update cache
|
||||||
this.setItem('_deed_types_', processUpdated);
|
this.setItem('_deed_types_', process);
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
}).catch(() => console.error('Failed to validate state'));
|
}).catch((error) => console.error('Failed to validate state', error));
|
||||||
}).catch(() => console.error('Failed to notify update'));
|
}).catch((error) => console.error('Failed to notify update', error));
|
||||||
}).catch(() => console.error('Failed to update'));
|
}).catch((error) => console.error('Failed to update', error));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export default class DocumentService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createDocument(documentData: any, validatorId: string): Promise<any> {
|
public static createDocument(documentData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -11,7 +11,7 @@ export default class DocumentTypeService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createDocumentType(documentTypeData: any, validatorId: string): Promise<any> {
|
public static createDocumentType(documentTypeData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -12,7 +12,7 @@ export default class FileService {
|
|||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createFile(fileData: FileData, validatorId: string): Promise<any> {
|
public static createFile(fileData: FileData, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -18,7 +18,7 @@ export default class FolderService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createFolder(folderData: any, stakeholdersId: string[], customersId: string[]): Promise<any> {
|
public static createFolder(folderData: any, stakeholdersId: string[], customersId: string[]): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -104,7 +104,7 @@ export default class ImportData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async done(validatorId: string): Promise<any> {
|
private static async done(validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -10,7 +10,7 @@ export default class NoteService {
|
|||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createNote(noteData: any, validatorId: string): Promise<any> {
|
public static createNote(noteData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -12,7 +12,7 @@ export default class OfficeRibService {
|
|||||||
private constructor() { }
|
private constructor() { }
|
||||||
|
|
||||||
public static createOfficeRib(fileData: FileData, validatorId: string): Promise<any> {
|
public static createOfficeRib(fileData: FileData, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -14,7 +14,7 @@ export default class OfficeRoleService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createOfficeRole(roleData: any, validatorId: string): Promise<any> {
|
public static createOfficeRole(roleData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -11,7 +11,7 @@ export default class OfficeService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createOffice(officeData: any, validatorId: string): Promise<any> {
|
public static createOffice(officeData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -11,7 +11,7 @@ export default class RoleService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createRole(roleData: any, validatorId: string): Promise<any> {
|
public static createRole(roleData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -13,7 +13,7 @@ export default class RuleGroupService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createRuleGroup(ruleGroupData: any, validatorId: string): Promise<any> {
|
public static createRuleGroup(ruleGroupData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -11,7 +11,7 @@ export default class RuleService extends AbstractService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static createRule(ruleData: any, validatorId: string): Promise<any> {
|
public static createRule(ruleData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
uid: uuidv4(),
|
uid: uuidv4(),
|
||||||
|
@ -88,15 +88,15 @@ export default class Customers extends BaseNotary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendReminder(uid: string, documentsUid: string[]): Promise<void> {
|
public async sendReminder(office: any, customer: any): Promise<void> {
|
||||||
// TODO: review
|
// TODO: review
|
||||||
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
|
const baseBackUrl = 'http://localhost:8080';//variables.BACK_API_PROTOCOL + variables.BACK_API_HOST;
|
||||||
|
|
||||||
const url = new URL(`${baseBackUrl}/api/${uid}/send_reminder`);
|
const url = new URL(`${baseBackUrl}/api/send_reminder`);
|
||||||
|
|
||||||
//const url = new URL(this.baseURl.concat(`/${uid}/send_reminder`));
|
//const url = new URL(this.baseURl.concat(`/${uid}/send_reminder`));
|
||||||
try {
|
try {
|
||||||
await this.postRequest<void>(url, { email: 'ja.janin.anthony@gmail.com', documentsUid });
|
await this.postRequest<void>(url, { office, customer });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.onError(err);
|
this.onError(err);
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
|
@ -7,7 +7,6 @@ import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
|||||||
import DefaultDeedTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDeedTypeDashboard";
|
import DefaultDeedTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDeedTypeDashboard";
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
|
||||||
import { DeedType, Office } from "le-coffre-resources/dist/Admin";
|
import { DeedType, Office } from "le-coffre-resources/dist/Admin";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
@ -15,8 +14,10 @@ import { useCallback, useState } from "react";
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import { validateOrReject, ValidationError } from "class-validator";
|
import { validateOrReject, ValidationError } from "class-validator";
|
||||||
|
|
||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
import UserStore from "@Front/Stores/UserStore";
|
||||||
|
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
|
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
export default function DeedTypesCreate(props: IProps) {
|
export default function DeedTypesCreate(props: IProps) {
|
||||||
@ -28,8 +29,8 @@ export default function DeedTypesCreate(props: IProps) {
|
|||||||
const onSubmitHandler = useCallback(
|
const onSubmitHandler = useCallback(
|
||||||
async (e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) => {
|
async (e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) => {
|
||||||
try {
|
try {
|
||||||
// TODO: review
|
const user: any = UserStore.instance.getUser();
|
||||||
const officeId = 'demo_notary_office_id'; //JwtService.getInstance().decodeJwt()?.office_Id;
|
const officeId: string = user.office.uid;
|
||||||
|
|
||||||
const deedType = DeedType.hydrate<DeedType>({
|
const deedType = DeedType.hydrate<DeedType>({
|
||||||
name: values["name"],
|
name: values["name"],
|
||||||
|
@ -79,6 +79,7 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
async function getDeedType() {
|
async function getDeedType() {
|
||||||
if (!deedTypeUid) return;
|
if (!deedTypeUid) return;
|
||||||
|
|
||||||
|
setSelectedDocuments([]);
|
||||||
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
DeedTypeService.getDeedTypeByUid(deedTypeUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const deedType: any = process.processData;
|
const deedType: any = process.processData;
|
||||||
@ -99,6 +100,7 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getDocuments() {
|
async function getDocuments() {
|
||||||
|
setAvailableDocuments([]);
|
||||||
DocumentTypeService.getDocumentTypes().then((processes: any[]) => {
|
DocumentTypeService.getDocumentTypes().then((processes: any[]) => {
|
||||||
if (processes.length) {
|
if (processes.length) {
|
||||||
const documents: any[] = processes.map((process: any) => process.processData);
|
const documents: any[] = processes.map((process: any) => process.processData);
|
||||||
@ -128,8 +130,8 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
if (!document_types) {
|
if (!document_types) {
|
||||||
document_types = [];
|
document_types = [];
|
||||||
}
|
}
|
||||||
selectedDocuments.map((selectedDocument: any) => ({ uid: selectedDocument.id as string }))
|
selectedDocuments.map((selectedDocument: any) => selectedDocument.id as string)
|
||||||
.forEach((selectedDocument: any) => document_types.push(selectedDocument));
|
.forEach((uid: any) => document_types.push(availableDocuments.find((document: any) => document.uid === uid)));
|
||||||
|
|
||||||
// New data
|
// New data
|
||||||
const newData: any = {
|
const newData: any = {
|
||||||
|
@ -11,6 +11,11 @@ import React, { useCallback, useMemo, useState } from "react";
|
|||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
|
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||||
|
import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
||||||
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
|
import UserStore from "@Front/Stores/UserStore";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
@ -23,9 +28,24 @@ export default function ReminderModal(props: IProps) {
|
|||||||
const [selectedOptions, setSelectedOptions] = useState<IOption[]>([]);
|
const [selectedOptions, setSelectedOptions] = useState<IOption[]>([]);
|
||||||
const [isAllSelected, setIsAllSelected] = useState(false);
|
const [isAllSelected, setIsAllSelected] = useState(false);
|
||||||
|
|
||||||
const onRemind = useCallback(() => {
|
const onRemind = useCallback(async () => {
|
||||||
|
LoaderService.getInstance().show();
|
||||||
|
|
||||||
|
const documentUids: string[] = selectedOptions.map((option) => option.value) as string[];
|
||||||
|
|
||||||
|
const user: any = UserStore.instance.getUser();
|
||||||
|
const _office: any = user.office;
|
||||||
|
|
||||||
|
const _documents: any[] = [];
|
||||||
|
for (const documentUid of documentUids) {
|
||||||
|
_documents.push((await DocumentService.getDocumentByUid(documentUid)).processData);
|
||||||
|
}
|
||||||
|
const _customer = (await CustomerService.getCustomerByUid(customer.uid!)).processData;
|
||||||
|
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
|
|
||||||
Customers.getInstance()
|
Customers.getInstance()
|
||||||
.sendReminder(customer.uid!, selectedOptions.map((option) => option.value) as string[])
|
.sendReminder(_office, _customer)
|
||||||
.then(onRemindSuccess)
|
.then(onRemindSuccess)
|
||||||
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "La relance a été envoyée avec succès." }))
|
.then(() => ToasterService.getInstance().success({ title: "Succès !", description: "La relance a été envoyée avec succès." }))
|
||||||
.then(onClose);
|
.then(onClose);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user