// slateMATCH API client: every call targets the /api/slatematch namespace over the ONE shared scoring // core, so a slate member's score equals the same candidate's score in screenMATCH and missionMATCH. // It reuses the shared request helper; only the paths differ. import { request } from '../../lib/api' import type { CandidateListView, ProposalReadinessView, RequirementListView, SlateDetailView, SlateResult, SlateSummaryView, } from '../../lib/types' const NS = '/slatematch' export const slateApi = { requirements: () => request(`${NS}/requirements?limit=200`), candidates: () => request(`${NS}/candidates?limit=200`), generate: (requirement_id: string, name: string) => request(`${NS}/slates/generate`, { method: 'POST', body: JSON.stringify({ requirement_id, name }), }), slatesFor: (requirementId: string) => request(`${NS}/requirements/${encodeURIComponent(requirementId)}/slates`), detail: (slateId: string) => request(`${NS}/slates/${encodeURIComponent(slateId)}`), readiness: (slateId: string) => request(`${NS}/slates/${encodeURIComponent(slateId)}/proposal-readiness`), // Human in the loop: a person approves or rejects a member, optionally with a note. decide: (slateId: string, candidateId: string, decision: 'approved' | 'rejected', note: string) => request<{ status: string }>( `${NS}/slates/${encodeURIComponent(slateId)}/members/${encodeURIComponent(candidateId)}/decision`, { method: 'PATCH', body: JSON.stringify({ decision, note }) }, ), // The branded CSV export is a same origin GET; the session cookie rides along, so an anchor download // to this URL streams the file with its Content-Disposition filename. exportUrl: (slateId: string) => `/api/slatematch/slates/${encodeURIComponent(slateId)}/export`, }