Fix some issues

This commit is contained in:
Anthony Janin 2025-07-17 08:17:15 +02:00
parent 97e86308ce
commit 2500e19e71
9 changed files with 331 additions and 153 deletions

View File

@ -1,13 +1,17 @@
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import MessageBus from 'src/sdk/MessageBus';
import User from 'src/sdk/User'; import User from 'src/sdk/User';
export default class RoleService { import AbstractService from './AbstractService';
private static readonly messageBus: MessageBus = MessageBus.getInstance(); import OfficeService from './OfficeService';
import RuleService from './RuleService';
private constructor() { } export default class RoleService extends AbstractService {
private constructor() {
super();
}
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 = User.getInstance().getPairingId()!;
@ -70,7 +74,7 @@ export default class RoleService {
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => { this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => { this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => { this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
resolve(processCreated); this.getRoleByUid(processCreated.processData.uid).then(resolve).catch(reject);
}).catch(reject); }).catch(reject);
}).catch(reject); }).catch(reject);
}).catch(reject); }).catch(reject);
@ -78,16 +82,58 @@ export default class RoleService {
} }
public static getRoles(): Promise<any[]> { public static getRoles(): Promise<any[]> {
return this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['utype'] && publicValues['utype'] === 'role' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false'); // Check if we have valid cache
const items: any[] = this.getItems('_roles_');
return this.messageBus.getProcessesDecoded((publicValues: any) =>
publicValues['uid'] &&
publicValues['utype'] &&
publicValues['utype'] === 'role' &&
publicValues['isDeleted'] &&
publicValues['isDeleted'] === 'false' &&
!items.map((item: any) => item.processData.uid).includes(publicValues['uid'])
).then(async (processes: any[]) => {
if (processes.length === 0) {
return items;
} else {
for (let process of processes) {
process = await this.completeRole(process);
// Update cache
this.setItem('_roles_', process);
items.push(process);
}
return items;
}
});
} }
public static getRoleByUid(uid: string): Promise<any> { public static getRoleByUid(uid: string): Promise<any> {
// Check if we have valid cache
const item: any = this.getItem('_roles_', uid);
if (item) {
return Promise.resolve(item);
}
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => { return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
this.messageBus.getProcessesDecoded((publicValues: any) => publicValues['uid'] && publicValues['uid'] === uid && publicValues['utype'] && publicValues['utype'] === 'role' && publicValues['isDeleted'] && publicValues['isDeleted'] === 'false').then(async (processes: any[]) => { this.messageBus.getProcessesDecoded((publicValues: any) =>
publicValues['uid'] &&
publicValues['uid'] === uid &&
publicValues['utype'] &&
publicValues['utype'] === 'role' &&
publicValues['isDeleted'] &&
publicValues['isDeleted'] === 'false'
).then(async (processes: any[]) => {
if (processes.length === 0) { if (processes.length === 0) {
resolve(null); resolve(null);
} else { } else {
const process: any = processes[0]; let process: any = processes[0];
process = await this.completeRole(process);
// Update cache
this.setItem('_roles_', process);
resolve(process); resolve(process);
} }
}).catch(reject); }).catch(reject);
@ -100,10 +146,34 @@ export default class RoleService {
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((_stateValidated) => { this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
resolve(); const roleUid: string = process.processData.uid;
this.removeItem('_roles_', roleUid);
this.getRoleByUid(roleUid).then(resolve).catch(reject);
}).catch(reject); }).catch(reject);
}).catch(reject); }).catch(reject);
}).catch(reject); }).catch(reject);
}); });
} }
private static async completeRole(process: any): Promise<any> {
if (process.processData.office) {
process.processData.office = await new Promise<any>(async (resolve: (office: any) => void) => {
const office: any = (await OfficeService.getOfficeByUid(process.processData.office.uid)).processData;
resolve(office);
});
}
if (process.processData.rules && process.processData.rules.length > 0) {
process.processData.rules = await new Promise<any[]>(async (resolve: (rules: any[]) => void) => {
const rules: any[] = [];
for (const rule of process.processData.rules) {
rules.push((await RuleService.getRuleByUid(rule.uid)).processData);
}
resolve(rules);
});
}
return process;
}
} }

View File

