Files
jaengseung-made/app/components/ContactForm.tsx
gahusb 19fb7a0892 Redesign full site: dashboard layout, service pages, modal contact, CookieRun font
- 전체 디자인 시스템 개편: 딥 네이비 (#04102b) + 로열 블루 (#1a56db) 팔레트
- 홈 대시보드: 가운데 정렬, 서비스별 고유 카드 디자인 (로또/주식/프롬프트/자동화)
- 서비스 페이지 4종: 각 서비스 테마 색상 + 장식 요소 + 가운데 정렬 레이아웃
- 외주 개발 페이지: 라이브 카운터 (진행중/상담중/납품완료), 수직 타임라인
- ContactModal 컴포넌트: 서비스별 모달 문의폼 + 체크리스트 (페이지 이동 없이 문의)
- CookieRun 폰트 적용 (Regular/Bold/Black, 상업적 이용 가능 라이선스)
- 실명 '박재오' → '쟁토리' 전체 변경, 7년차 강조 홈 페이지에만 표시

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 02:11:25 +09:00

176 lines
6.8 KiB
TypeScript

'use client';
import { useState, useEffect, Suspense } from 'react';
import { useSearchParams } from 'next/navigation';
function ContactFormInner() {
const searchParams = useSearchParams();
const [formData, setFormData] = useState({
name: '',
phone: '',
email: '',
service: '외주 개발 문의',
message: '',
});
const [status, setStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle');
const [errorMessage, setErrorMessage] = useState('');
useEffect(() => {
const serviceParam = searchParams.get('service');
if (serviceParam) {
setFormData((prev) => ({ ...prev, service: serviceParam }));
}
}, [searchParams]);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setStatus('loading');
setErrorMessage('');
try {
const response = await fetch('/api/contact', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData),
});
const data = await response.json();
if (!response.ok) throw new Error(data.error || '문의 전송에 실패했습니다.');
setStatus('success');
setFormData({ name: '', phone: '', email: '', service: '외주 개발 문의', message: '' });
setTimeout(() => setStatus('idle'), 5000);
} catch (error) {
setStatus('error');
setErrorMessage(error instanceof Error ? error.message : '문의 전송에 실패했습니다.');
}
};
const handleChange = (
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>
) => {
setFormData((prev) => ({ ...prev, [e.target.name]: e.target.value }));
};
return (
<form onSubmit={handleSubmit} className="space-y-4">
<div className="grid sm:grid-cols-2 gap-4">
<div>
<label className="block text-xs font-semibold text-slate-600 mb-1.5">
<span className="text-red-500">*</span>
</label>
<input
type="text"
name="name"
value={formData.name}
onChange={handleChange}
required
disabled={status === 'loading'}
placeholder="홍길동"
className="w-full px-3.5 py-2.5 text-sm border border-[#dbe8ff] rounded-xl focus:ring-2 focus:ring-[#1a56db] focus:border-[#1a56db] outline-none bg-white disabled:bg-slate-50"
/>
</div>
<div>
<label className="block text-xs font-semibold text-slate-600 mb-1.5"></label>
<input
type="tel"
name="phone"
value={formData.phone}
onChange={handleChange}
disabled={status === 'loading'}
placeholder="010-0000-0000"
className="w-full px-3.5 py-2.5 text-sm border border-[#dbe8ff] rounded-xl focus:ring-2 focus:ring-[#1a56db] focus:border-[#1a56db] outline-none bg-white disabled:bg-slate-50"
/>
</div>
</div>
<div>
<label className="block text-xs font-semibold text-slate-600 mb-1.5">
<span className="text-red-500">*</span>
</label>
<input
type="email"
name="email"
value={formData.email}
onChange={handleChange}
required
disabled={status === 'loading'}
placeholder="example@email.com"
className="w-full px-3.5 py-2.5 text-sm border border-[#dbe8ff] rounded-xl focus:ring-2 focus:ring-[#1a56db] focus:border-[#1a56db] outline-none bg-white disabled:bg-slate-50"
/>
</div>
<div>
<label className="block text-xs font-semibold text-slate-600 mb-1.5"> </label>
<select
name="service"
value={formData.service}
onChange={handleChange}
disabled={status === 'loading'}
className="w-full px-3.5 py-2.5 text-sm border border-[#dbe8ff] rounded-xl focus:ring-2 focus:ring-[#1a56db] focus:border-[#1a56db] outline-none bg-white disabled:bg-slate-50"
>
<option> </option>
<option> - </option>
<option> - </option>
<option> - </option>
<option> - </option>
<option> - </option>
<option> - </option>
<option> - </option>
<option> - </option>
<option> - / </option>
<option> - </option>
<option> - </option>
<option> - </option>
<option> </option>
</select>
</div>
<div>
<label className="block text-xs font-semibold text-slate-600 mb-1.5">
<span className="text-red-500">*</span>
</label>
<textarea
name="message"
value={formData.message}
onChange={handleChange}
required
rows={5}
disabled={status === 'loading'}
placeholder="문의하실 내용을 자유롭게 작성해주세요. 프로젝트 목적, 원하시는 기능, 예산 등을 적어주시면 더 정확한 답변이 가능합니다."
className="w-full px-3.5 py-2.5 text-sm border border-slate-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 outline-none resize-none bg-white disabled:bg-slate-50"
/>
</div>
{status === 'success' && (
<div className="bg-emerald-50 border border-emerald-200 text-emerald-800 text-sm px-4 py-3 rounded-xl">
! 24 .
</div>
)}
{status === 'error' && (
<div className="bg-red-50 border border-red-200 text-red-800 text-sm px-4 py-3 rounded-xl">
{errorMessage}
</div>
)}
<button
type="submit"
disabled={status === 'loading'}
className="w-full bg-[#1a56db] hover:bg-[#1e4fc2] text-white py-3 rounded-xl text-sm font-bold transition shadow-lg shadow-blue-900/20 disabled:opacity-50 disabled:cursor-not-allowed"
>
{status === 'loading' ? '전송 중...' : '문의 보내기'}
</button>
<p className="text-slate-400 text-xs text-center">
24 ·
</p>
</form>
);
}
export default function ContactForm() {
return (
<Suspense fallback={<div className="text-slate-400 text-sm"> ...</div>}>
<ContactFormInner />
</Suspense>
);
}