Files
lcbp3/frontend/lib/services/rfa.service.ts
T
admin 67da186672
CI / CD Pipeline / build (push) Failing after 3m23s
CI / CD Pipeline / deploy (push) Has been skipped
feat(ai): implement unified prompt management UX/UI (ADR-037)
- Add context config endpoints (GET/PUT /api/ai/prompts/:type/:version/context-config)
- Add execution profile endpoints (CRUD /api/ai/execution-profiles)
- Add sandbox RAG Prep endpoint (POST /api/ai/admin/sandbox/rag-prep)
- Create Prompt Management UI with multi-type support
- Add ContextConfigEditor, PromptEditor, RuntimeParametersPanel components
- Add SandboxTabs for 3-step workflow (OCR, Extract, RAG Prep)
- Add database deltas for ai_execution_profiles and additional prompt types
- Update quickstart.md with production backend URLs
- Add comprehensive test coverage for new features
2026-06-14 19:55:43 +07:00

80 lines
2.4 KiB
TypeScript

// File: lib/services/rfa.service.ts
import apiClient from '@/lib/api/client';
import { CreateRfaDto, UpdateRfaDto, SearchRfaDto } from '@/types/dto/rfa/rfa.dto';
// DTO สำหรับการอนุมัติ (อาจจะย้ายไปไว้ใน folder dto/rfa/ ก็ได้ในอนาคต)
export interface WorkflowActionDto {
action: 'APPROVE' | 'REJECT' | 'COMMENT' | 'ACKNOWLEDGE';
comments?: string;
stepNumber?: number; // อาจจะไม่จำเป็นถ้า Backend เช็ค state ปัจจุบันได้เอง
}
export interface SubmitRfaDto {
reviewTeamPublicId?: string;
}
export const rfaService = {
/**
* ดึงรายการ RFA ทั้งหมด (รองรับ Search & Filter)
*/
getAll: async (params: SearchRfaDto) => {
// GET /rfas
const response = await apiClient.get('/rfas', { params });
return response.data;
},
/**
* ดึงรายละเอียด RFA และประวัติ Workflow
*/
getByUuid: async (uuid: string) => {
// GET /rfas/:uuid (ADR-019)
const response = await apiClient.get(`/rfas/${uuid}`);
return response.data;
},
/**
* สร้าง RFA ใหม่
*/
create: async (data: CreateRfaDto) => {
// POST /rfas
const response = await apiClient.post('/rfas', data);
return response.data;
},
/**
* Submit a Draft RFA to workflow
*/
submit: async (uuid: string, data: SubmitRfaDto) => {
// POST /rfas/:uuid/submit (ADR-019)
const response = await apiClient.post(`/rfas/${uuid}/submit`, data);
return response.data;
},
/**
* แก้ไข RFA (เฉพาะสถานะ Draft)
*/
update: async (uuid: string, data: UpdateRfaDto) => {
// PUT /rfas/:uuid (ADR-019)
const response = await apiClient.put(`/rfas/${uuid}`, data);
return response.data;
},
/**
* ดำเนินการ Workflow (อนุมัติ / ตีกลับ / ส่งต่อ)
*/
processWorkflow: async (uuid: string, actionData: WorkflowActionDto) => {
// POST /rfas/:uuid/action (ADR-019)
const response = await apiClient.post(`/rfas/${uuid}/action`, actionData);
return response.data;
},
/**
* (Optional) ลบ RFA (Soft Delete)
*/
delete: async (uuid: string) => {
// DELETE /rfas/:uuid (ADR-019)
const response = await apiClient.delete(`/rfas/${uuid}`);
return response.data;
},
};