diff --git a/apps/api/src/server.ts b/apps/api/src/server.ts index 98df40b..166ccd9 100644 --- a/apps/api/src/server.ts +++ b/apps/api/src/server.ts @@ -563,6 +563,10 @@ export const app = new Elysia() params: t.Object({ id: t.String() }) }) .post("/:id/request-action", async ({ params: { id }, body: { reviewerNotes, activityVerifications } }) => { + const verification = await s.Verifications.get(id); + if (!verification) throw new NotFoundError("Verification not found"); + if (verification.status === "completed") throw status(409, { error: "Cannot modify a completed verification" }); + const updated = await s.Verifications.requestAction(id, reviewerNotes ?? null, activityVerifications); if (!updated) throw new NotFoundError("Verification not found"); }, { @@ -573,6 +577,10 @@ export const app = new Elysia() }) }) .post("/:id/complete", async ({ params: { id }, body: { activityVerifications }, accountId }) => { + const verification = await s.Verifications.get(id); + if (!verification) throw new NotFoundError("Verification not found"); + if (verification.status === "completed") throw status(409, { error: "Cannot modify a completed verification" }); + const updated = await s.Verifications.complete(id, accountId, activityVerifications); if (!updated) throw new NotFoundError("Verification not found"); }, { diff --git a/apps/portal/src/routes/(app)/verification/requests/[id]/+page.svelte b/apps/portal/src/routes/(app)/verification/requests/[id]/+page.svelte index 3b1b9c4..60e9c12 100644 --- a/apps/portal/src/routes/(app)/verification/requests/[id]/+page.svelte +++ b/apps/portal/src/routes/(app)/verification/requests/[id]/+page.svelte @@ -120,6 +120,7 @@ ACTIVITIES.filter((a) => verf[a] !== "unset").length, ); const allReviewed = $derived(reviewedCount === ACTIVITIES.length); + const isReadOnly = $derived(verification?.status === "completed"); async function load() { loading = true; @@ -152,6 +153,7 @@ } function setVerf(activity: Activity, choice: VerfChoice) { + if (isReadOnly) return; verf[activity] = choice; } @@ -290,6 +292,7 @@ class="btn btn-sm {verf[activity] === 'pass' ? 'btn-success' : 'btn-outline btn-success'}" + disabled={isReadOnly} onclick={() => setVerf(activity, "pass")} > Pass @@ -298,13 +301,14 @@ class="btn btn-sm {verf[activity] === 'fail' ? 'btn-error' : 'btn-outline btn-error'}" + disabled={isReadOnly} onclick={() => setVerf(activity, "fail")} > Fail -
- {#if !allReviewed} - Mark every activity Pass or Fail to completeThis verification is completed and read-only. + {:else} +
+ {#if !allReviewed} + Mark every activity Pass or Fail to complete + {/if} + - -
+ {submitting === "action" + ? "Submitting..." + : "Request action"} + + +
+ {/if} {/if}