'use client'; import { useState, useEffect } from 'react'; import DataTable from '@/components/admin/DataTable'; import DetailModal from '@/components/admin/DetailModal'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { ArrowLeft, Wrench } from 'lucide-react'; import Link from 'next/link'; export default function ConfigurationItemsBrowserPage() { const [configItems, setConfigItems] = useState([]); const [totalCount, setTotalCount] = useState(0); const [page, setPage] = useState(1); const [pageSize] = useState(50); const [isLoading, setIsLoading] = useState(false); const [selectedItem, setSelectedItem] = useState(null); const [modalOpen, setModalOpen] = useState(false); const fetchConfigItems = async (currentPage: number, search?: string, sortBy?: string, sortOrder?: string) => { setIsLoading(true); try { const params = new URLSearchParams({ limit: pageSize.toString(), offset: ((currentPage - 1) * pageSize).toString(), }); if (search) params.append('search', search); if (sortBy) params.append('sort', sortBy); if (sortOrder) params.append('order', sortOrder); const response = await fetch(`/api/data/configuration-items?${params}`); const result = await response.json(); setConfigItems(result.configurationItems || []); setTotalCount(result.pagination?.total || 0); } catch (error) { console.error('Failed to fetch configuration items:', error); } finally { setIsLoading(false); } }; useEffect(() => { fetchConfigItems(page); }, [page]); const handleRowClick = (item: any) => { setSelectedItem(item); setModalOpen(true); }; const columns = [ { key: 'id', label: 'ID', sortable: true, }, { key: 'reference_title', label: 'Title', sortable: true, render: (value: string) => (
{value}
), }, { key: 'reference_number', label: 'Reference #', sortable: true, }, { key: 'serial_number', label: 'Serial #', sortable: true, }, { key: 'company_id', label: 'Company ID', sortable: true, }, { key: 'configuration_item_type', label: 'Type', }, { key: 'is_active', label: 'Active', render: (value: boolean) => ( {value ? 'Active' : 'Inactive'} ), }, ]; const detailFields = [ { key: 'id', label: 'ID' }, { key: 'company_id', label: 'Company ID' }, { key: 'reference_title', label: 'Title' }, { key: 'reference_number', label: 'Reference Number' }, { key: 'serial_number', label: 'Serial Number' }, { key: 'product_id', label: 'Product ID' }, { key: 'configuration_item_type', label: 'Type' }, { key: 'configuration_item_category_id', label: 'Category ID' }, { key: 'is_active', label: 'Active' }, { key: 'install_date', label: 'Install Date' }, { key: 'warranty_expiration_date', label: 'Warranty Expiration' }, { key: 'contact_id', label: 'Contact ID' }, { key: 'location_id', label: 'Location ID' }, { key: 'vendor_id', label: 'Vendor ID' }, { key: 'device_type', label: 'Device Type' }, { key: 'rmm_device_uid', label: 'RMM Device UID' }, { key: 'notes', label: 'Notes' }, { key: 'synced_at', label: 'Synced At' }, { key: 'is_deleted', label: 'Is Deleted' }, ]; return (
{/* Header */}

Configuration Items

Manage and inspect device data

{totalCount} total records
{/* Data Table Card */}
All Configuration Items View and search through all configuration items in the system
fetchConfigItems(page, undefined, column, direction)} onSearch={(query) => fetchConfigItems(1, query)} onRowClick={handleRowClick} isLoading={isLoading} />
{/* Detail Modal */}
); }