feat: 구매 신청 모달에 이름 필드 추가 (입금자명 매칭용)

이메일 로컬파트 대신 사용자 입력 이름을 /api/contact name 필드 및 메시지 본문에 포함 — 입금 확인 시 계좌이체 입금자명과 대조 용이.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-15 01:16:10 +09:00
parent 8da844bb40
commit 91c0073f23

View File

@@ -29,6 +29,7 @@ export default function PurchaseAgreementModal({
bankInfo = DEFAULT_BANK, bankInfo = DEFAULT_BANK,
}: Props) { }: Props) {
const [agreed, setAgreed] = useState(false); const [agreed, setAgreed] = useState(false);
const [name, setName] = useState('');
const [email, setEmail] = useState(''); const [email, setEmail] = useState('');
const [sent, setSent] = useState(false); const [sent, setSent] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -36,6 +37,7 @@ export default function PurchaseAgreementModal({
useEffect(() => { useEffect(() => {
if (!isOpen) { if (!isOpen) {
setAgreed(false); setAgreed(false);
setName('');
setEmail(''); setEmail('');
setSent(false); setSent(false);
} }
@@ -44,7 +46,7 @@ export default function PurchaseAgreementModal({
if (!isOpen) return null; if (!isOpen) return null;
const handleSubmit = async () => { const handleSubmit = async () => {
if (!agreed || !email) return; if (!agreed || !email || !name.trim()) return;
setLoading(true); setLoading(true);
try { try {
await fetch('/api/contact', { await fetch('/api/contact', {
@@ -52,10 +54,10 @@ export default function PurchaseAgreementModal({
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
service: `구매 신청: ${productName}`, service: `구매 신청: ${productName}`,
name: email.split('@')[0], name: name.trim(),
email, email,
phone: '', phone: '',
message: `상품: ${productName} (${price})\n입금 대기 중. 입금 확인 후 이메일로 상품 전달 예정.`, message: `상품: ${productName} (${price})\n입금자명: ${name.trim()}\n입금 대기 중. 입금 확인 후 이메일로 상품 전달 예정.`,
}), }),
}); });
setSent(true); setSent(true);
@@ -103,6 +105,19 @@ export default function PurchaseAgreementModal({
</div> </div>
) : ( ) : (
<div className="p-6 space-y-5"> <div className="p-6 space-y-5">
<div>
<label className="block text-xs font-bold text-slate-700 mb-2">
( )
</label>
<input
type="text"
value={name}
onChange={(e) => setName(e.target.value)}
placeholder="홍길동"
className="w-full px-4 py-3 border border-slate-300 rounded-xl text-sm focus:outline-none focus:border-violet-500"
/>
</div>
<div> <div>
<label className="block text-xs font-bold text-slate-700 mb-2"> <label className="block text-xs font-bold text-slate-700 mb-2">
( ) ( )
@@ -171,7 +186,7 @@ export default function PurchaseAgreementModal({
</button> </button>
<button <button
onClick={handleSubmit} onClick={handleSubmit}
disabled={!agreed || !email || loading} disabled={!agreed || !email || !name.trim() || loading}
className="flex-[2] py-3 bg-violet-600 hover:bg-violet-500 disabled:bg-slate-300 disabled:cursor-not-allowed text-white rounded-xl text-sm font-bold transition" className="flex-[2] py-3 bg-violet-600 hover:bg-violet-500 disabled:bg-slate-300 disabled:cursor-not-allowed text-white rounded-xl text-sm font-bold transition"
> >
{loading ? '전송 중...' : '구매 신청'} {loading ? '전송 중...' : '구매 신청'}