Spaces:
Running
Running
File size: 4,731 Bytes
33d9e63 | 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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | import React from 'react';
import { Input } from './Input';
import { TextArea } from './TextArea';
import { Button } from './Button';
export interface ProjectFormData {
title: string;
companyName: string;
contactName: string;
contactEmail: string;
startDate: string;
endDate: string;
memo: string;
}
export interface ProjectFormProps {
initialData?: ProjectFormData;
onSubmit: (data: ProjectFormData) => void;
submitButtonText: string;
cancelButtonText?: string;
onCancel?: () => void;
submitIcon?: React.ReactNode;
}
export const ProjectForm: React.FC<ProjectFormProps> = ({
initialData,
onSubmit,
submitButtonText,
cancelButtonText,
onCancel,
submitIcon,
}) => {
const [title, setTitle] = React.useState('');
const [companyName, setCompanyName] = React.useState('');
const [contactName, setContactName] = React.useState('');
const [contactEmail, setContactEmail] = React.useState('');
const [memo, setMemo] = React.useState('');
const [startDate, setStartDate] = React.useState('2026-07-01');
const [endDate, setEndDate] = React.useState('2026-07-15');
// Sync initial data when loaded/changed
React.useEffect(() => {
if (initialData) {
setTitle(initialData.title);
setCompanyName(initialData.companyName);
setContactName(initialData.contactName);
setContactEmail(initialData.contactEmail);
setMemo(initialData.memo);
setStartDate(initialData.startDate);
setEndDate(initialData.endDate);
}
}, [initialData]);
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
onSubmit({
title,
companyName,
contactName,
contactEmail,
startDate,
endDate,
memo,
});
};
return (
<form onSubmit={handleSubmit} className="space-y-6" id="common-project-form">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<Input
label="고객사 명칭 *"
type="text"
value={companyName}
onChange={(e) => setCompanyName(e.target.value)}
placeholder="예: 삼성전자, 하이닉스"
className="text-sm"
required
/>
</div>
<div>
<Input
label="진단 타이틀 *"
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="예: 2026년 하반기 전사 조직 협업도 네트워크 분석 진단"
className="text-sm"
required
/>
</div>
<div>
<Input
label="담당자명 (이름/직급/직책)"
type="text"
value={contactName}
onChange={(e) => setContactName(e.target.value)}
placeholder="예: 김길동 부장"
className="text-sm"
/>
</div>
<div>
<Input
label="담당자 이메일"
type="email"
value={contactEmail}
onChange={(e) => setContactEmail(e.target.value)}
placeholder="client@company.com"
className="text-sm"
/>
</div>
<div>
<Input
label="설문 시작일 *"
type="date"
value={startDate}
onChange={(e) => setStartDate(e.target.value)}
className="text-sm"
required
/>
</div>
<div>
<Input
label="설문 마감일 *"
type="date"
value={endDate}
onChange={(e) => setEndDate(e.target.value)}
className="text-sm"
required
/>
</div>
<div className="md:col-span-2">
<TextArea
label="고객사 메모"
value={memo}
onChange={(e) => setMemo(e.target.value)}
placeholder="부서 네트워크 전사 모니터링 MVP 적용 목적 기입..."
rows={3}
className="text-sm resize-none"
/>
</div>
</div>
<div className="flex justify-end gap-3 border-t border-slate-100 pt-4" id="project-form-btn-wrapper">
{onCancel && (
<Button
type="button"
onClick={onCancel}
variant="secondary"
size="md"
id="project-form-cancel-btn"
>
{cancelButtonText || '취소'}
</Button>
)}
<Button
type="submit"
variant="primary"
size="md"
leftIcon={submitIcon}
id="project-form-submit-btn"
>
{submitButtonText}
</Button>
</div>
</form>
);
};
|