From ef4c533ebacc2cdc97e518f30e9a9350004fcdfb Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 28 Apr 2025 02:13:30 +0000 Subject: ~20250428 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/form-list/table/meta-sheet.tsx | 85 ++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 27 deletions(-) (limited to 'lib/form-list/table/meta-sheet.tsx') diff --git a/lib/form-list/table/meta-sheet.tsx b/lib/form-list/table/meta-sheet.tsx index 694ee845..7c15bdea 100644 --- a/lib/form-list/table/meta-sheet.tsx +++ b/lib/form-list/table/meta-sheet.tsx @@ -1,8 +1,9 @@ "use client" import * as React from "react" -import { useMemo } from "react" +import { useState } from "react" import { Badge } from "@/components/ui/badge" +import { Button } from "@/components/ui/button" import { Sheet, SheetContent, @@ -34,6 +35,56 @@ import { import type { TagTypeClassFormMappings } from "@/db/schema/vendorData" // or your actual type import { fetchFormMetadata, FormColumn } from "@/lib/forms/services" +// 옵션을 표시하기 위한 새로운 컴포넌트 +const CollapsibleOptions = ({ options }: { options?: string[] }) => { + const [isExpanded, setIsExpanded] = useState(false); + + // 옵션이 없거나 5개 이하인 경우 모두 표시 + if (!options || options.length <= 5) { + return ( +
+ {options?.map((option) => ( + + {option} + + )) || "-"} +
+ ); + } + + // 더 많은 옵션이 있는 경우 접었다 펼칠 수 있게 함 + return ( +
+
+ {isExpanded + ? options.map((option) => ( + + {option} + + )) + : options.slice(0, 3).map((option) => ( + + {option} + + )) + } + {!isExpanded && ( + + +{options.length - 3} more + + )} +
+ +
+ ); +}; interface ViewMetasProps { open: boolean @@ -51,7 +102,7 @@ export function ViewMetas({ open, onOpenChange, form }: ViewMetasProps) { const [loading, setLoading] = React.useState(false) // Group columns by type for better organization - const groupedColumns = useMemo(() => { + const groupedColumns = React.useMemo(() => { if (!metadata?.columns) return {} return metadata.columns.reduce((acc, column) => { @@ -65,7 +116,7 @@ export function ViewMetas({ open, onOpenChange, form }: ViewMetasProps) { }, [metadata]) // Types for the tabs - const columnTypes = useMemo(() => { + const columnTypes = React.useMemo(() => { return Object.keys(groupedColumns) }, [groupedColumns]) @@ -165,17 +216,7 @@ export function ViewMetas({ open, onOpenChange, form }: ViewMetasProps) { {column.type} - {column.options ? ( -
- {column.options.map((option) => ( - - {option} - - ))} -
- ) : ( - "-" - )} +
))} @@ -198,7 +239,7 @@ export function ViewMetas({ open, onOpenChange, form }: ViewMetasProps) { Key Label - {type === "select" && Options} + {type === "LIST" && Options} @@ -206,19 +247,9 @@ export function ViewMetas({ open, onOpenChange, form }: ViewMetasProps) { {column.key} {column.label} - {type === "select" && ( + {type === "LIST" && ( - {column.options ? ( -
- {column.options.map((option) => ( - - {option} - - ))} -
- ) : ( - "-" - )} +
)}
-- cgit v1.2.3