import { request } from '../../lib/api' import type { RAssignment, RInterview, ROffer, RPlacement, RPlacementList } from '../../lib/types' const NS = '/recruiting' const body = (v: unknown) => ({ body: JSON.stringify(v) }) export const assignmentApi = { get: (appId: string) => request(`${NS}/applications/${encodeURIComponent(appId)}/assignment`), scheduleInterview: (appId: string, v: Record) => request(`${NS}/applications/${encodeURIComponent(appId)}/interviews`, { method: 'POST', ...body(v) }), updateInterview: (id: string, v: Record) => request(`${NS}/interviews/${encodeURIComponent(id)}`, { method: 'PATCH', ...body(v) }), extendOffer: (appId: string, v: Record) => request(`${NS}/applications/${encodeURIComponent(appId)}/offers`, { method: 'POST', ...body(v) }), respondToOffer: (id: string, v: { expected_status: string; status: string; decline_reason?: string }) => request(`${NS}/offers/${encodeURIComponent(id)}/status`, { method: 'POST', ...body(v) }), // Creating a placement moves the application to placed in the same transaction, so a full requisition // is refused here rather than discovered in a report later. createPlacement: (appId: string, v: Record) => request(`${NS}/applications/${encodeURIComponent(appId)}/placement`, { method: 'POST', ...body(v) }), endPlacement: (id: string, v: Record) => request(`${NS}/placements/${encodeURIComponent(id)}/end`, { method: 'POST', ...body(v) }), placements: (status?: string) => request(`${NS}/placements${status ? `?status=${encodeURIComponent(status)}` : ''}`), }