diff --git a/frontend/components/analysis/RunButton.vue b/frontend/components/analysis/RunButton.vue index 76d8c5f..d814cc7 100644 --- a/frontend/components/analysis/RunButton.vue +++ b/frontend/components/analysis/RunButton.vue @@ -58,19 +58,19 @@ const request = computed(() => { } }) -const startRun = () => { +const startRun = async () => { emit('started') clicked.value = true - void withLoading( - () => pactaClient.runAnalysis(request.value) - .then((resp) => { analysisId.value = resp.analysisId }) - .then(() => { void refreshAnalysisState() }), + const resp = await withLoading( + () => pactaClient.runAnalysis(request.value), `${prefix}.runAnalysis`, ) + analysisId.value = resp.analysisId + void refreshAnalysisState() } -const runAnalysis = () => { +const runAnalysis = async () => { if (!props.warnForDuplicate) { - startRun() + await startRun() return } confirm({ diff --git a/frontend/pages/admin/merge.vue b/frontend/pages/admin/merge.vue index 8a21107..93b9a62 100644 --- a/frontend/pages/admin/merge.vue +++ b/frontend/pages/admin/merge.vue @@ -12,31 +12,34 @@ const fromUserId = useState(`${prefix}.fromUserId`, () => '') const toUserId = useState(`${prefix}.toUserId`, () => '') const done = useState(`${prefix}.done`, () => false) -// TODO(#168) An example of the error here. -const doMerge = (): void => { - void withLoading(() => pactaClient.mergeUsers({ +const doMerge = async () => { + await withLoading(() => pactaClient.mergeUsers({ fromUserId: fromUserId.value, toUserId: toUserId.value, - }).then((resp) => { - done.value = true }), `${prefix}.doMerge`) + + done.value = true } -const clickMerge = () => { - confirm({ - header: 'Are you 100% sure?', - message: 'This will transfer all assets from the source user to the destination user, and then delete the source user. This cannot be undone. Only proceed if you have tripple checked the user IDs and are confident in this procedure.', - icon: 'pi pi-user-minus', - position: 'center', - blockScroll: true, - reject: () => { /* noop */ }, - rejectLabel: 'Cancel', - rejectIcon: 'pi pi-times', - rejectClass: 'p-button-secondary p-button-text', - acceptClass: 'p-button-danger', - acceptLabel: 'Proceed', - accept: doMerge, - acceptIcon: 'pi pi-check', +const clickMerge = async () => { + await new Promise((resolve, reject) => { + confirm({ + header: 'Are you 100% sure?', + message: 'This will transfer all assets from the source user to the destination user, and then delete the source user. This cannot be undone. Only proceed if you have tripple checked the user IDs and are confident in this procedure.', + icon: 'pi pi-user-minus', + position: 'center', + blockScroll: true, + reject: () => { /* noop */ }, + rejectLabel: 'Cancel', + rejectIcon: 'pi pi-times', + rejectClass: 'p-button-secondary p-button-text', + acceptClass: 'p-button-danger', + acceptLabel: 'Proceed', + accept: () => { + doMerge().then(resolve).catch(reject) + }, + acceptIcon: 'pi pi-check', + }) }) }