const { useState, useEffect } = React; /* DIALPLAN MODAL — Adım adım wizard tarzı */ function DialplanModal({ dp, onClose, onSave }) { const [form, setForm] = useState(dp || { name: '', description: '', is_active: true, gw_name: 'netgsm', gw_username: '', gw_password: '', gw_proxy: 'sip.netgsm.com.tr', gw_register: true, gw_caller_id_in_from: true, gw_ping: 25, ext_name: 'ai_incoming', dest_number: '', dest_regex_prefix: '^(90)?', recording_enabled: true, recording_stereo: false, recording_path: '/usr/local/freeswitch/recordings/${strftime(%Y-%m-%d-%H-%M-%S)}_${caller_id_number}.wav', mode: 'qc_script', agent_id: null, qc_script_id: null, survey_id: null, ivr_id: null, // EKLENDİ policy_years: null, ws_host: '127.0.0.1', ws_port: 5000, silence_ms: 500, xml_filename: '00_ai_agent.xml', fs_dialplan_dir: '/etc/freeswitch/dialplan/public' }); const [agents, setAgents] = useState([]); const [qcScripts, setQcScripts] = useState([]); const [surveys, setSurveys] = useState([]); const [ivrs, setIvrs] = useState([]); // BU SATIR EKSİKTİ, EKLENDİ const [saving, setSaving] = useState(false); const [step, setStep] = useState(0); const [xmlPreview, setXmlPreview] = useState(''); const set = (k, v) => setForm(f => ({ ...f, [k]: v })); useEffect(() => { authFetch('/api/dialplan/options/agents').then(r => r.json()).then(setAgents).catch(() => {}); authFetch('/api/dialplan/options/qc-scripts').then(r => r.json()).then(setQcScripts).catch(() => {}); authFetch('/api/dialplan/options/surveys').then(r => r.json()).then(setSurveys).catch(() => {}); authFetch('/api/dialplan/options/ivrs').then(r => r.json()).then(setIvrs).catch(() => {}); // EKLENDİ }, []); async function save() { setSaving(true); try { const url = dp ? `/api/dialplan/${dp.id}` : '/api/dialplan'; const method = dp ? 'PUT' : 'POST'; const r = await authFetch(url, { method, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(form) }); if (r.ok) onSave(); } finally { setSaving(false); } } async function loadPreview() { if (dp) { const r = await authFetch(`/api/dialplan/${dp.id}/preview`); const d = await r.json(); setXmlPreview(d.xml); } else { setXmlPreview('Önce kaydedin, sonra XML önizleme yapabilirsiniz.'); } } const steps = [ { key: 'general', label: 'Genel', icon: '' }, { key: 'gateway', label: 'Gateway', icon: '' }, { key: 'mode', label: 'Çalışma Modu', icon: '' }, { key: 'advanced', label: 'Gelişmiş', icon: '' }, ]; const canNext = () => { if (step === 0) return form.name && form.dest_number; return true; }; const Toggle = ({ checked, onChange, label }) => (