/** * ========================================================================= * PLATEFORME ECO-PANNEAU.FR - VERSION 1.0.0 * Socle Éditeur (1/4) - Onglet Informations Générales * ========================================================================= */ window.pano_PanneauEditorInfos = ({ panneau, setPanneau, lockedFields = [], validationErrors = [], uiMode, settings }) => { // 1. RÉCUPÉRATION DES COMPOSANTS ET ICÔNES GLOBAUX const AlertBox = window.pano_AlertBox || (() => null); const Button = window.pano_Button || (() => null); const { InfoIcon, LockIcon, MapPinIcon, CalendarIcon, UploadCloudIcon, CheckCircleIcon, Trash2Icon, PlusIcon } = window.pano_getIcons(); // 2. LOGIQUE D'AFFICHAGE (Mode simplifié vs pro) const isAdvanced = uiMode === 'professionnel'; const showDesc = isAdvanced || settings?.simp_opt_description === '1'; const showImage = isAdvanced || settings?.simp_opt_image === '1'; const showLink = isAdvanced || settings?.simp_opt_link === '1'; const showEmergency = isAdvanced || settings?.simp_opt_emergency === '1'; const showSchedule = isAdvanced || settings?.simp_opt_schedule === '1'; const showPractical = showLink || showEmergency || showSchedule; const isFieldLocked = (fieldId) => lockedFields.includes(fieldId); const displayOptions = panneau.displayOptions || { hideLots: false, hideIntervenants: false, hideLegal: false, customColor: '#059669', phone: '', hours: '', link: '' }; // 3. HANDLERS SPÉCIFIQUES À CE COMPOSANT const updateDisplayOption = (key, value) => { setPanneau({ ...panneau, displayOptions: { ...displayOptions, [key]: value } }); }; const handleFileUpload = async (e, type) => { const file = e.target.files[0]; if (!file) return; if (type === 'image') { const reader = new FileReader(); reader.onload = async (event) => { const base64Url = event.target.result; setPanneau(prev => ({ ...prev, imageUrl: base64Url })); try { const fileId = await window.pano_uploadFile(file, 'image', null, false, false, panneau.client_uid, panneau.id); setPanneau(prev => ({ ...prev, imageId: fileId })); } catch (err) { if (window.pano_showToast) window.pano_showToast(err, "error"); setPanneau(prev => ({ ...prev, imageUrl: '' })); } }; reader.readAsDataURL(file); } else if (type === 'pdf') { try { const fileId = await window.pano_uploadFile(file, 'pdf', null, false, false, panneau.client_uid, panneau.id); setPanneau(prev => ({ ...prev, pdfId: fileId })); } catch (err) { if (window.pano_showToast) window.pano_showToast(err, "error"); } } }; const addModifiedPermit = () => { if (isFieldLocked('permitNumber')) return; const currentArr = panneau.modifiedPermits || []; const newId = 'mod_' + Date.now() + '_' + Math.floor(Math.random() * 1000); setPanneau({ ...panneau, modifiedPermits: [...currentArr, { number: '', date: '', id: newId }] }); }; const updateModifiedPermit = (id, field, value) => { if (isFieldLocked('permitNumber')) return; const newArr = (panneau.modifiedPermits || []).map(p => p.id === id ? { ...p, [field]: value } : p); setPanneau({ ...panneau, modifiedPermits: newArr }); }; const removeModifiedPermit = (id) => { if (isFieldLocked('permitNumber')) return; const newArr = (panneau.modifiedPermits || []).filter(p => p.id !== id); setPanneau({ ...panneau, modifiedPermits: newArr }); }; // 4. RENDU return (