@ -0,0 +1,152 @@
import { v4 as uuidv4 } from 'uuid';
import User from 'src/sdk/User';
import AbstractService from './AbstractService';
export default class RuleService extends AbstractService {
private constructor() {
super();
}
public static createRule(ruleData: any, validatorId: string): Promise<any> {
const ownerId = User.getInstance().getPairingId()!;
const processData: any = {
uid: uuidv4(),
utype: 'rule',
isDeleted: 'false',
created_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
...ruleData,
};
const privateFields: string[] = Object.keys(processData);
privateFields.splice(privateFields.indexOf('uid'), 1);
privateFields.splice(privateFields.indexOf('utype'), 1);
privateFields.splice(privateFields.indexOf('isDeleted'), 1);
const roles: any = {
demiurge: {
members: [...[ownerId], validatorId],
validation_rules: [],
storages: []
},
owner: {
members: [ownerId],
validation_rules: [
{
quorum: 0.5,
fields: [...privateFields, 'roles', 'uid', 'utype'],
min_sig_member: 1,
},
],
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: {
members: [ownerId],
validation_rules: [],
storages: []
}
};
return new Promise<any>((resolve: (processCreated: any) => void, reject: (error: string) => void) => {
this.messageBus.createProcess(processData, privateFields, roles).then((processCreated: any) => {
this.messageBus.notifyUpdate(processCreated.processId, processCreated.process.states[0].state_id).then(() => {
this.messageBus.validateState(processCreated.processId, processCreated.process.states[0].state_id).then((_stateValidated: any) => {
this.getRuleByUid(processCreated.processData.uid).then(resolve).catch(reject);
}).catch(reject);
}).catch(reject);
}).catch(reject);
});
}
public static getRules(): Promise<any[]> {
// Check if we have valid cache
const items: any[] = this.getItems('_rules_');
return this.messageBus.getProcessesDecoded((publicValues: any) =>
publicValues['uid'] &&
publicValues['utype'] &&
publicValues['utype'] === 'rule' &&
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('_rules_', process);
items.push(process);
}
return items;
}
});
}
public static getRuleByUid(uid: string): Promise<any> {
// Check if we have valid cache
const item: any = this.getItem('_rules_', uid);
if (item) {
return Promise.resolve(item);
}
return new Promise<any>((resolve: (process: any) => void, reject: (error: string) => void) => {
this.messageBus.getProcessesDecoded((publicValues: any) =>
publicValues['uid'] &&
publicValues['uid'] === uid &&
publicValues['utype'] &&
publicValues['utype'] === 'rule' &&
publicValues['isDeleted'] &&
publicValues['isDeleted'] === 'false'
).then((processes: any[]) => {
if (processes.length === 0) {
resolve(null);
} else {
const process: any = processes[0];
// Update cache
this.setItem('_rules_', process);
resolve(process);
}
}).catch(reject);
});
}
public static updateRule(process: any, newData: any): Promise<void> {
return new Promise<void>((resolve: () => void, reject: (error: string) => void) => {
this.messageBus.updateProcess(process.processId, { updated_at: new Date().toISOString(), ...newData }, [], null).then((processUpdated: any) => {
const newStateId: string = processUpdated.diffs[0]?.state_id;
this.messageBus.notifyUpdate(process.processId, newStateId).then(() => {
this.messageBus.validateState(process.processId, newStateId).then((_stateValidated) => {
const ruleUid: string = process.processData.uid;
this.removeItem('_rules_', ruleUid);
this.getRuleByUid(ruleUid).then(resolve).catch(reject);
}).catch(reject);
}).catch(reject);
}).catch(reject);
});
}
}

View File

