251209:1453 Frontend: progress nest = UAT & Bug Fixing
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
import apiClient from "@/lib/api/client";
|
||||
|
||||
export interface AuditLogRaw {
|
||||
audit_log_id: number;
|
||||
user_id: number;
|
||||
user_name?: string;
|
||||
export interface AuditLog {
|
||||
auditId: string;
|
||||
userId?: number | null;
|
||||
user?: {
|
||||
id: number;
|
||||
fullName?: string;
|
||||
username: string;
|
||||
};
|
||||
action: string;
|
||||
entity_type: string;
|
||||
entity_id: string; // or number
|
||||
description: string;
|
||||
ip_address?: string;
|
||||
created_at: string;
|
||||
severity: string;
|
||||
entityType?: string;
|
||||
entityId?: string;
|
||||
detailsJson?: any;
|
||||
ipAddress?: string;
|
||||
userAgent?: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export const auditLogService = {
|
||||
getLogs: async (params?: any) => {
|
||||
const response = await apiClient.get<AuditLogRaw[]>("/audit-logs", { params });
|
||||
return response.data;
|
||||
}
|
||||
const response = await apiClient.get<any>("/audit-logs", { params });
|
||||
// Support both wrapped and unwrapped scenarios
|
||||
return response.data.data || response.data;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -14,7 +14,8 @@ export const masterDataService = {
|
||||
/** ดึงรายการ Tags ทั้งหมด (Search & Pagination) */
|
||||
getTags: async (params?: SearchTagDto) => {
|
||||
const response = await apiClient.get("/tags", { params });
|
||||
return response.data;
|
||||
// Support both wrapped and unwrapped scenarios
|
||||
return response.data.data || response.data;
|
||||
},
|
||||
|
||||
/** สร้าง Tag ใหม่ */
|
||||
@@ -39,8 +40,8 @@ export const masterDataService = {
|
||||
|
||||
/** ดึงรายชื่อองค์กรทั้งหมด */
|
||||
getOrganizations: async () => {
|
||||
const response = await apiClient.get<Organization[]>("/organizations");
|
||||
return response.data;
|
||||
const response = await apiClient.get<any>("/organizations");
|
||||
return response.data.data || response.data;
|
||||
},
|
||||
|
||||
/** สร้างองค์กรใหม่ */
|
||||
@@ -69,7 +70,7 @@ export const masterDataService = {
|
||||
const response = await apiClient.get("/master/disciplines", {
|
||||
params: { contractId }
|
||||
});
|
||||
return response.data;
|
||||
return response.data.data || response.data;
|
||||
},
|
||||
|
||||
/** สร้างสาขางานใหม่ */
|
||||
@@ -78,6 +79,12 @@ export const masterDataService = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/** ลบสาขางาน */
|
||||
deleteDiscipline: async (id: number) => {
|
||||
const response = await apiClient.delete(`/master/disciplines/${id}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// --- Sub-Types Management (Admin / Req 6B) ---
|
||||
|
||||
/** ดึงรายชื่อประเภทย่อย (กรองตาม Contract และ Type) */
|
||||
@@ -85,7 +92,7 @@ export const masterDataService = {
|
||||
const response = await apiClient.get("/master/sub-types", {
|
||||
params: { contractId, correspondenceTypeId: typeId }
|
||||
});
|
||||
return response.data;
|
||||
return response.data.data || response.data;
|
||||
},
|
||||
|
||||
/** สร้างประเภทย่อยใหม่ */
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// File: lib/services/project.service.ts
|
||||
import apiClient from "@/lib/api/client";
|
||||
import {
|
||||
CreateProjectDto,
|
||||
UpdateProjectDto,
|
||||
SearchProjectDto
|
||||
import {
|
||||
CreateProjectDto,
|
||||
UpdateProjectDto,
|
||||
SearchProjectDto
|
||||
} from "@/types/dto/project/project.dto";
|
||||
|
||||
export const projectService = {
|
||||
@@ -45,19 +45,21 @@ export const projectService = {
|
||||
|
||||
// --- Related Data / Dropdown Helpers ---
|
||||
|
||||
/** * ดึงรายชื่อองค์กรในโครงการ (สำหรับ Dropdown 'To/From')
|
||||
/** * ดึงรายชื่อองค์กรในโครงการ (สำหรับ Dropdown 'To/From')
|
||||
* GET /projects/:id/organizations
|
||||
*/
|
||||
getOrganizations: async (projectId: string | number) => {
|
||||
const response = await apiClient.get(`/projects/${projectId}/organizations`);
|
||||
return response.data;
|
||||
// Unwrap the response data if it's wrapped in a 'data' property by the interceptor
|
||||
return response.data.data || response.data;
|
||||
},
|
||||
|
||||
/** * ดึงรายชื่อสัญญาในโครงการ
|
||||
/** * ดึงรายชื่อสัญญาในโครงการ
|
||||
* GET /projects/:id/contracts
|
||||
*/
|
||||
getContracts: async (projectId: string | number) => {
|
||||
const response = await apiClient.get(`/projects/${projectId}/contracts`);
|
||||
return response.data;
|
||||
// Unwrap the response data if it's wrapped in a 'data' property by the interceptor
|
||||
return response.data.data || response.data;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,11 +3,19 @@ import { CreateUserDto, UpdateUserDto, SearchUserDto, User } from "@/types/user"
|
||||
|
||||
export const userService = {
|
||||
getAll: async (params?: SearchUserDto) => {
|
||||
const response = await apiClient.get<User[]>("/users", { params });
|
||||
// Assuming backend returns array or paginated object.
|
||||
// If backend uses standard pagination { data: [], total: number }, adjust accordingly.
|
||||
// Based on previous code checks, it seems simple array or standard structure.
|
||||
// Let's assume standard response for now.
|
||||
const response = await apiClient.get<any>("/users", { params });
|
||||
// Unwrap NestJS TransformInterceptor response
|
||||
if (response.data?.data) {
|
||||
return response.data.data as User[];
|
||||
}
|
||||
return response.data as User[];
|
||||
},
|
||||
|
||||
getRoles: async () => {
|
||||
const response = await apiClient.get<any>("/users/roles");
|
||||
if (response.data?.data) {
|
||||
return response.data.data;
|
||||
}
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user