/** * ========================================================================= * PLATEFORME ECO-PANNEAU.FR - VERSION 1.0.0 * Composant : Modale de gestion des liens de saisie déléguée * ========================================================================= */ const { useState } = React; window.pano_ClientDelegateShareModal = ({ managingPanneau, setManagingPanneau, onClose, refreshData, showToast }) => { const { activeDialog, openDialog, closeCurrentLayer } = window.pano_useUrlModal(); const routerCloseLayer = onClose || closeCurrentLayer; const { PlusIcon, LockIcon, CopyIcon, Trash2Icon, LinkIcon } = window.pano_getIcons(); const Modal = window.pano_Modal; const AlertBox = window.pano_AlertBox; const EmptyState = window.pano_EmptyState; const Toggle = window.pano_Toggle; const ConfirmModal = window.pano_ConfirmModal; const Button = window.pano_Button; const [newLink, setNewLink] = useState({ name: '', expDays: 7, lockedFields: [] }); const [isSaving, setIsSaving] = useState(false); const [confirmConfig, setConfirmConfig] = useState(null); const isDirty = newLink.name.trim() !== '' || newLink.expDays !== 7 || newLink.lockedFields.length > 0; return (
* Champs obligatoires
Créez des liens sécurisés pour confier la saisie d'informations ou le dépôt de documents (PDF) à d'autres membres de l'équipe du chantier sans leur donner accès à votre compte ou à votre facturation.

Créer un nouveau lien

setNewLink({...newLink, name: e.target.value})} placeholder="Ex: Architecte Dupont" className="w-full border border-slate-200 rounded-xl p-3 text-sm outline-none focus:border-blue-500 font-bold" />
setNewLink({...newLink, expDays: parseInt(e.target.value)||7})} className="w-full border border-slate-200 rounded-xl p-3 text-sm outline-none focus:border-blue-500 font-bold" />
{[ { id: 'name', label: 'Nom du chantier' }, { id: 'location', label: 'Lieu' }, { id: 'maitreOuvrage', label: "Maître d'ouvrage" }, { id: 'permitNumber', label: 'N° de permis' }, { id: 'description', label: 'Description' }, { id: 'promoterLink', label: 'Lien promoteur' }, { id: 'emergencyPhone', label: 'N° d\'urgence' }, { id: 'noiseSchedule', label: 'Horaires' }, { id: 'intervenants', label: 'Intervenants' }, { id: 'lots', label: 'Lots' }, { id: 'pdfId', label: 'Arrêté (PDF)' } ].map(f => (
setNewLink(p => ({...p, lockedFields: p.lockedFields.includes(f.id) ? p.lockedFields.filter(x=>x!==f.id) : [...p.lockedFields, f.id]}))} className={`px-3 py-1.5 rounded-lg text-xs font-bold transition border cursor-pointer ${newLink.lockedFields.includes(f.id) ? 'bg-red-50 text-red-600 border-red-200' : 'bg-slate-50 text-slate-500 border-slate-200 hover:bg-slate-100'}`}> {newLink.lockedFields.includes(f.id) && }{f.label}
))}

Liens générés pour ce panneau

{(!managingPanneau.delegate_links || managingPanneau.delegate_links.length === 0) && ( )} {managingPanneau.delegate_links?.map((link, idx) => { const isExpired = link.exp < Date.now() / 1000; return (

{link.name}

Exp. : {new Date(link.exp * 1000).toLocaleDateString('fr-FR')} {isExpired && (Expiré)}

{ const links = [...managingPanneau.delegate_links]; links[idx] = { ...links[idx], active: newVal }; const updatedPanneau = { ...managingPanneau, delegate_links: links }; const d = await window.pano_apiFetch('panneaux', { body: { id: updatedPanneau.id, status: updatedPanneau.status, offerType: updatedPanneau.offerType, physicalPanels: updatedPanneau.physicalPanels, details: updatedPanneau }, setLoading: setIsSaving }); if (d) { setManagingPanneau(updatedPanneau); if (refreshData) refreshData(); } }} />
{link.lockedFields && link.lockedFields.length > 0 && (

Verrouillés : {link.lockedFields.join(', ')}

)}
); })}
{activeDialog === 'confirm' && confirmConfig && ConfirmModal && ( { setConfirmConfig(null); closeCurrentLayer(); }} zIndex="z-[350]" /> )}
); }; /* EOF ========== [_react/_clients_modals_delegate.jsx] */