260316:1524 Refactor to UUID
Build and Deploy / deploy (push) Successful in 3m25s

This commit is contained in:
admin
2026-03-16 15:24:26 +07:00
parent 3636b3c831
commit 4f7d9bb80c
3 changed files with 17 additions and 16 deletions
@@ -50,14 +50,13 @@ import { SearchContractDto, CreateContractDto, UpdateContractDto } from "@/types
import { AxiosError } from "axios";
interface Project {
id: number;
id: string; // ADR-019: uuid exposed as 'id'
projectCode: string;
projectName: string;
}
interface Contract {
uuid: string;
id?: number; // Excluded from API responses (ADR-019)
id: string; // ADR-019: uuid exposed as 'id'
contractCode: string;
contractName: string;
projectId: number;
@@ -65,6 +64,7 @@ interface Contract {
startDate?: string;
endDate?: string;
project?: {
id: string; // ADR-019: project uuid exposed as 'id'
projectCode: string;
projectName: string;
}
@@ -145,7 +145,7 @@ export default function ContractsPage() {
const confirmDelete = () => {
if (contractToDelete) {
deleteContract.mutate(contractToDelete.uuid, {
deleteContract.mutate(contractToDelete.id, {
onSuccess: () => {
setDeleteDialogOpen(false);
setContractToDelete(null);
@@ -213,9 +213,9 @@ export default function ContractsPage() {
];
const handleEdit = (contract: Contract) => {
setEditingUuid(contract.uuid);
// ADR-019: projectId might be a number or a UUID string from the entity response
const pId = String((contract as any).id || (contract as any).projectId || "");
setEditingUuid(contract.id);
// ADR-019: project.id is the project's UUID (exposed via @Expose)
const pId = contract.project?.id || '';
reset({
contractCode: contract.contractCode,
contractName: contract.contractName,
@@ -242,10 +242,11 @@ export default function ContractsPage() {
const onSubmit = (data: ContractFormData) => {
// ADR-019: Resolve projectId (ID or UUID)
// ADR-019: projectId is now a UUID string — backend resolveProjectId handles both
const submitData = {
...data,
projectId: isNaN(Number(data.projectId)) ? data.projectId : Number(data.projectId),
} as any;
projectId: data.projectId,
};
if (editingUuid) {
updateContract.mutate({ uuid: editingUuid, data: submitData });
+5 -5
View File
@@ -15,7 +15,7 @@ export const masterDataKeys = {
all: ['masterData'] as const,
organizations: () => [...masterDataKeys.all, 'organizations'] as const,
correspondenceTypes: () => [...masterDataKeys.all, 'correspondenceTypes'] as const,
disciplines: (contractId?: number) => [...masterDataKeys.all, 'disciplines', contractId] as const,
disciplines: (contractId?: number | string) => [...masterDataKeys.all, 'disciplines', contractId] as const,
};
export function useOrganizations(params?: SearchOrganizationDto) {
@@ -74,7 +74,7 @@ export function useDeleteOrganization() {
});
}
export function useDisciplines(contractId?: number) {
export function useDisciplines(contractId?: number | string) {
return useQuery({
queryKey: masterDataKeys.disciplines(contractId),
queryFn: () => masterDataService.getDisciplines(contractId),
@@ -88,10 +88,10 @@ export function useProjects(isActive: boolean = true) {
});
}
export function useContracts(projectId: number = 1) {
export function useContracts(projectId?: number | string) {
return useQuery({
queryKey: ['contracts', projectId],
queryFn: () => contractService.getAll({ projectId }),
queryKey: ['contracts', projectId ?? 'all'],
queryFn: () => contractService.getAll(projectId ? { projectId } : undefined),
});
}
+2 -2
View File
@@ -1,7 +1,7 @@
export interface CreateContractDto {
contractCode: string;
contractName: string;
projectId: number;
projectId: number | string;
description?: string;
startDate?: string;
endDate?: string;
@@ -11,7 +11,7 @@ export type UpdateContractDto = Partial<CreateContractDto>;
export interface SearchContractDto {
search?: string;
projectId?: number;
projectId?: number | string;
page?: number;
limit?: number;
}