/* ════════════════════════════════════════════════ Halaman publik: Program, Pengajar, Fasilitas, Kegiatan, Tentang, Kontak. Semua membaca section dari API (bisa diedit admin), fallback ke data statis (MQA). ════════════════════════════════════════════════ */ /* Hook: ambil daftar section dari API ({items:[...]}) dgn fallback */ function useSection(section, fallback) { const [data, setData] = useState(fallback); useEffect(() => { let on = true; api.get(`content.php?action=get_section§ion=${section}`).then(r => { if (!on) return; const arr = (r.ok && r.data && Array.isArray(r.data.items)) ? r.data.items : null; if (arr && arr.length) setData(arr); }).catch(() => {}); return () => { on = false; }; }, [section]); return data; } /* Hook: ambil section objek (mis. 'settings'/'about') dgn fallback */ function useObjSection(section, fallback) { const [data, setData] = useState(fallback); useEffect(() => { let on = true; api.get(`content.php?action=get_section§ion=${section}`).then(r => { if (!on) return; if (r.ok && r.data && !Array.isArray(r.data) && typeof r.data === 'object') setData(d => ({ ...d, ...r.data })); }).catch(() => {}); return () => { on = false; }; }, [section]); return data; } /* Header band biru standar tiap halaman — mendukung baris Arab + override dashboard. pageKey: untuk membaca override dari section 'page_headers'. */ function PageBand({ kicker, arabic, title, sub, pageKey }) { const headers = useObjSection('page_headers', {}); const ov = (pageKey && headers && headers[pageKey]) ? headers[pageKey] : {}; const _arabic = ov.arabic !== undefined ? ov.arabic : arabic; const _title = ov.title || title; const _sub = ov.sub !== undefined ? ov.sub : sub; const _kicker = ov.kicker || kicker; const _img = ov.image || ov.bg_image; const STAR = "url(\"data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='52'%20height='52'%20viewBox='0%200%2052%2052'%3E%3Cg%20fill='none'%20stroke='%23ffffff'%20stroke-opacity='0.12'%20stroke-width='1.4'%3E%3Crect%20x='13'%20y='13'%20width='26'%20height='26'/%3E%3Crect%20x='13'%20y='13'%20width='26'%20height='26'%20transform='rotate(45%2026%2026)'/%3E%3C/g%3E%3C/svg%3E\")"; return (
{_img ? <>
:
}
{_arabic ?
{_arabic}
: (_kicker &&
{_kicker}
)}

{_title}

{_sub &&

{_sub}

}
); } /* ── PROGRAM ── */ function ProgramsPage({ navigate }) { const programs = useSection('programs', (window.MQA || {}).programs || []); return (
{programs.map(p => { const levels = Array.isArray(p.levels) ? p.levels : (p.levelsStr ? p.levelsStr.split(',').map(x => x.trim()) : []); const hasMedia = p.youtube_url || p.banner_url; return (
{hasMedia && }
{!hasMedia &&
}

{p.name}

{p.desc}

{levels.length > 0 && (
{levels.map((lv, i) => {lv})}
)} {p.schedule &&
🕐 {p.schedule}
}
); })}
); } /* ── PENGAJAR ── */ function TeachersPage() { const teachers = useSection('teachers', (window.MQA || {}).teachers || []); return (
{teachers.map(t => { const tags = Array.isArray(t.tags) ? t.tags : (t.tagsStr ? t.tagsStr.split(',').map(x => x.trim()) : []); return (
{t.initial || (t.name || '?')[0]}

{t.name}

{t.title}

{t.bio}

{tags.map((tg, i) => {tg})}
); })}
); } /* ── FASILITAS ── */ function FasilitasPage() { const items = useSection('fasilitas', (window.MQA || {}).fasilitas || []); return (
{items.map(f => (
{f.img_url ? {f.caption} : }
{f.caption}
))}
); } /* ── KEGIATAN ── */ function KegiatanPage() { const events = useSection('kegiatan', (window.MQA || {}).kegiatan || []); const badge = { upcoming: { t: 'Akan Datang', c: '#1F6B47', bg: 'rgba(31,107,71,.12)' }, past: { t: 'Selesai', c: 'var(--muted)', bg: 'var(--bg2)' } }; return (
{events.map(e => { const b = badge[e.status] || badge.upcoming; const hasMedia = e.youtube_url || e.img_url; return (
{hasMedia && }
{b.t} {e.youtube_url && ▶ Video}

{e.title}

{e.desc}

{(e.date || e.time) && 📅 {e.date}{e.time ? ' · ' + e.time : ''}} {e.location && 📍 {e.location}}
); })}
); } /* ── TENTANG ── */ function AboutPage({ navigate }) { const s = useObjSection('settings', {}); const tahun = s.tahun || '2015'; const profil1 = s.profil || "Markaz Qurrota A'yun adalah rumah ilmu yang berkomitmen membentuk generasi Qur'ani yang berakhlak mulia melalui pendidikan tahfidz, bahasa Arab, fiqih, dan akhlaq."; const profil2 = s.profil2 || "Dengan pengajar berpengalaman dan lingkungan yang islami, kami mendampingi santri dari segala usia untuk mencintai dan mengamalkan Al-Qur'an dalam kehidupan sehari-hari."; const stats = [[s.stat_santri || '500+', 'Santri Aktif'], [s.stat_pengajar || '25+', 'Pengajar'], [s.stat_program || '8', 'Program'], [tahun, 'Berdiri']]; return (
مَرْكَزُ قُرَّةِ أَعْيُن

{profil1}

{profil2}

Keluarga besar MQA
{/* Sambutan Mudir */} {(s.mudir_text || s.mudir_name) && (
{s.mudir_photo ? {s.mudir_name} : }
{s.mudir_name || 'Pimpinan'}
{s.mudir_title || 'Mudir / Pimpinan'}
Sambutan Pimpinan

"{s.mudir_text || ''}"

)} {/* Visi & Misi */} {(s.visi || s.misi) && (
{s.visi && (
Visi

{s.visi}

)} {s.misi && (
Misi
    {String(s.misi).split('\n').filter(x => x.trim()).map((m, i) => (
  • {m.replace(/^[-•\d.\s]+/, '')}
  • ))}
)}
)} {/* Nilai-Nilai (tampil hanya bila diisi) */} {s.nilai && String(s.nilai).split('\n').filter(x => x.trim()).length > 0 && (
Nilai-Nilai Kami

Prinsip yang Kami Pegang

{String(s.nilai).split('\n').filter(x => x.trim()).map((v, i) => { const [judul, ...rest] = String(v).split(/\s[—-]\s/); return (
{i + 1}
{judul}
{rest.length > 0 &&
{rest.join(' ')}
}
); })}
)}
{stats.map(([n, l]) => (
{n}
{l}
))}
{/* Testimoni */}
Bergabunglah Bersama Kami

Daftarkan diri atau putra-putri Anda, atau dukung dakwah kami melalui donasi.

); } /* ── KONTAK ── */ function ContactPage() { const s = useObjSection('settings', {}); const wa = s.wa || '628123456789'; const info = [ { icon: '📍', label: 'Alamat', val: s.address || 'Alamat belum diatur — silakan ubah di dashboard.' }, { icon: '📱', label: 'WhatsApp', val: s.phone || '+62 812-3456-7890' }, { icon: '📧', label: 'Email', val: s.email || 'info@qurrotaayun.com' }, { icon: '🕐', label: 'Jam Operasional', val: s.jam || 'Senin–Sabtu, 08.00–20.00 WIB' }, ]; const socials = [['Instagram', s.ig], ['YouTube', s.yt], ['Facebook', s.fb], ['TikTok', s.tiktok]].filter(([, v]) => v); return (
{info.map(c => (
{c.icon}
{c.label}
{c.val}
))}
{socials.length > 0 && (
{socials.map(([name, url]) => ( {name} ↗ ))}
)} {s.maps_embed ? (
📍 Lokasi Kami
) : (s.maps_link ? : null)}
); } /* Section testimoni di halaman Tentang */ function AboutTestimonials() { const items = useSection('testimonials', (window.MQA || {}).testimonials || []); if (!items.length) return null; return (
Testimoni

Kata Mereka Tentang Kami

{items.map((t, i) => (
{'★'.repeat(Math.max(1, Math.min(5, t.stars || 5)))}{'★'.repeat(5 - Math.max(1, Math.min(5, t.stars || 5)))}

"{t.text}"

{t.initial || (t.name || '?')[0]}
{t.name}
{t.role}
))}
); } Object.assign(window, { useSection, useObjSection, PageBand, ProgramsPage, TeachersPage, FasilitasPage, KegiatanPage, AboutPage, ContactPage, AboutTestimonials });