Compare commits
No commits in common. "56878c977c5bafbeee970eb705e8e3a69b512848" and "6a7918d081af3716748b0a7b94eff16a6ea0b887" have entirely different histories.
56878c977c
...
6a7918d081
@ -3,7 +3,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
import User from 'src/sdk/User';
|
import User from 'src/sdk/User';
|
||||||
|
|
||||||
import AbstractService from './AbstractService';
|
import AbstractService from './AbstractService';
|
||||||
import { DEFAULT_STORAGE_URLS } from '@Front/Config/AppConstants';
|
|
||||||
|
|
||||||
export default class CustomerService extends AbstractService {
|
export default class CustomerService extends AbstractService {
|
||||||
|
|
||||||
@ -11,7 +10,7 @@ export default class CustomerService extends AbstractService {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async createCustomer(customerData: any, validatorId: string): Promise<{ processId: string, processData: any }> {
|
public static createCustomer(customerData: any, validatorId: string): Promise<any> {
|
||||||
const ownerId: string = User.getInstance().getPairingId()!;
|
const ownerId: string = User.getInstance().getPairingId()!;
|
||||||
|
|
||||||
const processData: any = {
|
const processData: any = {
|
||||||
@ -24,72 +23,114 @@ export default class CustomerService extends AbstractService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const privateFields: string[] = Object.keys(processData);
|
const privateFields: string[] = Object.keys(processData);
|
||||||
const allFields: string[] = [...privateFields, 'roles'];
|
privateFields.splice(privateFields.indexOf('uid'), 1);
|
||||||
|
privateFields.splice(privateFields.indexOf('utype'), 1);
|
||||||
|
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
|
||||||
|
|
||||||
const roles: any = {
|
const roles: any = {
|
||||||
demiurge: {
|
demiurge: {
|
||||||
members: [ownerId, validatorId],
|
members: [...[ownerId], validatorId],
|
||||||
validation_rules: [],
|
validation_rules: [],
|
||||||
storages: []
|
storages: []
|
||||||
},
|
},
|
||||||
owner: {
|
owner: {
|
||||||
members: [ownerId, validatorId],
|
members: [ownerId],
|
||||||
validation_rules: [
|
validation_rules: [
|
||||||
{
|
{
|
||||||
quorum: 1,
|
quorum: 0.5,
|
||||||
fields: allFields,
|
fields: [...privateFields, 'roles', 'uid', 'utype'],
|
||||||
min_sig_member: 1,
|
min_sig_member: 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
storages: [...DEFAULT_STORAGE_URLS]
|
storages: []
|
||||||
|
},
|
||||||
|
validator: {
|
||||||
|
members: [validatorId],
|
||||||
|
validation_rules: [
|
||||||
|
{
|
||||||
|
quorum: 0.5,
|
||||||
|
fields: ['idCertified', 'roles'],
|
||||||
|
min_sig_member: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
quorum: 0.0,
|
||||||
|
fields: [...privateFields],
|
||||||
|
min_sig_member: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
storages: []
|
||||||
},
|
},
|
||||||
apophis: {
|
apophis: {
|
||||||
members: [ownerId, validatorId],
|
members: [ownerId],
|
||||||
validation_rules: [],
|
validation_rules: [],
|
||||||
storages: []
|
storages: []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
return new Promise<any>((resolve: (processCreated: any) => void, reject: (error: string) => void) => {
|
||||||
const processCreated = await this.messageBus.createProcess(processData, privateFields, roles);
|
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
|
||||||
await this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id);
|
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
|
||||||
await this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id);
|
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
|
||||||
const finalProcessData = await this.messageBus.getProcessData(processCreated.processId);
|
this.getCustomerByUid(processCreated.processData.uid).then(resolve).catch(reject);
|
||||||
|
}).catch(reject);
|
||||||
return { processId: processCreated.processId, processData: finalProcessData[processCreated.processId] };
|
}).catch(reject);
|
||||||
} catch (error) {
|
}).catch(reject);
|
||||||
throw error;
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getCustomers(callback: (processes: Record<string, any>) => void): void {
|
public static getCustomers(): Promise<any[]> {
|
||||||
// Check if we have valid cache
|
// Check if we have valid cache
|
||||||
const items: Record<string, any> = this.getItems('_customers_');
|
const items: any[] = this.getItems('_customers_');
|
||||||
if (Object.keys(items).length > 0) {
|
|
||||||
setTimeout(() => callback(items), 0);
|
return this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
|
publicValues['uid'] &&
|
||||||
|
publicValues['utype'] &&
|
||||||
|
publicValues['utype'] === 'customer' &&
|
||||||
|
publicValues['isDeleted'] &&
|
||||||
|
publicValues['isDeleted'] === 'false' &&
|
||||||
|
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
|
||||||
|
).then((processes: any[]) => {
|
||||||
|
if (processes.length === 0) {
|
||||||
|
return items;
|
||||||
|
} else {
|
||||||
|
for (const process of processes) {
|
||||||
|
// Update cache
|
||||||
|
this.setItem('_customers_', process);
|
||||||
|
|
||||||
|
items.push(process);
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getCustomerByUid(uid: string): Promise<any> {
|
||||||
|
// Check if we have valid cache
|
||||||
|
const item: any = this.getItem('_customers_', uid);
|
||||||
|
if (item) {
|
||||||
|
return Promise.resolve(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.messageBus.getProcessesDecoded((_processId: string, values: any) => {
|
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
|
||||||
return values['utype']
|
this.messageBus.getProcessesDecoded((publicValues: any) =>
|
||||||
&& values['utype'] === 'customer'
|
publicValues['uid'] &&
|
||||||
&& values['isDeleted']
|
publicValues['uid'] === uid &&
|
||||||
&& values['isDeleted'] === 'false';
|
publicValues['utype'] &&
|
||||||
}).then(async (processes: Record<string, any>) => {
|
publicValues['utype'] === 'customer' &&
|
||||||
if (Object.keys(processes).length === 0) {
|
publicValues['isDeleted'] &&
|
||||||
callback(items);
|
publicValues['isDeleted'] === 'false'
|
||||||
return;
|
).then((processes: any[]) => {
|
||||||
}
|
if (processes.length === 0) {
|
||||||
|
resolve(null);
|
||||||
|
} else {
|
||||||
|
const process: any = processes[0];
|
||||||
|
|
||||||
const updatedItems: Record<string, any> = { ...items };
|
// Update cache
|
||||||
|
this.setItem('_customers_', process);
|
||||||
|
|
||||||
for (const [processId, process] of Object.entries(processes)) {
|
resolve(process);
|
||||||
// Update cache
|
}
|
||||||
this.setItem('_customers_', processId, process);
|
}).catch(reject);
|
||||||
|
|
||||||
updatedItems[processId] = process;
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(updatedItems);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +143,7 @@ export default class CustomerService extends AbstractService {
|
|||||||
const customerUid: string = process.processData.uid;
|
const customerUid: string = process.processData.uid;
|
||||||
this.removeItem('_customers_', customerUid);
|
this.removeItem('_customers_', customerUid);
|
||||||
|
|
||||||
resolve();
|
this.getCustomerByUid(customerUid).then(resolve).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDas
|
|||||||
import { DeedType } from "le-coffre-resources/dist/Notary";
|
import { DeedType } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||||
import { idAsUrl } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
type IProps = IPropsDashboardWithList;
|
type IProps = IPropsDashboardWithList;
|
||||||
|
|
||||||
@ -18,13 +17,13 @@ export default function DefaultDeedTypeDashboard(props: IProps) {
|
|||||||
const [deedTypes, setDeedTypes] = React.useState<DeedType[] | null>(null);
|
const [deedTypes, setDeedTypes] = React.useState<DeedType[] | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
DeedTypeService.getDeedTypes((processes: Record<string, any>) => {
|
DeedTypeService.getDeedTypes((processes: any[]) => {
|
||||||
const deedTypes = Object.entries(processes).map(([processId, processData]) => ({
|
if (processes.length > 0) {
|
||||||
...processData,
|
let deedTypes = processes.map((process: any) => process.processData);
|
||||||
processId: processId
|
|
||||||
}));
|
// FilterBy archived_at = null or not defined
|
||||||
if (deedTypes.length > 0) {
|
deedTypes = deedTypes.filter((deedType: any) => !deedType.archived_at);
|
||||||
deedTypes.filter((deedType: any) => !deedType.archived_at);
|
|
||||||
// OrderBy name asc
|
// OrderBy name asc
|
||||||
deedTypes.sort((a: any, b: any) => a.name.localeCompare(b.name));
|
deedTypes.sort((a: any, b: any) => a.name.localeCompare(b.name));
|
||||||
|
|
||||||
@ -36,9 +35,7 @@ export default function DefaultDeedTypeDashboard(props: IProps) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onSelectedBlock = (block: IBlock) => {
|
const onSelectedBlock = (block: IBlock) => {
|
||||||
// Remove ':0' suffix from processId for URL navigation
|
router.push(Module.getInstance().get().modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", block.id));
|
||||||
const urlId = idAsUrl(block.id as string);
|
|
||||||
router.push(Module.getInstance().get().modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", urlId));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -47,14 +44,11 @@ export default function DefaultDeedTypeDashboard(props: IProps) {
|
|||||||
onSelectedBlock={onSelectedBlock}
|
onSelectedBlock={onSelectedBlock}
|
||||||
blocks={
|
blocks={
|
||||||
deedTypes
|
deedTypes
|
||||||
? deedTypes.map((deedType: any) => {
|
? deedTypes.map((deedTypes) => ({
|
||||||
const urlId = idAsUrl(deedType.processId);
|
id: deedTypes.uid!,
|
||||||
return {
|
primaryText: deedTypes.name,
|
||||||
id: deedType.processId, // Keep full processId for internal use
|
isActive: deedTypes.uid === deedTypeUid,
|
||||||
primaryText: deedType.name,
|
}))
|
||||||
isActive: urlId === deedTypeUid, // Compare without ':0' suffix
|
|
||||||
};
|
|
||||||
})
|
|
||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
bottomButton={{
|
bottomButton={{
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import { useRouter } from "next/router";
|
|||||||
import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList";
|
import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList";
|
||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import { idAsUrl } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
type IProps = IPropsDashboardWithList & {
|
type IProps = IPropsDashboardWithList & {
|
||||||
isArchived?: boolean;
|
isArchived?: boolean;
|
||||||
@ -26,11 +25,11 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
|||||||
: Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path;
|
: Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path;
|
||||||
|
|
||||||
const getBlocks = useCallback(
|
const getBlocks = useCallback(
|
||||||
(folders: any[]): IBlock[] => {
|
(folders: OfficeFolder[]): IBlock[] => {
|
||||||
const pendingFolders = folders
|
const pendingFolders = folders
|
||||||
.filter((folder) => {
|
.filter((folder) => {
|
||||||
const pendingDocuments = (folder.documents ?? []).filter(
|
const pendingDocuments = (folder.documents ?? []).filter(
|
||||||
(document: any) => document.document_status === EDocumentStatus.DEPOSITED,
|
(document) => document.document_status === EDocumentStatus.DEPOSITED,
|
||||||
);
|
);
|
||||||
return pendingDocuments.length >= 1;
|
return pendingDocuments.length >= 1;
|
||||||
})
|
})
|
||||||
@ -41,7 +40,7 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
|||||||
const otherFolders = folders
|
const otherFolders = folders
|
||||||
.filter((folder) => {
|
.filter((folder) => {
|
||||||
const pendingDocuments = (folder.documents ?? []).filter(
|
const pendingDocuments = (folder.documents ?? []).filter(
|
||||||
(document: any) => document.document_status === EDocumentStatus.DEPOSITED,
|
(document) => document.document_status === EDocumentStatus.DEPOSITED,
|
||||||
);
|
);
|
||||||
return pendingDocuments.length === 0;
|
return pendingDocuments.length === 0;
|
||||||
})
|
})
|
||||||
@ -49,18 +48,15 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
|||||||
return folder1.created_at! > folder2.created_at! ? -1 : 1;
|
return folder1.created_at! > folder2.created_at! ? -1 : 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
const blocks = [...pendingFolders, ...otherFolders].map((folder) => {
|
return [...pendingFolders, ...otherFolders].map((folder) => {
|
||||||
const res = {
|
return {
|
||||||
id: idAsUrl(folder.processId),
|
id: folder.uid!,
|
||||||
primaryText: folder.name,
|
primaryText: folder.name,
|
||||||
secondaryText: folder.folder_number,
|
secondaryText: folder.folder_number,
|
||||||
isActive: folderUid === idAsUrl(folder.processId),
|
isActive: folderUid === folder.uid,
|
||||||
showAlert: folder.documents?.some((document: any) => document.document_status === EDocumentStatus.DEPOSITED),
|
showAlert: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED),
|
||||||
};
|
};
|
||||||
return res;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return blocks;
|
|
||||||
},
|
},
|
||||||
[folderUid],
|
[folderUid],
|
||||||
);
|
);
|
||||||
@ -119,26 +115,14 @@ export default function DefaultNotaryDashboard(props: IProps) {
|
|||||||
.then((folders) => setFolders(folders));
|
.then((folders) => setFolders(folders));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FolderService.getFolders((processes: Record<string, any>) => {
|
FolderService.getFolders((processes: any[]) => {
|
||||||
if (Object.keys(processes).length > 0) {
|
if (processes.length > 0) {
|
||||||
let folders: any[] = Object.entries(processes).map(([processId, process]) => {
|
let folders: any[] = processes.map((process: any) => process.processData);
|
||||||
const res = {
|
|
||||||
...process,
|
|
||||||
processId: processId
|
|
||||||
};
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// FilterBy status
|
// FilterBy status
|
||||||
folders = folders.filter((folder: any) => {
|
folders = folders.filter((folder: any) => folder.status === targetedStatus);
|
||||||
const matches = folder.status === targetedStatus;
|
|
||||||
return matches;
|
|
||||||
});
|
|
||||||
|
|
||||||
setFolders(folders);
|
setFolders(folders);
|
||||||
} else {
|
|
||||||
console.debug('[DefaultNotaryDashboard] No processes found');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [isArchived]);
|
}, [isArchived]);
|
||||||
|
|||||||
@ -19,7 +19,6 @@ import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
|||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||||
import { DEFAULT_VALIDATOR_ID } from "@Front/Config/AppConstants";
|
import { DEFAULT_VALIDATOR_ID } from "@Front/Config/AppConstants";
|
||||||
import Auth from "@Front/Api/Auth/IdNot";
|
import Auth from "@Front/Api/Auth/IdNot";
|
||||||
import { idAsUrl } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
export default function DeedTypesCreate(props: IProps) {
|
export default function DeedTypesCreate(props: IProps) {
|
||||||
@ -81,7 +80,7 @@ export default function DeedTypesCreate(props: IProps) {
|
|||||||
});
|
});
|
||||||
const deedTypeUid = processCreated.processId;
|
const deedTypeUid = processCreated.processId;
|
||||||
// Remove ':0' suffix from processId for URL navigation
|
// Remove ':0' suffix from processId for URL navigation
|
||||||
const urlId = idAsUrl(deedTypeUid);
|
const urlId = deedTypeUid.replace(/:0$/, '');
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
|
|||||||
@ -17,7 +17,6 @@ import classes from "./classes.module.scss";
|
|||||||
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
import MessageBus from "src/sdk/MessageBus";
|
import MessageBus from "src/sdk/MessageBus";
|
||||||
import { idAsProcessId } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
export default function DeedTypesEdit() {
|
export default function DeedTypesEdit() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -34,7 +33,7 @@ export default function DeedTypesEdit() {
|
|||||||
if (!deedTypeUid) return;
|
if (!deedTypeUid) return;
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
||||||
const processId = idAsProcessId(deedTypeUid as string);
|
const processId = (deedTypeUid as string) + ':0';
|
||||||
MessageBus.getInstance().getProcessData(processId).then((processData: any) => {
|
MessageBus.getInstance().getProcessData(processId).then((processData: any) => {
|
||||||
if (processData) {
|
if (processData) {
|
||||||
setDeedTypeSelected(processData);
|
setDeedTypeSelected(processData);
|
||||||
@ -67,7 +66,7 @@ export default function DeedTypesEdit() {
|
|||||||
try {
|
try {
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
||||||
const processId = idAsProcessId(deedTypeUid as string);
|
const processId = (deedTypeUid as string) + ':0';
|
||||||
|
|
||||||
const process = await MessageBus.getInstance().getProcessData(processId);
|
const process = await MessageBus.getInstance().getProcessData(processId);
|
||||||
if (process) {
|
if (process) {
|
||||||
|
|||||||
@ -22,7 +22,6 @@ import DeedTypeService from "src/common/Api/LeCoffreApi/sdk/DeedTypeService";
|
|||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
import MessageBus from "src/sdk/MessageBus";
|
import MessageBus from "src/sdk/MessageBus";
|
||||||
import { idAsProcessId } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
type IProps = {};
|
type IProps = {};
|
||||||
export default function DeedTypesInformations(props: IProps) {
|
export default function DeedTypesInformations(props: IProps) {
|
||||||
@ -52,14 +51,12 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
setIsSaveModalOpened(false);
|
setIsSaveModalOpened(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const deleteDeedType = async () => {
|
const deleteDeedType = useCallback(async () => {
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
try {
|
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
||||||
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
const processId = (deedTypeUid as string) + ':0';
|
||||||
const processId = idAsProcessId(deedTypeUid as string);
|
MessageBus.getInstance().getProcessData(processId).then(async (process: any) => {
|
||||||
const process = await MessageBus.getInstance().getProcessData(processId);
|
if (process) {
|
||||||
|
|
||||||
if (process && process[processId]) {
|
|
||||||
// New data
|
// New data
|
||||||
const newData: any = {
|
const newData: any = {
|
||||||
isDeleted: 'true',
|
isDeleted: 'true',
|
||||||
@ -67,22 +64,19 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Merge process data with new data & update process
|
// Merge process data with new data & update process
|
||||||
process[processId].isDeleted = newData.isDeleted;
|
process.processData.isDeleted = newData.isDeleted;
|
||||||
process[processId].archived_at = newData.archived_at;
|
process.processData.archived_at = newData.archived_at;
|
||||||
await DeedTypeService.updateDeedType(processId, newData);
|
await DeedTypeService.updateDeedType(process, newData);
|
||||||
|
|
||||||
router.push(
|
router.push(
|
||||||
Module.getInstance()
|
Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.DeedTypes.props.path
|
.modules.pages.DeedTypes.props.path
|
||||||
);
|
);
|
||||||
|
LoaderService.getInstance().hide();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
});
|
||||||
console.error('Error deleting deed type:', error);
|
}, [deedTypeUid, router]);
|
||||||
} finally {
|
|
||||||
LoaderService.getInstance().hide();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getDeedType() {
|
async function getDeedType() {
|
||||||
@ -90,7 +84,7 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
|
|
||||||
setSelectedDocuments([]);
|
setSelectedDocuments([]);
|
||||||
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
||||||
const processId = idAsProcessId(deedTypeUid as string);
|
const processId = (deedTypeUid as string) + ':0';
|
||||||
MessageBus.getInstance().getProcessData(processId).then((process: any) => {
|
MessageBus.getInstance().getProcessData(processId).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
console.log('[DeedTypesInformations] process', process);
|
console.log('[DeedTypesInformations] process', process);
|
||||||
@ -137,7 +131,7 @@ export default function DeedTypesInformations(props: IProps) {
|
|||||||
const saveDocumentTypes = useCallback(async () => {
|
const saveDocumentTypes = useCallback(async () => {
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
// deedTypeUid comes from URL without ':0' suffix, add it back for API calls
|
||||||
const processId = idAsProcessId(deedTypeUid as string);
|
const processId = (deedTypeUid as string) + ':0';
|
||||||
console.log('[DeedTypesInformations] processId', processId);
|
console.log('[DeedTypesInformations] processId', processId);
|
||||||
const deedType = (await MessageBus.getInstance().getProcessData(processId))[processId];
|
const deedType = (await MessageBus.getInstance().getProcessData(processId))[processId];
|
||||||
if (deedType) {
|
if (deedType) {
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import classes from "./classes.module.scss";
|
|||||||
|
|
||||||
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
import DocumentTypeService from "src/common/Api/LeCoffreApi/sdk/DocumentTypeService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
import { idAsUrl } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
import UserStore from "@Front/Stores/UserStore";
|
import UserStore from "@Front/Stores/UserStore";
|
||||||
import { DEFAULT_VALIDATOR_ID } from "@Front/Config/AppConstants";
|
import { DEFAULT_VALIDATOR_ID } from "@Front/Config/AppConstants";
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ export default function DocumentTypesCreate(props: IProps) {
|
|||||||
title: "Succès !",
|
title: "Succès !",
|
||||||
description: "Type de document créé avec succès"
|
description: "Type de document créé avec succès"
|
||||||
});
|
});
|
||||||
const documentTypeUid = idAsUrl(processCreated.processId);
|
const documentTypeUid = processCreated.processId.split(':')[0];
|
||||||
if (!documentTypeUid) {
|
if (!documentTypeUid) {
|
||||||
console.error("DocumentTypesCreate: documentTypeUid is undefined - processCreated.processId is missing");
|
console.error("DocumentTypesCreate: documentTypeUid is undefined - processCreated.processId is missing");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -33,10 +33,9 @@ export default function ClientBox(props: IProps) {
|
|||||||
const handleDelete = useCallback(
|
const handleDelete = useCallback(
|
||||||
(customerUid: string) => {
|
(customerUid: string) => {
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
DocumentService.getDocuments().then((processes: Record<string, any>) => {
|
DocumentService.getDocuments().then((processes: any[]) => {
|
||||||
const processArray = Object.values(processes);
|
if (processes.length > 0) {
|
||||||
if (processArray.length > 0) {
|
let documents: any[] = processes.map((process: any) => process.processData);
|
||||||
let documents: any[] = processArray.map((process: any) => process.processData);
|
|
||||||
|
|
||||||
// FilterBy folder.uid & depositor.uid
|
// FilterBy folder.uid & depositor.uid
|
||||||
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
documents = documents.filter((document: any) => document.folder.uid === folderUid && document.depositor && document.depositor.uid === customerUid);
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
|
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||||
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Tabs from "@Front/Components/Elements/Tabs";
|
import Tabs from "@Front/Components/Elements/Tabs";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { DocumentIcon, UserPlusIcon } from "@heroicons/react/24/outline";
|
import { DocumentIcon, UserPlusIcon } from "@heroicons/react/24/outline";
|
||||||
import Customer from "le-coffre-resources/dist/Customer";
|
import Customer from "le-coffre-resources/dist/Customer";
|
||||||
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
@ -16,10 +18,9 @@ import EmailReminder from "./EmailReminder";
|
|||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
import LoaderService from "src/common/Api/LeCoffreApi/sdk/Loader/LoaderService";
|
||||||
import MessageBus from "src/sdk/MessageBus";
|
import MessageBus from "src/sdk/MessageBus";
|
||||||
import { idAsUrl } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
folder: any;
|
folder: { processId: string, FolderData: OfficeFolder};
|
||||||
anchorStatus: AnchorStatus;
|
anchorStatus: AnchorStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ export default function ClientView(props: IProps) {
|
|||||||
<Link
|
<Link
|
||||||
href={Module.getInstance()
|
href={Module.getInstance()
|
||||||
.get()
|
.get()
|
||||||
.modules.pages.Folder.pages.AddClient.props.path.replace("[folderUid]", idAsUrl(folder.processId) ?? "")}>
|
.modules.pages.Folder.pages.AddClient.props.path.replace("[folderUid]", folder.processId ?? "")}>
|
||||||
<Button
|
<Button
|
||||||
size={EButtonSize.MD}
|
size={EButtonSize.MD}
|
||||||
rightIcon={<UserPlusIcon />}
|
rightIcon={<UserPlusIcon />}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import EmptyAlert from "@Front/Components/DesignSystem/EmptyAlert";
|
import EmptyAlert from "@Front/Components/DesignSystem/EmptyAlert";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
import { idAsUrl } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
import { UserPlusIcon } from "@heroicons/react/24/outline";
|
import { UserPlusIcon } from "@heroicons/react/24/outline";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
@ -15,7 +14,7 @@ export default function AddClientSection(props: IProps) {
|
|||||||
|
|
||||||
const addClientPath = useMemo(() => {
|
const addClientPath = useMemo(() => {
|
||||||
if (!folderUid) return "";
|
if (!folderUid) return "";
|
||||||
return Module.getInstance().get().modules.pages.Folder.pages.AddClient.props.path.replace("[folderUid]", idAsUrl(folderUid));
|
return Module.getInstance().get().modules.pages.Folder.pages.AddClient.props.path.replace("[folderUid]", folderUid);
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -20,9 +20,8 @@ import InformationSection from "./InformationSection";
|
|||||||
import NoClientView from "./NoClientView";
|
import NoClientView from "./NoClientView";
|
||||||
import AnchoringProcessingInfo from "./elements/AnchoringProcessingInfo";
|
import AnchoringProcessingInfo from "./elements/AnchoringProcessingInfo";
|
||||||
|
|
||||||
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
import EFolderStatus from "le-coffre-resources/dist/Customer/EFolderStatus";
|
||||||
import MessageBus from "src/sdk/MessageBus";
|
|
||||||
import { idAsProcessId } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
export enum AnchorStatus {
|
export enum AnchorStatus {
|
||||||
"VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN",
|
"VERIFIED_ON_CHAIN" = "VERIFIED_ON_CHAIN",
|
||||||
@ -63,34 +62,63 @@ export default function FolderInformation(props: IProps) {
|
|||||||
const doesFolderHaveClient = useMemo(() => folder?.customers?.length !== 0, [folder]);
|
const doesFolderHaveClient = useMemo(() => folder?.customers?.length !== 0, [folder]);
|
||||||
|
|
||||||
const fetchFolder = useCallback(async () => {
|
const fetchFolder = useCallback(async () => {
|
||||||
if (!folderUid) {
|
if (!folderUid) return;
|
||||||
console.log('[FolderInformation] No folderUid, skipping fetch');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const processId = idAsProcessId(folderUid as string);
|
/*
|
||||||
return MessageBus.getInstance().getProcessData(processId).then(async (process: { [key: string]: any }) => {
|
const query = {
|
||||||
|
q: {
|
||||||
|
deed: { include: { deed_type: true, document_types: true } },
|
||||||
|
office: true,
|
||||||
|
customers: {
|
||||||
|
include: {
|
||||||
|
contact: true,
|
||||||
|
documents: {
|
||||||
|
where: {
|
||||||
|
folder_uid: folderUid,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
folder: true,
|
||||||
|
document_type: true,
|
||||||
|
files: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
documents: {
|
||||||
|
include: {
|
||||||
|
depositor: {
|
||||||
|
include: {
|
||||||
|
contact: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
folder_anchor: true,
|
||||||
|
notes: {
|
||||||
|
include: {
|
||||||
|
customer: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return Folders.getInstance()
|
||||||
|
.getByUid(folderUid, query)
|
||||||
|
.then((folder) => setFolder(folder));
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: review
|
||||||
|
return FolderService.getFolderByUid(folderUid).then(async (process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const processEntries = Object.entries(process);
|
const folder: any = process.processData;
|
||||||
if (processEntries.length === 1) {
|
setFolder(folder);
|
||||||
const [processId, processData] = processEntries[0]!;
|
|
||||||
const folder: any = {
|
|
||||||
...processData,
|
|
||||||
processId: processId
|
|
||||||
};
|
|
||||||
setFolder(folder);
|
|
||||||
} else if (processEntries.length > 1) {
|
|
||||||
console.error('[FolderInformation] Multiple processes found for folderUid ', folderUid, ':', processEntries);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).catch((e) => {
|
|
||||||
console.error('[FolderInformation] No process found for folderUid ', folderUid, ':', e);
|
|
||||||
});
|
});
|
||||||
}, [folderUid]);
|
}, [folderUid]);
|
||||||
|
|
||||||
const fetchAnchorStatus = useCallback(() => {
|
const fetchAnchorStatus = useCallback(() => {
|
||||||
return OfficeFolderAnchors.getInstance()
|
return OfficeFolderAnchors.getInstance()
|
||||||
.getByUid(folderUid as string)
|
.getByUid(folderUid)
|
||||||
.then((anchorStatus) =>
|
.then((anchorStatus) =>
|
||||||
setAnchorStatus(anchorStatus.status === "VERIFIED_ON_CHAIN" ? AnchorStatus.VERIFIED_ON_CHAIN : AnchorStatus.ANCHORING),
|
setAnchorStatus(anchorStatus.status === "VERIFIED_ON_CHAIN" ? AnchorStatus.VERIFIED_ON_CHAIN : AnchorStatus.ANCHORING),
|
||||||
)
|
)
|
||||||
@ -140,7 +168,7 @@ export default function FolderInformation(props: IProps) {
|
|||||||
)}
|
)}
|
||||||
{!isArchived && anchorStatus === AnchorStatus.ANCHORING && <AnchoringProcessingInfo />}
|
{!isArchived && anchorStatus === AnchorStatus.ANCHORING && <AnchoringProcessingInfo />}
|
||||||
{isArchived && folderUid && (
|
{isArchived && folderUid && (
|
||||||
<ArchiveAlertWarning folderUid={folderUid as string} onDownloadAnchoringProof={downloadAnchoringProofModal.open} />
|
<ArchiveAlertWarning folderUid={folderUid} onDownloadAnchoringProof={downloadAnchoringProofModal.open} />
|
||||||
)}
|
)}
|
||||||
{folder && !doesFolderHaveClient && <NoClientView folder={folder} anchorStatus={anchorStatus} />}
|
{folder && !doesFolderHaveClient && <NoClientView folder={folder} anchorStatus={anchorStatus} />}
|
||||||
{folder && doesFolderHaveClient && <ClientView folder={folder} anchorStatus={anchorStatus} />}
|
{folder && doesFolderHaveClient && <ClientView folder={folder} anchorStatus={anchorStatus} />}
|
||||||
@ -148,7 +176,7 @@ export default function FolderInformation(props: IProps) {
|
|||||||
<AnchoringModal
|
<AnchoringModal
|
||||||
isOpen={anchoringModal.isOpen}
|
isOpen={anchoringModal.isOpen}
|
||||||
onClose={anchoringModal.close}
|
onClose={anchoringModal.close}
|
||||||
folderUid={folderUid as string}
|
folderUid={folderUid}
|
||||||
onAnchorSuccess={fetchData}
|
onAnchorSuccess={fetchData}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -164,7 +192,7 @@ export default function FolderInformation(props: IProps) {
|
|||||||
onClose={requireAnchoringModal.close}
|
onClose={requireAnchoringModal.close}
|
||||||
onAnchor={anchoringModal.open}
|
onAnchor={anchoringModal.open}
|
||||||
/>
|
/>
|
||||||
{folderUid && <ArchiveModal isOpen={archiveModal.isOpen} onClose={archiveModal.close} folderUid={folderUid as string} />}
|
{folderUid && <ArchiveModal isOpen={archiveModal.isOpen} onClose={archiveModal.close} folderUid={folderUid} />}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{isLoading && (
|
{isLoading && (
|
||||||
|
|||||||
@ -24,8 +24,6 @@ import DocumentService from "src/common/Api/LeCoffreApi/sdk/DocumentService";
|
|||||||
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
import FileService from "src/common/Api/LeCoffreApi/sdk/FileService";
|
||||||
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
import CustomerService from "src/common/Api/LeCoffreApi/sdk/CustomerService";
|
||||||
import { DEFAULT_VALIDATOR_ID } from "@Front/Config/AppConstants";
|
import { DEFAULT_VALIDATOR_ID } from "@Front/Config/AppConstants";
|
||||||
import { idAsProcessId } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
import MessageBus from "src/sdk/MessageBus";
|
|
||||||
|
|
||||||
enum EClientSelection {
|
enum EClientSelection {
|
||||||
ALL_CLIENTS = "all_clients",
|
ALL_CLIENTS = "all_clients",
|
||||||
@ -72,7 +70,7 @@ export default function SendDocuments() {
|
|||||||
const customer: any = await new Promise<void>((resolve: (customer: any) => void) => {
|
const customer: any = await new Promise<void>((resolve: (customer: any) => void) => {
|
||||||
CustomerService.getCustomerByUid(selectedClient as string).then((process: any) => {
|
CustomerService.getCustomerByUid(selectedClient as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const customer: any = process;
|
const customer: any = process.processData;
|
||||||
resolve(customer);
|
resolve(customer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -102,7 +100,7 @@ export default function SendDocuments() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
FileService.createFile(fileData, DEFAULT_VALIDATOR_ID).then((processCreated: any) => {
|
FileService.createFile(fileData, DEFAULT_VALIDATOR_ID).then((processCreated: any) => {
|
||||||
const fileUid: string = processCreated.uid;
|
const fileUid: string = processCreated.processData.uid;
|
||||||
|
|
||||||
const documentData: any = {
|
const documentData: any = {
|
||||||
folder: {
|
folder: {
|
||||||
@ -175,9 +173,9 @@ export default function SendDocuments() {
|
|||||||
|
|
||||||
const fetchFolder = useCallback(async () => {
|
const fetchFolder = useCallback(async () => {
|
||||||
LoaderService.getInstance().show();
|
LoaderService.getInstance().show();
|
||||||
MessageBus.getInstance().getProcessData(idAsProcessId(folderUid as string)).then((process: any) => {
|
FolderService.getFolderByUid(folderUid as string).then((process: any) => {
|
||||||
if (process) {
|
if (process) {
|
||||||
const folder: any = process;
|
const folder: any = process.processData;
|
||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
LoaderService.getInstance().hide();
|
LoaderService.getInstance().hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import { useEffect, useState } from "react";
|
|||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
|
||||||
import { idAsUrl } from "@Front/Utils/ProcessIdUtils";
|
|
||||||
|
|
||||||
export default function Folder() {
|
export default function Folder() {
|
||||||
const [_isArchivedModalOpen, _setIsArchivedModalOpen] = useState(true);
|
const [_isArchivedModalOpen, _setIsArchivedModalOpen] = useState(true);
|
||||||
@ -40,7 +39,7 @@ export default function Folder() {
|
|||||||
folders = folders.sort((a: any, b: any) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
folders = folders.sort((a: any, b: any) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
||||||
|
|
||||||
if (folders.length > 0) {
|
if (folders.length > 0) {
|
||||||
const folderUid = idAsUrl(folders[0]?.processId);
|
const folderUid = folders[0]?.processId;
|
||||||
|
|
||||||
if (!folderUid) {
|
if (!folderUid) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
* Utility functions to safely handle conversion between URL-friendly IDs and process IDs.
|
|
||||||
*
|
|
||||||
* Process IDs in the system use a ":0" suffix for API calls, but URLs use the clean ID without the suffix.
|
|
||||||
* These functions provide safe conversion between the two formats to avoid error-prone string manipulation.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a process ID to URL-friendly format by removing the ":0" suffix if present.
|
|
||||||
* Safe to call multiple times - won't remove ":0" from IDs that don't end with it.
|
|
||||||
*
|
|
||||||
* @param processId - The process ID that may or may not have ":0" suffix
|
|
||||||
* @returns The ID without ":0" suffix, suitable for use in URLs. Returns empty string for null/undefined.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* idAsUrl("abc123:0") // returns "abc123"
|
|
||||||
* idAsUrl("abc123") // returns "abc123" (no change)
|
|
||||||
* idAsUrl("abc:123:0") // returns "abc:123" (only removes trailing ":0")
|
|
||||||
* idAsUrl(null) // returns ""
|
|
||||||
* idAsUrl(undefined) // returns ""
|
|
||||||
*/
|
|
||||||
export function idAsUrl(processId: string | null | undefined): string {
|
|
||||||
if (!processId || typeof processId !== 'string') {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only remove ":0" if it's at the very end of the string
|
|
||||||
return processId.replace(/:0$/, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a URL-friendly ID to process ID format by adding ":0" suffix if not already present.
|
|
||||||
* Safe to call multiple times - won't add ":0" if it's already there.
|
|
||||||
*
|
|
||||||
* @param urlId - The URL-friendly ID that may or may not have ":0" suffix
|
|
||||||
* @returns The ID with ":0" suffix, suitable for use in API calls. Returns ":0" for null/undefined.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* idAsProcessId("abc123") // returns "abc123:0"
|
|
||||||
* idAsProcessId("abc123:0") // returns "abc123:0" (no change)
|
|
||||||
* idAsProcessId("abc:123") // returns "abc:123:0"
|
|
||||||
* idAsProcessId(null) // returns ""
|
|
||||||
* idAsProcessId(undefined) // returns ""
|
|
||||||
*/
|
|
||||||
export function idAsProcessId(urlId: string | null | undefined): string {
|
|
||||||
if (!urlId || typeof urlId !== 'string') {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only add ":0" if it's not already at the end
|
|
||||||
return urlId.endsWith(':0') ? urlId : `${urlId}:0`;
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user