// media.jsx — sección Fotografía + Audiovisual con producción/postproducción y galerías
const { useState: __mes, useEffect: __mee, useRef: __mer } = React;
/* ════════════════════════════════════════════════════════
MEDIA — wrapper con dos disciplinas
════════════════════════════════════════════════════════ */
function Media({ t }) {
const [remote, setRemote] = __mes(null);
// Carga del admin (media_items). Si falla, usamos el i18n como fallback.
__mee(() => {
let alive = true;
fetch('api/media.php', { credentials: 'same-origin' })
.then(r => r.ok ? r.json() : null)
.then(d => {
if (!alive || !d || !d.ok || !d.data) return;
const photoOk = Array.isArray(d.data.photo) && d.data.photo.length > 0;
const videoOk = Array.isArray(d.data.video) && d.data.video.length > 0;
if (photoOk || videoOk) setRemote(d.data);
})
.catch(() => {});
return () => { alive = false; };
}, []);
// Mezcla: si el admin tiene items, sobreescribe la galería del i18n
const photoBlock = remote && remote.photo && remote.photo.length
? { ...t.photo, gallery: remote.photo } : t.photo;
const videoBlock = remote && remote.video && remote.video.length
? { ...t.video, gallery: remote.video } : t.video;
return (
{t.media_sub}
{t.media_title_1} {t.media_title_2}
{block.lead}
{p.body}