LayoutConfigurationDetail.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. "use client";
  2. import { useRouter } from "next/navigation";
  3. import { LayoutSectionCard } from "./LayoutSectionCard";
  4. import { Button } from "@/components/ui/button";
  5. import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
  6. import { Badge } from "@/components/ui/badge";
  7. import { ArrowLeft, Plus } from "lucide-react";
  8. interface LayoutConfiguration {
  9. id: number;
  10. name: string;
  11. sections: LayoutSection[];
  12. createdAt: Date;
  13. updatedAt: Date;
  14. }
  15. interface LayoutSection {
  16. id: number;
  17. name: string;
  18. type: string;
  19. sheetName: string;
  20. startingRow?: number | null;
  21. endingRow?: number | null;
  22. tableName: string;
  23. fields: LayoutSectionField[];
  24. }
  25. interface LayoutSectionField {
  26. id: number;
  27. name: string;
  28. dataType: string;
  29. dataTypeFormat: string | null;
  30. cellPosition: string;
  31. importTableColumnName: string;
  32. importColumnOrderNumber: number;
  33. }
  34. interface LayoutConfigurationDetailProps {
  35. configuration: LayoutConfiguration;
  36. }
  37. export function LayoutConfigurationDetail({ configuration }: LayoutConfigurationDetailProps) {
  38. const router = useRouter();
  39. return (
  40. <div className="space-y-6">
  41. <div className="flex items-center gap-4">
  42. <Button
  43. variant="ghost"
  44. size="sm"
  45. onClick={() => router.push("/layout-configurations")}
  46. >
  47. <ArrowLeft className="h-4 w-4 mr-2" />
  48. Back to Configurations
  49. </Button>
  50. </div>
  51. <Card>
  52. <CardHeader>
  53. <div className="flex justify-between items-start">
  54. <div>
  55. <CardTitle>Configuration Details</CardTitle>
  56. <CardDescription>
  57. Overview of the layout configuration and its sections
  58. </CardDescription>
  59. </div>
  60. <div className="flex gap-2">
  61. <Badge variant="secondary">
  62. {configuration.sections.length} sections
  63. </Badge>
  64. <Badge variant="outline">
  65. {configuration.sections.reduce((total, section) => total + section.fields.length, 0)} fields
  66. </Badge>
  67. </div>
  68. </div>
  69. </CardHeader>
  70. <CardContent>
  71. <div className="grid gap-4">
  72. <div>
  73. <span className="font-medium">Name:</span> {configuration.name}
  74. </div>
  75. <div>
  76. <span className="font-medium">Created:</span> {new Date(configuration.createdAt).toLocaleDateString()}
  77. </div>
  78. <div>
  79. <span className="font-medium">Last Updated:</span> {new Date(configuration.updatedAt).toLocaleDateString()}
  80. </div>
  81. </div>
  82. </CardContent>
  83. </Card>
  84. <div className="space-y-4">
  85. <div className="flex justify-between items-center">
  86. <h2 className="text-2xl font-semibold">Sections</h2>
  87. <Button size="sm">
  88. <Plus className="h-4 w-4 mr-2" />
  89. Add Section
  90. </Button>
  91. </div>
  92. {configuration.sections.length === 0 ? (
  93. <Card>
  94. <CardContent className="pt-6">
  95. <p className="text-center text-muted-foreground">
  96. No sections found for this configuration
  97. </p>
  98. </CardContent>
  99. </Card>
  100. ) : (
  101. <div className="grid gap-4">
  102. {configuration.sections.map((section) => (
  103. <LayoutSectionCard key={section.id} section={section} />
  104. ))}
  105. </div>
  106. )}
  107. </div>
  108. </div>
  109. );
  110. }