LayoutConfigurationDetail.tsx 3.4 KB

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