From d455598dc208fb78ec87226864e9e42a33e2fc8e Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 19 Feb 2026 16:49:07 +0700 Subject: [PATCH] 260219:1649 20260219 TASK-BEFE-001 Fixed Blank Admin Pages --- .../drawings/contract/categories/page.tsx | 262 +++++++++--------- .../admin/doc-control/reference/page.tsx | 44 ++- frontend/hooks/use-master-data.ts | 38 ++- 3 files changed, 169 insertions(+), 175 deletions(-) diff --git a/frontend/app/(admin)/admin/doc-control/drawings/contract/categories/page.tsx b/frontend/app/(admin)/admin/doc-control/drawings/contract/categories/page.tsx index 8f55fea..deb83db 100644 --- a/frontend/app/(admin)/admin/doc-control/drawings/contract/categories/page.tsx +++ b/frontend/app/(admin)/admin/doc-control/drawings/contract/categories/page.tsx @@ -1,19 +1,20 @@ -"use client"; +'use client'; -import { useState } from "react"; -import { GenericCrudTable } from "@/components/admin/reference/generic-crud-table"; -import { ColumnDef } from "@tanstack/react-table"; +import { useState } from 'react'; +import { GenericCrudTable } from '@/components/admin/reference/generic-crud-table'; +import { ColumnDef } from '@tanstack/react-table'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; +import { Loader2, Plus, Trash2 } from 'lucide-react'; +import { useProjects } from '@/hooks/use-master-data'; import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { Loader2 } from "lucide-react"; -import { useProjects } from "@/hooks/use-master-data"; -import { drawingMasterDataService, ContractCategory, ContractSubCategory } from "@/lib/services/drawing-master-data.service"; -import { Badge } from "@/components/ui/badge"; + drawingMasterDataService, + ContractCategory, + ContractSubCategory, +} from '@/lib/services/drawing-master-data.service'; +import { Badge } from '@/components/ui/badge'; +import { Button } from '@/components/ui/button'; +import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; +import { toast } from 'sonner'; interface Category { id: number; @@ -29,33 +30,27 @@ export default function ContractCategoriesPage() { const columns: ColumnDef[] = [ { - accessorKey: "catCode", - header: "Code", + accessorKey: 'catCode', + header: 'Code', cell: ({ row }) => ( - {row.getValue("catCode")} + {row.getValue('catCode')} ), }, { - accessorKey: "catName", - header: "Category Name", + accessorKey: 'catName', + header: 'Category Name', }, { - accessorKey: "description", - header: "Description", - cell: ({ row }) => ( - - {row.getValue("description") || "-"} - - ), + accessorKey: 'description', + header: 'Description', + cell: ({ row }) => {row.getValue('description') || '-'}, }, { - accessorKey: "sortOrder", - header: "Order", - cell: ({ row }) => ( - {row.getValue("sortOrder")} - ), + accessorKey: 'sortOrder', + header: 'Order', + cell: ({ row }) => {row.getValue('sortOrder')}, }, ]; @@ -63,7 +58,7 @@ export default function ContractCategoriesPage() {
Project: +
+ + +
+ + {selectedCat && ( +
+
+
+ + -
+ +
+ +
- {selectedCat && ( -
-
-
- - -
- -
- -
-
- Mapped Sub-Categories - Action -
- {mappings.length === 0 ? ( -
No sub-categories mapped yet.
- ) : ( -
- {mappings.map((m: { id: number; subCategory: ContractSubCategory }) => ( -
- {m.subCategory.subCatCode} - {m.subCategory.subCatName} - -
- ))} -
- )} -
-
- )} +
+ ))} + + )} + + + )} - ) + ); } diff --git a/frontend/app/(admin)/admin/doc-control/reference/page.tsx b/frontend/app/(admin)/admin/doc-control/reference/page.tsx index 30c7c94..5b0e891 100644 --- a/frontend/app/(admin)/admin/doc-control/reference/page.tsx +++ b/frontend/app/(admin)/admin/doc-control/reference/page.tsx @@ -1,36 +1,36 @@ -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; -import { BookOpen, Tag, Settings, Layers } from "lucide-react"; -import Link from "next/link"; +import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { BookOpen, Tag, Settings, Layers } from 'lucide-react'; +import Link from 'next/link'; const refMenu = [ { - title: "Disciplines", - description: "Manage system-wide disciplines (e.g., ARCH, STR)", - href: "/admin/reference/disciplines", + title: 'Disciplines', + description: 'Manage system-wide disciplines (e.g., ARCH, STR)', + href: '/admin/doc-control/reference/disciplines', icon: Layers, }, { - title: "RFA Types", - description: "Manage RFA types and approve codes", - href: "/admin/reference/rfa-types", + title: 'RFA Types', + description: 'Manage RFA types and approve codes', + href: '/admin/doc-control/reference/rfa-types', icon: BookOpen, }, { - title: "Correspondence Types", - description: "Manage generic correspondence types", - href: "/admin/reference/correspondence-types", + title: 'Correspondence Types', + description: 'Manage generic correspondence types', + href: '/admin/doc-control/reference/correspondence-types', icon: Settings, }, { - title: "Tags", - description: "Manage system tags for documents", - href: "/admin/reference/tags", + title: 'Tags', + description: 'Manage system tags for documents', + href: '/admin/doc-control/reference/tags', icon: Tag, }, { - title: "Drawing Categories", - description: "Manage drawing sub-types and classifications", - href: "/admin/reference/drawing-categories", + title: 'Drawing Categories', + description: 'Manage drawing sub-types and classifications', + href: '/admin/doc-control/reference/drawing-categories', icon: Layers, }, ]; @@ -44,15 +44,11 @@ export default function ReferenceDataPage() { - - {item.title} - + {item.title} -

- {item.description} -

+

{item.description}

diff --git a/frontend/hooks/use-master-data.ts b/frontend/hooks/use-master-data.ts index 20d074d..87c737d 100644 --- a/frontend/hooks/use-master-data.ts +++ b/frontend/hooks/use-master-data.ts @@ -7,6 +7,9 @@ import { SearchOrganizationDto, } from '@/types/dto/organization/organization.dto'; import { AxiosError } from 'axios'; +import { organizationService } from '@/lib/services/organization.service'; +import { projectService } from '@/lib/services/project.service'; +import { contractService } from '@/lib/services/contract.service'; export const masterDataKeys = { all: ['masterData'] as const, @@ -15,8 +18,6 @@ export const masterDataKeys = { disciplines: (contractId?: number) => [...masterDataKeys.all, 'disciplines', contractId] as const, }; -import { organizationService } from '@/lib/services/organization.service'; - export function useOrganizations(params?: SearchOrganizationDto) { return useQuery({ queryKey: [...masterDataKeys.organizations(), params], @@ -29,30 +30,31 @@ export function useCreateOrganization() { return useMutation({ mutationFn: (data: CreateOrganizationDto) => masterDataService.createOrganization(data), onSuccess: () => { - toast.success("Organization created successfully"); + toast.success('Organization created successfully'); queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() }); }, onError: (error: AxiosError<{ message?: string }>) => { - toast.error("Failed to create organization", { - description: error.response?.data?.message || "Unknown error" + toast.error('Failed to create organization', { + description: error.response?.data?.message || 'Unknown error', }); - } + }, }); } export function useUpdateOrganization() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ id, data }: { id: number; data: UpdateOrganizationDto }) => masterDataService.updateOrganization(id, data), + mutationFn: ({ id, data }: { id: number; data: UpdateOrganizationDto }) => + masterDataService.updateOrganization(id, data), onSuccess: () => { - toast.success("Organization updated successfully"); + toast.success('Organization updated successfully'); queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() }); }, onError: (error: AxiosError<{ message?: string }>) => { - toast.error("Failed to update organization", { - description: error.response?.data?.message || "Unknown error" + toast.error('Failed to update organization', { + description: error.response?.data?.message || 'Unknown error', }); - } + }, }); } @@ -61,14 +63,14 @@ export function useDeleteOrganization() { return useMutation({ mutationFn: (id: number) => masterDataService.deleteOrganization(id), onSuccess: () => { - toast.success("Organization deleted successfully"); + toast.success('Organization deleted successfully'); queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() }); }, onError: (error: AxiosError<{ message?: string }>) => { - toast.error("Failed to delete organization", { - description: error.response?.data?.message || "Unknown error" + toast.error('Failed to delete organization', { + description: error.response?.data?.message || 'Unknown error', }); - } + }, }); } @@ -79,9 +81,6 @@ export function useDisciplines(contractId?: number) { }); } -// Add useProjects hook -import { projectService } from '@/lib/services/project.service'; - export function useProjects(isActive: boolean = true) { return useQuery({ queryKey: ['projects', { isActive }], @@ -89,9 +88,6 @@ export function useProjects(isActive: boolean = true) { }); } -// Add useContracts hook -import { contractService } from '@/lib/services/contract.service'; - export function useContracts(projectId: number = 1) { return useQuery({ queryKey: ['contracts', projectId],