Integrate committee ballots with Voting

This commit is contained in:
2026-08-01 20:57:25 +02:00
parent 758b59ca03
commit 133e55987e
12 changed files with 565 additions and 104 deletions
+37
View File
@@ -113,3 +113,40 @@ export function finalizeProviderBallot(
}
);
}
export async function finalizeVotingBallot(
settings: ApiSettings,
record: CommitteeRecord,
input: {
approvalId: string;
changeReason: string;
}
): Promise<CommitteeRecord> {
const ballotId = String(record.attributes.voting_ballot_id ?? "").trim();
const ballot = await apiFetch<{ revision: number }>(
settings,
`/api/v1/voting/${encodeURIComponent(ballotId)}`
);
return apiFetch<CommitteeRecord>(
settings,
`/api/v1/committee/workspace/vote/${encodeURIComponent(record.object_id)}/finalize-voting`,
{
method: "POST",
body: JSON.stringify({
voting_ballot_id: ballotId,
voting_expected_revision: ballot.revision,
approval_ref: {
kind: "approval",
owner_module: "approvals",
object_id: input.approvalId.trim(),
tenant_id: record.tenant_id,
version: "1"
},
expected_revision: record.revision,
recorded_at: new Date().toISOString(),
change_reason: input.changeReason.trim(),
idempotency_key: crypto.randomUUID()
})
}
);
}