// contact.jsx — ContactModal (buyer asks seller a question) // Lives outside admin.jsx so site pages can mount it without loading the admin shell. (function() { const { useState: _cS } = React; function ContactModal({ listing, onClose }) { const [channel, setChannel] = _cS('platform'); const [name, setName] = _cS(''); const [contact, setContact] = _cS(''); const [msg, setMsg] = _cS(''); const [sent, setSent] = _cS(false); // listings can carry the seller's handle as either `handle` (e.g. "@citytrails") or `username` const sellerHandle = (listing?.username || listing?.handle || '').replace(/^@/, '') || 'satıcı'; const send = () => { if (!msg.trim() || !name.trim()) return; const all = JSON.parse(localStorage.getItem('insta_messages_v1') || '[]'); all.unshift({ id: 'msg_' + Math.random().toString(36).slice(2, 9), listingId: listing?.id || null, username: sellerHandle, buyer: name, contact, channel, message: msg, createdAt: new Date().toISOString(), status: 'new', }); localStorage.setItem('insta_messages_v1', JSON.stringify(all)); setSent(true); }; const stop = e => e.stopPropagation(); const channels = [ { id: 'platform', label: 'Platform mesajı', sub: 'Cevap e-postanla gelir', k: '✎', c: 'var(--accent)' }, { id: 'whatsapp', label: 'WhatsApp', sub: 'Anlık yazışma', k: 'W', c: '#25d366' }, { id: 'telegram', label: 'Telegram', sub: 'Anlık yazışma', k: 'T', c: '#229ED9' }, ]; return (
Satıcı genelde 1 saat içinde dönüş yapıyor. {channel === 'platform' ? 'Cevap e-postana gelecek.' : 'Birazdan ' + (channel === 'whatsapp' ? 'WhatsApp' : 'Telegram') + ' üzerinden ulaşılacak.'}
Hesap, devir veya pazarlık hakkında ne sormak istersen yaz.