// components/NewLeadModal.tsx 'use client'; import React, { useState } from 'react'; import { X, Building2, Phone, User, MapPin, Plus, Save, DollarSign } from 'lucide-react'; import { PIPELINE_STAGES } from '@/lib/automation'; interface NewLeadModalProps { isOpen: boolean; onClose: () => void; onSuccess: () => void; } export function NewLeadModal({ isOpen, onClose, onSuccess }: NewLeadModalProps) { if (!isOpen) return null; const [name, setName] = useState(''); const [city, setCity] = useState('تهران'); const [district, setDistrict] = useState(''); const [managerName, setManagerName] = useState(''); const [phone, setPhone] = useState(''); const [instagram, setInstagram] = useState(''); const [website, setWebsite] = useState(''); const [stage, setStage] = useState('ارتباط اولیه'); const [dealValue, setDealValue] = useState(15000000); const [roomName, setRoomName] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!name.trim() || !phone.trim() || !city.trim()) { setError('نام مجموعه، شهر و شماره تماس الزامی هستند.'); return; } setLoading(true); setError(''); try { const res = await fetch('/api/leads', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: name.trim(), city: city.trim(), district: district.trim() || null, ownerName: managerName.trim() || 'مدیر مجموعه', ownerPhone: phone.trim(), managerName: managerName.trim() || null, phone: phone.trim(), stage, rooms: roomName.trim() ? [{ title: roomName.trim(), minPlayers: 4, maxPlayers: 8, ticketPrice: 250000 }] : [] }) }); if (!res.ok) { const d = await res.json(); throw new Error(d.error || 'خطا در ثبت لید'); } onSuccess(); onClose(); } catch (err: any) { setError(err.message || 'خطا در برقراری ارتباط'); } finally { setLoading(false); } }; return (

افزودن مجموعه اتاق فرار جدید

ثبت لید جدید در پایپ‌لاین فروش اکیپا

{error && (
{error}
)}
setName(e.target.value)} placeholder="مثال: اتاق فرار طاعون سیاه" className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setCity(e.target.value)} placeholder="تهران / کرج / اصفهان ..." className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setDistrict(e.target.value)} placeholder="مثال: سعادت‌آباد، فردیس" className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setManagerName(e.target.value)} placeholder="مثال: احسان رضایی" className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setPhone(e.target.value)} placeholder="09123456789" className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setInstagram(e.target.value)} placeholder="@escaperoom_ir" className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setWebsite(e.target.value)} placeholder="https://t4f.ir/..." className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setDealValue(Number(e.target.value))} className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
setRoomName(e.target.value)} placeholder="مثال: اتاق جن‌گیر (۶ نفره - ۲۵۰,۰۰۰ تومان)" className="w-full text-xs px-3 py-2.5 rounded-xl border border-slate-300 focus:ring-2 focus:ring-teal-500" />
); }