gis 편집
This commit is contained in:
@@ -45,17 +45,37 @@ type UiTableProps = {
|
||||
onFormDataChange?: (formData: { [key: string]: string | number | boolean }) => void; // 추가
|
||||
};
|
||||
|
||||
type UiSelectOption =
|
||||
| string
|
||||
| {
|
||||
value?: string | number;
|
||||
label?: string;
|
||||
val?: string | number;
|
||||
text?: string;
|
||||
hidden?: boolean;
|
||||
};
|
||||
|
||||
type UiHeadProps = {
|
||||
id: string;
|
||||
title: string;
|
||||
align?: string;
|
||||
type?: string;
|
||||
options?: string[];
|
||||
options?: UiSelectOption[];
|
||||
placeholder?: string;
|
||||
isNumber?: boolean;
|
||||
length?: number;
|
||||
required?: boolean;
|
||||
};
|
||||
|
||||
const getSelectOptionValue = (option: UiSelectOption) =>
|
||||
typeof option === "string" ? option : String(option.value ?? option.val ?? "");
|
||||
|
||||
const getSelectOptionLabel = (option: UiSelectOption) =>
|
||||
typeof option === "string" ? option : String(option.label ?? option.text ?? getSelectOptionValue(option));
|
||||
|
||||
const isSelectOptionHidden = (option: UiSelectOption) =>
|
||||
typeof option === "string" ? false : Boolean(option.hidden);
|
||||
|
||||
export function VerticalTable({
|
||||
headName,
|
||||
tableName1,
|
||||
@@ -153,6 +173,7 @@ export function VerticalTable({
|
||||
{/* 컬럼 제목 */}
|
||||
<TableCell className={`font-bold bg-blue-100 text-xs w-[120px] whitespace-nowrap`}>
|
||||
{head.title}
|
||||
{head.required ? <span className="ml-1 text-red-600">*</span> : null}
|
||||
</TableCell>
|
||||
{/* 데이터 값 또는 입력 필드 */}
|
||||
<TableCell className="text-xs">
|
||||
@@ -160,21 +181,28 @@ export function VerticalTable({
|
||||
head.type === "select" ? (
|
||||
<select
|
||||
id={head.id}
|
||||
value={String(formData[head.id]) ?? "-"}
|
||||
value={formData[head.id] !== undefined ? String(formData[head.id]) : ""}
|
||||
onChange={(e) => handleInputChange(head.id, e.target.value)}
|
||||
className="w-full border border-gray-300 rounded-sm px-2 py-1 text-xl border-radius-0"
|
||||
>
|
||||
{head.options?.map((option) => (
|
||||
<option key={option} value={option}>
|
||||
{option}
|
||||
</option>
|
||||
))}
|
||||
{head.options?.map((option, optionIndex) => {
|
||||
const optionValue = getSelectOptionValue(option);
|
||||
return (
|
||||
<option
|
||||
key={`${head.id}-${optionValue}-${optionIndex}`}
|
||||
value={optionValue}
|
||||
hidden={isSelectOptionHidden(option)}
|
||||
>
|
||||
{getSelectOptionLabel(option)}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
) : head.type === "input" ? (
|
||||
) : head.type === "input" || head.type === "date" ? (
|
||||
<div className="w-full">
|
||||
<input
|
||||
id={head.id}
|
||||
type="text"
|
||||
type={head.type === "date" ? "date" : "text"}
|
||||
value={String(formData[head.id] ?? "")}
|
||||
onChange={(e) => {
|
||||
if (head.isNumber) {
|
||||
@@ -241,8 +269,9 @@ export function VerticalTable({
|
||||
<TableRow key={head.id}>
|
||||
{/* 컬럼 제목 */}
|
||||
<TableCell className={`font-bold bg-blue-100 text-xs w-[120px] whitespace-nowrap`}>
|
||||
{head.title}
|
||||
</TableCell>
|
||||
{head.title}
|
||||
{head.required ? <span className="ml-1 text-red-600">*</span> : null}
|
||||
</TableCell>
|
||||
{/* 데이터 값 또는 입력 필드 */}
|
||||
<TableCell className="text-xs">
|
||||
{children && children[head.id] ? children[head.id] : isEditable2 ? (
|
||||
@@ -253,17 +282,24 @@ export function VerticalTable({
|
||||
onChange={(e) => handleInputChange(head.id, e.target.value)}
|
||||
className="w-full border border-gray-300 rounded-sm px-2 py-1 text-xl border-radius-0"
|
||||
>
|
||||
{head.options?.map((option) => (
|
||||
<option key={option} value={option}>
|
||||
{option}
|
||||
</option>
|
||||
))}
|
||||
{head.options?.map((option, optionIndex) => {
|
||||
const optionValue = getSelectOptionValue(option);
|
||||
return (
|
||||
<option
|
||||
key={`${head.id}-${optionValue}-${optionIndex}`}
|
||||
value={optionValue}
|
||||
hidden={isSelectOptionHidden(option)}
|
||||
>
|
||||
{getSelectOptionLabel(option)}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
) : head.type === "input" ? (
|
||||
) : head.type === "input" || head.type === "date" ? (
|
||||
<div className="w-full">
|
||||
<input
|
||||
id={head.id}
|
||||
type={head.isNumber ? "number" : "text"}
|
||||
type={head.type === "date" ? "date" : head.isNumber ? "number" : "text"}
|
||||
value={formData[head.id] !== undefined ? String(formData[head.id]) : ""}
|
||||
onChange={(e) => {
|
||||
if (head.isNumber) {
|
||||
@@ -333,4 +369,4 @@ export function VerticalTable({
|
||||
<Toaster position="top-center"></Toaster>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user