/** * ========================================================================= * PLATEFORME ECO-PANNEAU.FR - VERSION 1.0.0 * Interface Admin - Onglet : Logistique (A1) * ========================================================================= */ window.pano_AdminLogisticsTab = ({ data, refreshData, showToast, activeModal, activeDialog, targetId, openLocalModal, openLocalDialog, closeCurrentLayer }) => { const { useState, useEffect } = React; const routerActiveDialog = activeDialog || new URLSearchParams(window.location.search).get('dialog'); const routerCloseLayer = closeCurrentLayer || (() => window.history.back()); const routerOpenDialog = openLocalDialog || ((type) => { const u = new URL(window.location); u.searchParams.set('dialog', type); window.history.pushState({ dialog: type }, '', u); window.dispatchEvent(new Event('popstate')); }); const [forceRender, setForceRender] = useState(0); useEffect(() => { if (!activeDialog) { const onPop = () => setForceRender(prev => prev + 1); window.addEventListener('popstate', onPop); return () => window.removeEventListener('popstate', onPop); } }, [activeDialog]); const [isSaving, setIsSaving] = useState(false); const [confirmConfig, setConfirmConfig] = useState(null); const [shippingTarget, setShippingTarget] = useState(null); const [trackingData, setTrackingData] = useState({ number: '', link: '' }); const Button = window.pano_Button || (() => null); const ConfirmModal = window.pano_ConfirmModal || (() => null); const StatusBadge = window.pano_StatusBadge || (() => null); const Modal = window.pano_Modal || (() => null); const PackageIcon = window.pano_PackageIcon || (() => null); const CheckCircleIcon = window.pano_CheckCircleIcon || (() => null); const EyeIcon = window.pano_EyeIcon || (() => null); const UploadIcon = window.pano_UploadIcon || (() => null); const Trash2Icon = window.pano_Trash2Icon || (() => null); const EditIcon = window.pano_EditIcon || (() => null); const DownloadIcon = window.pano_DownloadIcon || (() => null); const handleA1Upload = async (c, e) => { const file = e.target.files[0]; if(!file) return; const id = await window.pano_uploadFile(file, 'pdf', null, false, false, c.clientName, c.id); if (id) { const d = await window.pano_apiFetch('panneaux', { body: { id: c.id, status: c.status, offerType: c.offerType, currentRate: c.currentRate, physicalPanels: c.physicalPanels, details: { ...c, a1PdfId: id }, a1PdfId: id }, setLoading: setIsSaving, successMessage: "Maquette A1 attachée avec succès !" }); if(d) refreshData(); } e.target.value = null; }; const handleA1Delete = (c) => { setConfirmConfig({ title: "Retirer la maquette", message: "Voulez-vous retirer le fichier PDF A1 de ce panneau ?", confirmText: "Retirer", isDestructive: true, onConfirm: async () => { routerCloseLayer(); const d = await window.pano_apiFetch('panneaux', { body: { id: c.id, status: c.status, offerType: c.offerType, currentRate: c.currentRate, physicalPanels: c.physicalPanels, details: { ...c, a1PdfId: '' }, a1PdfId: '' }, setLoading: setIsSaving, successMessage: "Maquette retirée." }); if(d) refreshData(); } }); routerOpenDialog('confirm'); }; const updateShippingStatus = async (id, newStatus) => { const d = await window.pano_apiFetch('panneaux/shipping', { body: { id, shipping_status: newStatus }, setLoading: setIsSaving, successMessage: "Statut logistique mis à jour." }); if (d) refreshData(); }; const panneaux = data.panneaux || []; const clients = data.clients || []; const logisticPanels = panneaux.filter(p => p.physicalPanels > 0 && p.status === 'Actif'); return (
{c.name}
{owner ? owner.name : c.clientName}
En acheminement
{c.tracking_number}
Aucune commande de panneau physique en cours.