Download the new process in json file

This commit is contained in:
NicolasCantu 2025-06-05 15:39:33 +02:00
parent 23a3b2a9e8
commit c5b58d999f

View File

@ -53,6 +53,19 @@ export async function getProcessCreation(container: HTMLElement) {
const approveChangeResult = await service.approveChange(processId, stateId);
await service.handleApiReturn(approveChangeResult);
if (approveChangeResult) {
const process = await service.getProcess(processId);
const newState = service.getStateFromId(process, stateId);
const blob = new Blob([JSON.stringify(newState, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `process_${processId}_${stateId}.json`;
a.click();
URL.revokeObjectURL(url); // Clean up
}
};
container.appendChild(btn);