Make createAndSend{Profile,Folder}Tx returns object
This commit is contained in:
parent
00bc3d8ad2
commit
39f2b086b5
@ -1852,7 +1852,7 @@ export default class Services {
|
|||||||
this.stateId = null;
|
this.stateId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createAndSendProfileTx(userData: any): Promise<void> {
|
public async createAndSendProfileTx(userData: any): Promise<{ processId: string, process: Process }> {
|
||||||
try {
|
try {
|
||||||
const createProfileProcessReturn = await this.createProfileProcess(
|
const createProfileProcessReturn = await this.createProfileProcess(
|
||||||
userData,
|
userData,
|
||||||
@ -1862,7 +1862,7 @@ export default class Services {
|
|||||||
this.setProcessId(createProfileProcessReturn.updated_process!.process_id);
|
this.setProcessId(createProfileProcessReturn.updated_process!.process_id);
|
||||||
this.setStateId(createProfileProcessReturn.updated_process!.current_process.states[0].state_id);
|
this.setStateId(createProfileProcessReturn.updated_process!.current_process.states[0].state_id);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`creatProfileProcess failed: ${e}`);
|
throw new Error(`createProfileProcess failed: ${e}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1875,16 +1875,24 @@ export default class Services {
|
|||||||
try {
|
try {
|
||||||
const approveChangeReturn = await this.approveChange(this.processId!, this.stateId!);
|
const approveChangeReturn = await this.approveChange(this.processId!, this.stateId!);
|
||||||
await this.handleApiReturn(approveChangeReturn);
|
await this.handleApiReturn(approveChangeReturn);
|
||||||
this.processId = null;
|
|
||||||
this.stateId = null;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`approveChange failed: ${e}`);
|
throw new Error(`approveChange failed: ${e}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the new process from db
|
||||||
|
const processId = this.processId!;
|
||||||
|
this.setProcessId(null);
|
||||||
|
this.setStateId(null);
|
||||||
|
const profileProcess = await this.getProcess(processId);
|
||||||
|
if (profileProcess) {
|
||||||
|
return {processId, process: profileProcess};
|
||||||
|
} else {
|
||||||
|
console.error('Failed to retrieve newly created profile process'); // This shouldn't happen
|
||||||
|
return { processId, process: { states: [] } };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async createAndSendFolderTx(folderData: any): Promise<{ processId: string, process: Process }> {
|
||||||
public async createAndSendFolderTx(folderData: any): Promise<void> {
|
|
||||||
try {
|
try {
|
||||||
await this.checkConnections([]);
|
await this.checkConnections([]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -1914,12 +1922,22 @@ export default class Services {
|
|||||||
try {
|
try {
|
||||||
const approveChangeReturn = await this.approveChange(this.processId!, this.stateId!);
|
const approveChangeReturn = await this.approveChange(this.processId!, this.stateId!);
|
||||||
await this.handleApiReturn(approveChangeReturn);
|
await this.handleApiReturn(approveChangeReturn);
|
||||||
this.processId = null;
|
|
||||||
this.stateId = null;
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`approveChange failed: ${e}`);
|
throw new Error(`approveChange failed: ${e}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the new process from db
|
||||||
|
const processId = this.processId!;
|
||||||
|
this.setProcessId(null);
|
||||||
|
this.setStateId(null);
|
||||||
|
console.log(`createAndSendFolderTx ~ processId: ${processId}`);
|
||||||
|
const folderProcess = await this.getProcess(processId);
|
||||||
|
if (folderProcess) {
|
||||||
|
return { processId, process: folderProcess };
|
||||||
|
} else {
|
||||||
|
console.error('Failed to retrieve newly created folder process'); // This shouldn't happen
|
||||||
|
return { processId, process: { states: [] } };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async generateProcessPdf(processId: string, processState: ProcessState): Promise<void> {
|
public async generateProcessPdf(processId: string, processState: ProcessState): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user