LayoutSectionCard.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. "use client";
  2. import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
  3. import { Badge } from "@/components/ui/badge";
  4. import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
  5. import { Badge as BadgeIcon } from "lucide-react";
  6. interface LayoutSection {
  7. id: number;
  8. name: string;
  9. type: string;
  10. sheetName: string;
  11. startingRow?: number | null;
  12. endingRow?: number | null;
  13. tableName: string;
  14. fields: LayoutSectionField[];
  15. }
  16. interface LayoutSectionField {
  17. id: number;
  18. name: string;
  19. dataType: string;
  20. dataTypeFormat: string | null;
  21. cellPosition: string;
  22. importTableColumnName: string;
  23. importColumnOrderNumber: number;
  24. }
  25. interface LayoutSectionCardProps {
  26. section: LayoutSection;
  27. }
  28. export function LayoutSectionCard({ section }: LayoutSectionCardProps) {
  29. const getTypeColor = (type: string) => {
  30. switch (type.toLowerCase()) {
  31. case "properties":
  32. return "bg-blue-100 text-blue-800";
  33. case "grid":
  34. return "bg-green-100 text-green-800";
  35. default:
  36. return "bg-gray-100 text-gray-800";
  37. }
  38. };
  39. return (
  40. <Card>
  41. <CardHeader>
  42. <div className="flex justify-between items-start">
  43. <div>
  44. <CardTitle className="text-lg">{section.name}</CardTitle>
  45. <CardDescription>
  46. Sheet: {section.sheetName} | Table: {section.tableName}
  47. </CardDescription>
  48. </div>
  49. <Badge className={getTypeColor(section.type)}>
  50. {section.type}
  51. </Badge>
  52. </div>
  53. </CardHeader>
  54. <CardContent>
  55. <div className="space-y-4">
  56. <div className="flex gap-4 text-sm">
  57. {section.startingRow && (
  58. <span>
  59. <strong>Rows:</strong> {section.startingRow} - {section.endingRow || "end"}
  60. </span>
  61. )}
  62. <span>
  63. <strong>Fields:</strong> {section.fields.length}
  64. </span>
  65. </div>
  66. {section.fields.length > 0 && (
  67. <div>
  68. <h4 className="font-medium mb-2">Fields</h4>
  69. <div className="overflow-x-auto">
  70. <Table>
  71. <TableHeader>
  72. <TableRow>
  73. <TableHead>Name</TableHead>
  74. <TableHead>Type</TableHead>
  75. <TableHead>Position</TableHead>
  76. <TableHead>Column</TableHead>
  77. <TableHead>Order</TableHead>
  78. </TableRow>
  79. </TableHeader>
  80. <TableBody>
  81. {section.fields.map((field) => (
  82. <TableRow key={field.id}>
  83. <TableCell className="font-medium">{field.name}</TableCell>
  84. <TableCell>
  85. <Badge variant="outline" className="text-xs">
  86. {field.dataType}
  87. </Badge>
  88. </TableCell>
  89. <TableCell>{field.cellPosition}</TableCell>
  90. <TableCell>{field.importTableColumnName}</TableCell>
  91. <TableCell>{field.importColumnOrderNumber}</TableCell>
  92. </TableRow>
  93. ))}
  94. </TableBody>
  95. </Table>
  96. </div>
  97. </div>
  98. )}
  99. </div>
  100. </CardContent>
  101. </Card>
  102. );
  103. }