@ -5,7 +5,7 @@ import Module from "@Front/Config/Module";
import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block"; import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block";
import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList"; import DefaultDashboardWithList, { IPropsDashboardWithList } from "../DefaultDashboardWithList";
import { v4 as uuidv4 } from 'uuid'; import UserStore from "@Front/Stores/UserStore";
import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService"; import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService";
@ -13,111 +13,32 @@ type IProps = IPropsDashboardWithList;
export default function DefaultRoleDashboard(props: IProps) { export default function DefaultRoleDashboard(props: IProps) {
const [roles, setRoles] = React.useState<any[] | null>(null); const [roles, setRoles] = React.useState<any[] | null>(null);
const router = useRouter(); const router = useRouter();
const { roleUid } = router.query; const { roleUid } = router.query;
useEffect(() => { useEffect(() => {
/* TODO: review const user: any = UserStore.instance.getUser();
const query: IGetRolesParams = { if (!user) {
include: { rules: true }, return;
}; }
OfficeRoles.getInstance() const office: any = user.office;
.get(query) if (!office) {
.then((roles) => setRoles(roles)); return;
*/
const roles: any[] = [
{
uid: uuidv4(),
name: 'Notaire',
office: {
name: '',
crpcen: '',
created_at: new Date(),
updated_at: new Date()
},
rules: [
{
uid: uuidv4(),
name: "Gestion de l'abonnement",
label: "Gestion de l'abonnement",
namespace: "Gestion de l'abonnement",
created_at: new Date(),
updated_at: new Date()
},
{
uid: uuidv4(),
name: "Gestion des matrices d'actes et des documents",
label: "Gestion des matrices d'actes et des documents",
namespace: "Gestion des matrices d'actes et des documents",
created_at: new Date(),
updated_at: new Date()
},
{
uid: uuidv4(),
name: "Intégration du RIB",
label: "Intégration du RIB",
namespace: "Intégration du RIB",
created_at: new Date(),
updated_at: new Date()
} }
],
created_at: new Date(),
updated_at: new Date(),
},
{
uid: uuidv4(),
name: 'Collaborateur',
office: {
name: '',
crpcen: '',
created_at: new Date(),
updated_at: new Date()
},
rules: [
{
uid: uuidv4(),
name: "Gestion de l'abonnement",
label: "Gestion de l'abonnement",
namespace: "Gestion de l'abonnement",
created_at: new Date(),
updated_at: new Date()
},
{
uid: uuidv4(),
name: "Gestion des matrices d'actes et des documents",
label: "Gestion des matrices d'actes et des documents",
namespace: "Gestion des matrices d'actes et des documents",
created_at: new Date(),
updated_at: new Date()
},
{
uid: uuidv4(),
name: "Intégration du RIB",
label: "Intégration du RIB",
namespace: "Intégration du RIB",
created_at: new Date(),
updated_at: new Date()
}
],
created_at: new Date(),
updated_at: new Date(),
}
];
RoleService.getRoles().then(async (processes: any[]) => { RoleService.getRoles().then(async (processes: any[]) => {
if (processes.length > 0) { if (processes.length > 0) {
const roles: any[] = processes.map((process: any) => process.processData); let roles: any[] = processes.map((process: any) => process.processData);
setRoles(roles);
} else { // FilterBy office.uid
/* roles = roles.filter((role: any) => role.office.uid === office.uid);
for (let role of roles) {
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0'; // OrderBy label
roles = roles.sort((a: any, b: any) => a.label.localeCompare(b.label));
await RoleService.createRole(role, validatorId);
}
setRoles(roles); setRoles(roles);
*/
} }
}); });
}, []); }, []);

View File

@ -348,18 +348,13 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
await new Promise<void>((resolve: () => void) => { await new Promise<void>((resolve: () => void) => {
FileService.getFileByUid(process.processData.files[0].uid).then((p) => { FileService.getFileByUid(process.processData.files[0].uid).then((p) => {
if (p) { if (p) {
alert(`aplc-${p.processData.file_name}`) FileService.updateFile(p, {
FileService.updateFile(p, { file_name: `aplc-${p.processData.file_name}` }).then(resolve); file_name: `aplc-${p.processData.file_name}`
}).then(resolve);
} }
}); });
}); });
FileService.getFileByUid(process.processData.files[0].uid).then((process) => {
if (process) {
console.log(process.processData);
}
});
/* /*
this.props.router.push( this.props.router.push(
Module.getInstance() Module.getInstance()
@ -370,7 +365,6 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
); );
*/ */
/*
DocumentService.updateDocument(process, { document_status: EDocumentStatus.VALIDATED }).then(() => { DocumentService.updateDocument(process, { document_status: EDocumentStatus.VALIDATED }).then(() => {
this.props.router.push( this.props.router.push(
Module.getInstance() Module.getInstance()
@ -380,7 +374,6 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
this.state.document?.depositor?.uid, this.state.document?.depositor?.uid,
); );
}); });
*/
} }
}); });
} catch (e) { } catch (e) {

View File

@ -85,9 +85,6 @@ export default function Login() {
const onSmsCodeSubmit = useCallback( const onSmsCodeSubmit = useCallback(
async (e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) => { async (e: React.FormEvent<HTMLFormElement> | null, values: { [key: string]: string }) => {
try { try {
console.log(values);
console.log(email);
if (!values["totpCode"]) return; if (!values["totpCode"]) return;
/* /*
const res = await Auth.getInstance().verifyTotpCode({ totpCode: values["totpCode"], email }); const res = await Auth.getInstance().verifyTotpCode({ totpCode: values["totpCode"], email });

View File

@ -17,8 +17,9 @@ import AuthModal from "src/sdk/AuthModal";
import MessageBus from "src/sdk/MessageBus"; import MessageBus from "src/sdk/MessageBus";
import Iframe from "src/sdk/Iframe"; import Iframe from "src/sdk/Iframe";
import OfficeService from "src/common/Api/LeCoffreApi/sdk/OfficeService"; import RuleService from "src/common/Api/LeCoffreApi/sdk/RuleService";
import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService"; import RoleService from "src/common/Api/LeCoffreApi/sdk/RoleService";
import OfficeService from "src/common/Api/LeCoffreApi/sdk/OfficeService";
import CollaboratorService from "src/common/Api/LeCoffreApi/sdk/CollaboratorService"; import CollaboratorService from "src/common/Api/LeCoffreApi/sdk/CollaboratorService";
export default function LoginCallBack() { export default function LoginCallBack() {
@ -42,13 +43,12 @@ export default function LoginCallBack() {
create: { create: {
address: idNotUser.office.address.address, address: idNotUser.office.address.address,
zip_code: idNotUser.office.address.zip_code, zip_code: idNotUser.office.address.zip_code,
city: idNotUser.office.address.city, city: idNotUser.office.address.city
}, }
}, },
office_status: 'ACTIVATED' office_status: 'ACTIVATED'
}; };
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0'; const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
OfficeService.createOffice(officeData, validatorId).then((process: any) => { OfficeService.createOffice(officeData, validatorId).then((process: any) => {
if (process) { if (process) {
const office: any = process.processData; const office: any = process.processData;
@ -60,28 +60,69 @@ export default function LoginCallBack() {
}); });
}; };
const getRole = async (idNotUser: any) => { const getRoles = async (office: any) => {
return await new Promise<any>((resolve: (role: any) => void) => { const rules: any[] = await new Promise<any[]>((resolve: (rules: any[]) => void) => {
RoleService.getRoles().then((processes: any[]) => { const defaultRules: any[] = [
const roleFound: any = processes.length > 0 ? processes.map((process: any) => process.processData).find((role: any) => role.name === idNotUser.role.name) : null; {
if (roleFound) { name: "subscription",
resolve(roleFound); label: "Gestion de l'abonnement",
} else { namespace: "Gestion de l'abonnement"
const roleData: any = { },
name: idNotUser.role!.name, {
label: idNotUser.role!.label name: "document_types",
}; label: "Gestion des matrices d'actes et des documents",
namespace: "Gestion des matrices d'actes et des documents"
},
{
name: "rib",
label: "Intégration du RIB",
namespace: "Intégration du RIB"
}
];
RuleService.getRules().then(async (processes: any[]) => {
const rules: any[] = processes.map((process: any) => process.processData);
if (rules.length === 0) {
for (let ruleData of defaultRules) {
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0'; const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
rules.push((await RuleService.createRule(ruleData, validatorId)).processData);
}
}
resolve(rules);
});
});
RoleService.createRole(roleData, validatorId).then((process: any) => { const roles: any[] = await new Promise<any[]>((resolve: (roles: any[]) => void) => {
if (process) { const defaultRoles: any[] = [
const role: any = process.processData; {
resolve(role); name: 'notary',
label: 'Notaire',
office: {
uid: office.uid
},
rules: rules.map((rule: any) => ({ uid: rule.uid }))
},
{
name: 'collaborator',
label: 'Collaborateur',
office: {
uid: office.uid
},
rules: rules.map((rule: any) => ({ uid: rule.uid }))
} }
}); ];
RoleService.getRoles().then(async (processes: any[]) => {
const roles: any[] = processes.map((process: any) => process.processData);
if (roles.length === 0) {
for (let roleData of defaultRoles) {
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
roles.push((await RoleService.createRole(roleData, validatorId)).processData);
} }
}
resolve(roles);
}); });
}); });
return roles;
}; };
const getCollaborator = async (collaboratorData: any) => { const getCollaborator = async (collaboratorData: any) => {
@ -92,7 +133,6 @@ export default function LoginCallBack() {
resolve(collaboratorFound); resolve(collaboratorFound);
} else { } else {
const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0'; const validatorId: string = '884cb36a346a79af8697559f16940141f068bdf1656f88fa0df0e9ecd7311fb8:0';
CollaboratorService.createCollaborator(collaboratorData, validatorId).then((process: any) => { CollaboratorService.createCollaborator(collaboratorData, validatorId).then((process: any) => {
if (process) { if (process) {
const collaborator: any = process.processData; const collaborator: any = process.processData;
@ -191,7 +231,9 @@ export default function LoginCallBack() {
MessageBus.getInstance().initMessageListener(); MessageBus.getInstance().initMessageListener();
MessageBus.getInstance().isReady().then(async () => { MessageBus.getInstance().isReady().then(async () => {
const office: any = await getOffice(idNotUser); const office: any = await getOffice(idNotUser);
const role: any = await getRole(idNotUser);
const roles: any[] = await getRoles(office);
const role: any = roles.find((role: any) => role.name === idNotUser.role.name);
const collaboratorData: any = { const collaboratorData: any = {
idNot: idNotUser.idNot, idNot: idNotUser.idNot,

View File

@ -25,7 +25,7 @@ export default function RolesInformations() {
let { roleUid } = router.query; let { roleUid } = router.query;
const [roleSelected, setRoleSelected] = useState<any | null>(null); const [roleSelected, setRoleSelected] = useState<any | null>(null);
const [rulesGroupsCheckboxes, setRulesGroupsCheckboxes] = useState<RuleGroupsCheckbox[]>([]); const [rulesGroupsCheckboxes, setRulesGroupsCheckboxes] = useState<any[]>([]);
const [selectAll, setSelectAll] = useState<boolean>(false); const [selectAll, setSelectAll] = useState<boolean>(false);
const [isConfirmModalOpened, setIsConfirmModalOpened] = useState<boolean>(false); const [isConfirmModalOpened, setIsConfirmModalOpened] = useState<boolean>(false);
@ -190,7 +190,7 @@ export default function RolesInformations() {
{rulesGroupsCheckboxes.map((ruleGroup) => ( {rulesGroupsCheckboxes.map((ruleGroup) => (
<div className={classes["right"]} key={ruleGroup.uid}> <div className={classes["right"]} key={ruleGroup.uid}>
<CheckBox <CheckBox
option={{ label: ruleGroup.name!, value: ruleGroup.uid }} option={{ label: ruleGroup.label!, value: ruleGroup.uid }}
checked={ruleGroup.checked} checked={ruleGroup.checked}
onChange={handleRuleChange} onChange={handleRuleChange}
/> />

View File

@ -19,7 +19,6 @@ import FolderService from "src/common/Api/LeCoffreApi/sdk/FolderService";
export default function SelectFolder() { export default function SelectFolder() {
const router = useRouter(); const router = useRouter();
const [customer, setCustomer] = useState<any>(null);
const [folders, setFolders] = useState<OfficeFolder[]>([]); const [folders, setFolders] = useState<OfficeFolder[]>([]);
useEffect(() => { useEffect(() => {
@ -27,8 +26,6 @@ export default function SelectFolder() {
if (!customer) { if (!customer) {
return; return;
} }
setCustomer(customer);
LoaderService.getInstance().show(); LoaderService.getInstance().show();
FolderService.getFolders().then((processes: any[]) => { FolderService.getFolders().then((processes: any[]) => {
if (processes.length > 0) { if (processes.length > 0) {
@ -48,6 +45,10 @@ export default function SelectFolder() {
const handleSelectBlock = useCallback( const handleSelectBlock = useCallback(
(folder: IBlock) => { (folder: IBlock) => {
const customer: any = UserStore.instance.getUser();
if (!customer) {
return;
}
router.push( router.push(
Module.getInstance() Module.getInstance()
.get() .get()

View File

@ -140,13 +140,15 @@ export default class MessageBus {
let file: any; let file: any;
// Which is the last state that updated file_blob? // Which is the last state that updated file_blob?
const lastUpdatedFileNameState = process.states.findLast((state: any) => state.pcd_commitment['file_name']);
const lastUpdatedFileState = process.states.findLast((state: any) => state.pcd_commitment['file_blob']); const lastUpdatedFileState = process.states.findLast((state: any) => state.pcd_commitment['file_blob']);
if (!lastUpdatedFileNameState || !lastUpdatedFileState) {
if (!lastUpdatedFileState) {
continue; continue;
} }
try { try {
const fileName: string = (await this.getData(processId, lastUpdatedFileNameState.state_id)).file_name;
const processData = await this.getData(processId, lastUpdatedFileState.state_id); const processData = await this.getData(processId, lastUpdatedFileState.state_id);
const isEmpty = Object.keys(processData).length === 0; const isEmpty = Object.keys(processData).length === 0;
if (isEmpty) { if (isEmpty) {
@ -158,7 +160,6 @@ export default class MessageBus {
continue; continue;
} }
if (!file) { if (!file) {
file = { file = {
processId, processId,
@ -175,6 +176,7 @@ export default class MessageBus {
file.publicDataDecoded[key] = publicDataDecoded[key]; file.publicDataDecoded[key] = publicDataDecoded[key];
} }
} }
file.processData.file_name = fileName;
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }