import { request } from '../../lib/api' // TrackedOpportunity is the app facing view of a tenant tracked opportunity, snake_case to match the Go DTO. export interface TrackedOpportunity { id: string source_type: string title: string agency_name: string office_name: string solicitation_number: string notice_type: string response_deadline: string prime_or_sub: string status: string capture_owner_user_id: string naics_code: string psc_code: string set_aside_code: string place_of_performance: string incumbent_name: string source_url: string created_at: string updated_at: string } // The capture surface sits under /opportunities/tracked because the public SAM cache read owns // /opportunities/{noticeID}. request auto prefixes /api and attaches the session cookie and CSRF token. const NS = '/opportunities/tracked' const body = (v: unknown) => ({ body: JSON.stringify(v) }) export const captureApi = { list: (p: { status?: string; limit?: number }) => { const s = new URLSearchParams() if (p.status) s.set('status', p.status) if (p.limit) s.set('limit', String(p.limit)) const qs = s.toString() return request(`${NS}${qs ? `?${qs}` : ''}`) }, get: (id: string) => request(`${NS}/${encodeURIComponent(id)}`), create: (v: Record) => request(NS, { method: 'POST', ...body(v) }), update: (id: string, v: Record) => request(`${NS}/${encodeURIComponent(id)}`, { method: 'PATCH', ...body(v) }), }