Update approveChange

This commit is contained in:
NicolasCantu 2025-03-12 15:44:00 +01:00
parent 3a851d1b62
commit c82c219a28
4 changed files with 16 additions and 12 deletions

View File

@ -349,7 +349,7 @@ class ChatElement extends HTMLElement {
await service.handleApiReturn(createPrdReturn);
// Now we validate the new state
const approveChangeReturn = service.approveChange(this.selectedChatProcessId, newStateId);
const approveChangeReturn = await service.approveChange(this.selectedChatProcessId, newStateId);
await service.handleApiReturn(approveChangeReturn);
await this.lookForMyDms();
@ -672,7 +672,7 @@ class ChatElement extends HTMLElement {
this.selectedChatProcessId = processId;
const createPrdReturn = await service.createPrdUpdate(processId, stateId);
await service.handleApiReturn(createPrdReturn);
const approveChangeReturn = service.approveChange(processId, stateId);
const approveChangeReturn = await service.approveChange(processId, stateId);
await service.handleApiReturn(approveChangeReturn);
}, 500);
} catch (e) {

View File

@ -479,7 +479,7 @@ async function createMessagingProcess(): Promise<void> {
await service.handleApiReturn(createProcessReturn);
const createPrdReturn = await service.createPrdUpdate(processId, stateId);
await service.handleApiReturn(createPrdReturn);
const approveChangeReturn = service.approveChange(processId, stateId);
const approveChangeReturn = await service.approveChange(processId, stateId);
await service.handleApiReturn(approveChangeReturn);
}, 500)
}

View File

@ -185,7 +185,7 @@ export default class ModalService {
// We send confirmation that we validate the change
try {
const approveChangeReturn = service.approveChange(this.processId!, this.stateId!);
const approveChangeReturn = await service.approveChange(this.processId!, this.stateId!);
await service.handleApiReturn(approveChangeReturn);
await this.injectWaitingModal();
@ -234,7 +234,7 @@ export default class ModalService {
// We send confirmation that we validate the change
try {
const approveChangeReturn = service.approveChange(this.processId!, this.stateId!);
const approveChangeReturn = await service.approveChange(this.processId!, this.stateId!);
await service.handleApiReturn(approveChangeReturn);
} catch (e) {
throw e;

View File

@ -389,21 +389,25 @@ export default class Services {
}
}
public approveChange(processId: string, stateId: string): ApiReturn {
public async approveChange(processId: string, stateId: string): Promise<ApiReturn> {
const process = await this.getProcess(processId);
if (!process) {
throw new Error('Failed to get process from db');
}
try {
return this.sdkClient.validate_state(processId, stateId);
return this.sdkClient.validate_state(process, stateId);
} catch (e) {
throw new Error(`Failed to create prd response: ${e}`);
}
}
public rejectChange(): ApiReturn {
if (!this.currentProcess || !this.currentUpdateMerkleRoot) {
throw new Error('No current process and/or current update defined');
public async rejectChange(processId: string, stateId: string): Promise<ApiReturn> {
const process = await this.getProcess(processId);
if (!process) {
throw new Error('Failed to get process from db');
}
try {
return this.sdkClient.refuse_state(this.currentProcess, this.currentUpdateMerkleRoot);
return this.sdkClient.refuse_state(process, stateId);
} catch (e) {
throw new Error(`Failed to create prd response: ${e}`);
}