import { adminRequest } from "@/lib/admin-http"; import type { AdminDrawFinanceSummaryData } from "@/types/api/admin-draw-finance"; import type { AdminDrawBatchesData, AdminDrawActionResponse, AdminDrawListData, AdminDrawBatchCreateResponse, AdminDrawManualBatchPayload, AdminDrawPublishResponse, AdminDrawPlanGenerateResponse, AdminDrawShowData, AdminDrawCreatePayload, AdminDrawCreateResponse, } from "@/types/api/admin-draws"; const A = `/admin`; export type AdminDrawListQuery = { page?: number; per_page?: number; draw_no?: string; status?: string; }; export async function getAdminDraws(q: AdminDrawListQuery = {}): Promise { return adminRequest.get(`${A}/draws`, { params: q }); } export async function getAdminDraw(drawId: number): Promise { return adminRequest.get(`${A}/draws/${drawId}`); } export async function getAdminDrawResultBatches(drawId: number): Promise { return adminRequest.get(`${A}/draws/${drawId}/result-batches`); } export async function getAdminDrawFinanceSummary( drawId: number, ): Promise { return adminRequest.get( `${A}/draws/${drawId}/finance-summary`, ); } export async function postAdminPublishResultBatch( drawId: number, batchId: number, ): Promise { return adminRequest.post( `${A}/draws/${drawId}/result-batches/${batchId}/publish`, ); } export async function postAdminGenerateDrawPlan(): Promise { return adminRequest.post(`${A}/draws/generate-plan`); } export async function postAdminCreateDraw( payload: AdminDrawCreatePayload, ): Promise { return adminRequest.post(`${A}/draws`, payload); } export async function putAdminUpdateDraw( drawId: number, payload: AdminDrawCreatePayload, ): Promise { return adminRequest.put(`${A}/draws/${drawId}`, payload); } export async function deleteAdminDraw(drawId: number): Promise<{ deleted: boolean }> { return adminRequest.delete<{ deleted: boolean }>(`${A}/draws/${drawId}`); } export async function postAdminBatchDestroyDraws( drawIds: number[], ): Promise<{ success: number[]; failed: Array<{ id: number; reason: string }> }> { return adminRequest.post<{ success: number[]; failed: Array<{ id: number; reason: string }> }>( `${A}/draws/batch-destroy`, { draw_ids: drawIds }, ); } export async function postAdminManualCloseDraw(drawId: number): Promise { return adminRequest.post(`${A}/draws/${drawId}/manual-close`); } export async function postAdminCancelDraw(drawId: number): Promise { return adminRequest.post(`${A}/draws/${drawId}/cancel`); } export async function postAdminRunDrawRng(drawId: number): Promise { return adminRequest.post(`${A}/draws/${drawId}/rng`); } export async function postAdminCreateManualResultBatch( drawId: number, payload: AdminDrawManualBatchPayload, ): Promise { return adminRequest.post( `${A}/draws/${drawId}/result-batches`, payload, ); } export async function postAdminReopenDraw(drawId: number): Promise { return adminRequest.post(`${A}/draws/${drawId}/reopen`); }