Integrate committee ballots with Voting
This commit is contained in:
@@ -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()
|
||||
})
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user