690328:1703 Fixing Refactor uuid by Kimi #11
CI / CD Pipeline / build (push) Successful in 8m10s
CI / CD Pipeline / deploy (push) Successful in 4m26s

This commit is contained in:
2026-03-28 17:03:12 +07:00
parent 57a3ed2d37
commit 7a9a15560b
15 changed files with 82 additions and 54 deletions
+14 -4
View File
@@ -3,27 +3,30 @@ import { User, CreateUserDto, Organization, AuditLog } from '@/types/admin';
// Mock Data
const mockUsers: User[] = [
{
publicId: 'user-001',
userId: 1,
username: 'admin',
email: 'admin@example.com',
firstName: 'System',
lastName: 'Admin',
isActive: true,
roles: [{ roleId: 1, roleName: 'ADMIN', description: 'Administrator' }],
roles: [{ publicId: 'role-001', roleId: 1, roleName: 'ADMIN', description: 'Administrator' }],
},
{
publicId: 'user-002',
userId: 2,
username: 'jdoe',
email: 'john.doe@example.com',
firstName: 'John',
lastName: 'Doe',
isActive: true,
roles: [{ roleId: 2, roleName: 'USER', description: 'Regular User' }],
roles: [{ publicId: 'role-002', roleId: 2, roleName: 'USER', description: 'Regular User' }],
},
];
const mockOrgs: Organization[] = [
{
publicId: 'org-001',
orgId: 1,
orgCode: 'PAT',
orgName: 'Port Authority of Thailand',
@@ -31,6 +34,7 @@ const mockOrgs: Organization[] = [
description: 'Owner',
},
{
publicId: 'org-002',
orgId: 2,
orgCode: 'CNPC',
orgName: 'CNPC Consortium',
@@ -40,6 +44,7 @@ const mockOrgs: Organization[] = [
const mockLogs: AuditLog[] = [
{
publicId: 'log-001',
auditLogId: 1,
userName: 'admin',
action: 'CREATE',
@@ -49,6 +54,7 @@ const mockLogs: AuditLog[] = [
createdAt: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(),
},
{
publicId: 'log-002',
auditLogId: 2,
userName: 'jdoe',
action: 'UPDATE',
@@ -67,14 +73,17 @@ export const adminApi = {
createUser: async (data: CreateUserDto): Promise<User> => {
await new Promise((resolve) => setTimeout(resolve, 800));
const maxId = mockUsers.length > 0 ? Math.max(...mockUsers.map((u) => u.userId ?? 0)) : 0;
const newUser: User = {
userId: Math.max(...mockUsers.map((u) => u.userId)) + 1,
publicId: `user-${String(maxId + 1).padStart(3, '0')}`,
userId: maxId + 1,
username: data.username,
email: data.email,
firstName: data.firstName,
lastName: data.lastName,
isActive: data.isActive,
roles: data.roles.map((id) => ({
publicId: `role-${String(id).padStart(3, '0')}`,
roleId: id,
roleName: id === 1 ? 'ADMIN' : 'USER',
description: '',
@@ -91,7 +100,8 @@ export const adminApi = {
createOrganization: async (data: Omit<Organization, 'orgId'>): Promise<Organization> => {
await new Promise((resolve) => setTimeout(resolve, 600));
const newOrg = { ...data, orgId: Math.max(...mockOrgs.map((o) => o.orgId)) + 1 };
const maxId = mockOrgs.length > 0 ? Math.max(...mockOrgs.map((o) => o.orgId ?? 0)) : 0;
const newOrg: Organization = { ...data, publicId: data.publicId || `org-${String(maxId + 1).padStart(3, '0')}`, orgId: maxId + 1 };
mockOrgs.push(newOrg);
return newOrg;
},
+5 -5
View File
@@ -3,7 +3,7 @@ import { Drawing } from '@/types/drawing';
// Mock Data
const mockDrawings: Drawing[] = [
{
drawingId: 1,
publicId: 'dwg-001',
drawingNumber: 'S-201-A',
title: 'Structural Foundation Plan',
discipline: 'Structural',
@@ -13,7 +13,7 @@ const mockDrawings: Drawing[] = [
updatedAt: new Date(Date.now() - 1000 * 60 * 60 * 24).toISOString(),
},
{
drawingId: 2,
publicId: 'dwg-002',
drawingNumber: 'A-101-B',
title: 'Architectural Floor Plan - Level 1',
discipline: 'Architectural',
@@ -30,12 +30,12 @@ export const drawingApi = {
return { data: mockDrawings, meta: { total: mockDrawings.length } };
},
getById: async (id: number): Promise<Drawing | undefined> => {
getById: async (_id: string): Promise<Drawing | undefined> => {
await new Promise((resolve) => setTimeout(resolve, 300));
return mockDrawings.find((d) => d.drawingId === id);
return mockDrawings.find((d) => d.publicId === _id);
},
getByContract: async (_contractId: number): Promise<{ data: Drawing[] }> => {
getByContract: async (_contractId: string): Promise<{ data: Drawing[] }> => {
await new Promise((resolve) => setTimeout(resolve, 400));
// Mock: return all drawings for any contract
return { data: mockDrawings };
+9 -5
View File
@@ -3,6 +3,7 @@ import { Workflow, CreateWorkflowDto, ValidationResult } from '@/types/workflow'
// Mock Data
let mockWorkflows: Workflow[] = [
{
publicId: 'wf-001',
workflowId: 1,
workflowName: 'Standard RFA Workflow',
description: 'Default approval process for RFAs',
@@ -22,6 +23,7 @@ steps:
updatedAt: new Date().toISOString(),
},
{
publicId: 'wf-002',
workflowId: 2,
workflowName: 'Correspondence Review',
description: 'Incoming correspondence review flow',
@@ -44,15 +46,17 @@ export const workflowApi = {
return [...mockWorkflows];
},
getWorkflow: async (id: number): Promise<Workflow | undefined> => {
getWorkflow: async (id: string): Promise<Workflow | undefined> => {
await new Promise((resolve) => setTimeout(resolve, 300));
return mockWorkflows.find((w) => w.workflowId === id);
return mockWorkflows.find((w) => w.publicId === id);
},
createWorkflow: async (data: CreateWorkflowDto): Promise<Workflow> => {
await new Promise((resolve) => setTimeout(resolve, 800));
const maxId = mockWorkflows.length > 0 ? Math.max(...mockWorkflows.map((w) => Number(w.workflowId ?? 0))) : 0;
const newWorkflow: Workflow = {
workflowId: Math.max(...mockWorkflows.map((w) => Number(w.workflowId))) + 1,
publicId: `wf-${String(maxId + 1).padStart(3, '0')}`,
workflowId: maxId + 1,
...data,
version: 1,
isActive: true,
@@ -63,9 +67,9 @@ export const workflowApi = {
return newWorkflow;
},
updateWorkflow: async (id: number, data: Partial<CreateWorkflowDto>): Promise<Workflow> => {
updateWorkflow: async (id: string, data: Partial<CreateWorkflowDto>): Promise<Workflow> => {
await new Promise((resolve) => setTimeout(resolve, 600));
const index = mockWorkflows.findIndex((w) => w.workflowId === id);
const index = mockWorkflows.findIndex((w) => w.publicId === id);
if (index === -1) throw new Error('Workflow not found');
const updatedWorkflow = { ...mockWorkflows[index], ...data, updatedAt: new Date().toISOString() };
@@ -2,6 +2,7 @@ import apiClient from '@/lib/api/client';
import { AuditQueryParams } from '@/types/dto/numbering.dto';
export interface AuditLog {
publicId?: string; // ADR-019: public identifier
auditId: string;
userId?: number | null;
user?: {
+2 -2
View File
@@ -3,11 +3,11 @@ import { CreateContractDto, UpdateContractDto, SearchContractDto } from '@/types
import { Contract } from '@/types/contract';
const normalizeContract = (record: Contract): Contract => {
const publicId = record.publicId ?? record.id;
const publicId = record.publicId;
const project = record.project
? {
...record.project,
publicId: record.project.publicId ?? record.project.id,
publicId: record.project.publicId,
}
: undefined;
@@ -99,6 +99,7 @@ const normalizeWorkflowType = (workflowCode?: string): WorkflowType => {
const mapWorkflow = (backendObj: BackendWorkflowShape): Workflow => {
if (!backendObj) throw new Error('Workflow not found');
return {
publicId: String(backendObj.id ?? ''),
workflowId: backendObj.id ?? backendObj.workflow_code ?? '',
workflowName:
(typeof backendObj.dsl === 'object' ? backendObj.dsl?.workflowName : undefined) ||