690327:1426 Fixing Refactor ADR-019 Naming convention uuid #17
CI / CD Pipeline / build (push) Failing after 5m3s
CI / CD Pipeline / deploy (push) Has been skipped

This commit is contained in:
2026-03-27 14:26:52 +07:00
parent 47f12508f4
commit fc61ff2491
2 changed files with 8 additions and 16 deletions
+6 -13
View File
@@ -21,20 +21,10 @@ import {
ShopSubCategory,
ContractDrawingCategory,
} from '@/types/master-data';
import { useState, useEffect } from 'react';
import { useState, useEffect, useMemo } from 'react';
import { Loader2 } from 'lucide-react';
import { Textarea } from '@/components/ui/textarea';
// Helper to extract array data from various API response formats
const extractArrayData = <T,>(value: unknown): T[] => {
if (Array.isArray(value)) return value as T[];
if (value && typeof value === 'object' && 'data' in value) {
const data = (value as { data?: unknown }).data;
if (Array.isArray(data)) return data as T[];
}
return [];
};
// Base Schema
const baseSchema = z.object({
drawingType: z.enum(['CONTRACT', 'SHOP', 'AS_BUILT']),
@@ -90,7 +80,10 @@ export function DrawingUploadForm() {
// Project list - ADR-019: useProjects returns array directly now
const { data: projectsData, isLoading: isLoadingProjects } = useProjects();
const projects = (projectsData ?? []) as { id?: number; publicId?: string; projectName: string; projectCode: string }[];
const projects = useMemo(
() => (projectsData ?? []) as { id?: number; publicId?: string; projectName: string; projectCode: string }[],
[projectsData]
);
// Selected project for category fetching
const [selectedProjectId, setSelectedProjectId] = useState<number | string | undefined>(undefined);
@@ -192,7 +185,7 @@ export function DrawingUploadForm() {
)}
</SelectTrigger>
<SelectContent>
{projects.map((project) => {
{projects.map((project: { publicId?: string; id?: number; projectCode: string; projectName: string }) => {
const projectValue = String(project.publicId ?? project.id ?? '');
return (
<SelectItem key={projectValue} value={projectValue}>
+2 -3
View File
@@ -96,9 +96,8 @@ export function useProjects(isActive: boolean = true) {
return useQuery({
queryKey: ['projects', { isActive }],
queryFn: async () => {
const response = await projectService.getAll({ isActive });
// ADR-019: Handle paginated response { data: Project[], meta: {...} }
return extractArrayData(response);
// ADR-019: projectService.getAll() returns Project[] directly
return await projectService.getAll({ isActive });
},
});
}