"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { LayoutSectionCard } from "./LayoutSectionCard"; import { AddSectionDialog } from "./AddSectionDialog"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { ArrowLeft, Plus } from "lucide-react"; interface LayoutConfiguration { id: number; name: string; sections: LayoutSection[]; createdAt: Date; updatedAt: Date; } interface LayoutSection { id: number; name: string; type: string; sheetName: string; startingRow?: number | null; endingRow?: number | null; tableName: string; fields: LayoutSectionField[]; } interface LayoutSectionField { id: number; name: string; dataType: string; dataTypeFormat: string | null; cellPosition: string; importTableColumnName: string; importColumnOrderNumber: number; } interface LayoutConfigurationDetailProps { configuration: LayoutConfiguration; } export function LayoutConfigurationDetail({ configuration }: LayoutConfigurationDetailProps) { const router = useRouter(); const [isDialogOpen, setIsDialogOpen] = useState(false); const [sections, setSections] = useState(configuration.sections); return (
Configuration Details Overview of the layout configuration and its sections
{sections.length} sections {sections.reduce((total, section) => total + section.fields.length, 0)} fields
Name: {configuration.name}
Created: {new Date(configuration.createdAt).toLocaleDateString()}
Last Updated: {new Date(configuration.updatedAt).toLocaleDateString()}

Sections

{sections.length === 0 ? (

No sections found for this configuration

) : (
{sections.map((section) => ( { // Refresh the sections list setSections(prev => prev.filter(s => s.id !== section.id)); }} /> ))}
)}
); }