1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
"use client"
import * as React from "react"
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import {
ProjectSearchStatus,
getLabelStatusClassName,
getDisplayElementStatusClassName,
getInputStatusClassName
} from "./project-field-utils"
// 타입 재내보내기
export type { ProjectSearchStatus } from "./project-field-utils"
// 재사용 가능한 필드 컴포넌트들
export interface ProjectInputFieldProps {
label: string
value: string
onChange: (value: string) => void
placeholder: string
status: ProjectSearchStatus
statusText?: string
minWidth?: string
}
export const ProjectInputField: React.FC<ProjectInputFieldProps> = ({
label,
value,
onChange,
placeholder,
status,
statusText,
minWidth = "250px"
}) => (
<div className="space-y-2 min-w-[250px] flex-shrink-0" style={{ minWidth }}>
<label className={`text-sm font-medium ${getLabelStatusClassName(status)}`}>
{label}
{statusText && <span className="ml-1 text-xs">{statusText}</span>}
</label>
<Input
value={value}
onChange={(e) => onChange(e.target.value)}
placeholder={placeholder}
className={`h-8 text-sm ${getInputStatusClassName(status)}`}
/>
</div>
)
export interface ProjectDisplayFieldProps {
label: string
value: string
status: ProjectSearchStatus
minWidth?: string
formatter?: (value: string) => string
}
export const ProjectDisplayField: React.FC<ProjectDisplayFieldProps> = ({
label,
value,
status,
minWidth = "120px",
formatter
}) => {
const displayValue = status === 'searching' ? '조회 중...' : (formatter ? formatter(value) : (value || '-'))
return (
<div className="space-y-2 flex-shrink-0" style={{ minWidth }}>
<label className={`text-sm font-medium ${getLabelStatusClassName(status)}`}>
{label}
{status === 'searching' && <span className="ml-1 text-xs">(조회 중...)</span>}
</label>
<div className={`text-sm font-medium min-h-[32px] flex items-center border rounded-md px-3 bg-background ${getDisplayElementStatusClassName(status)}`}>
{displayValue}
</div>
</div>
)
}
export interface ProjectFileFieldProps {
label: string
originalFile: string
onFileUpload: (event: React.ChangeEvent<HTMLInputElement>) => void
minWidth?: string
}
export const ProjectFileField: React.FC<ProjectFileFieldProps> = ({
label,
originalFile,
onFileUpload,
minWidth = "200px"
}) => (
<div className="space-y-2 flex-shrink-0" style={{ minWidth }}>
<label className="text-sm font-medium text-muted-foreground">{label}</label>
<div className="flex items-center gap-2 min-h-[32px]">
{originalFile ? (
<span className="text-sm text-blue-600">{originalFile}</span>
) : (
<div className="relative">
<input
type="file"
onChange={onFileUpload}
className="absolute inset-0 w-full h-full opacity-0 cursor-pointer"
accept=".xlsx,.xls,.csv"
/>
<Button variant="outline" size="sm" className="text-xs">
파일 선택
</Button>
</div>
)}
</div>
</div>
)
|