@php $pageConfigs = ['navbarType' => 'hidden', 'contentLayout' => 'wide']; $configData = Helper::appClasses(); $statusMap = [ 'pending' => ['Pendiente', 'warning'], 'confirmed' => ['Confirmado', 'info'], 'at_restaurant' => ['En restaurante', 'primary'], 'en_route' => ['En camino', 'primary'], 'delivered' => ['Entregado', 'success'], 'cancelled' => ['Cancelado', 'danger'], ]; [$statusLabel, $statusColor] = $statusMap[$delivery->status] ?? ['Pendiente', 'warning']; $statusTone = match ($delivery->status) { 'pending' => 'pending', 'confirmed' => 'confirmed', 'at_restaurant' => 'restaurant', 'en_route' => 'route', 'delivered' => 'delivered', 'cancelled' => 'cancelled', default => 'pending', }; $origin = $delivery->restaurant?->address ?? ''; $destination = $delivery->delivery_address ?? ''; $navApp = auth()->user()->nav_app ?? 'maps'; $navUrl = $navApp === 'waze' ? 'https://waze.com/ul?q=' . urlencode($destination) . '&navigate=yes' : 'https://www.google.com/maps/dir/?api=1&origin=' . urlencode($origin) . '&destination=' . urlencode($destination); $missingCustomerDetails = $delivery->is_urgent && ( empty($delivery->customer_name) || $delivery->customer_name === 'Por definir' || empty($delivery->delivery_address) || $delivery->delivery_address === 'Por definir' || empty($delivery->customer_phone) ); $nextAction = match ($delivery->status) { 'pending' => ['confirmed', 'Confirmar pedido', 'btn-success', 'tabler-check'], 'confirmed' => ['at_restaurant', 'He llegado al restaurante', 'btn-info', 'tabler-building-store'], 'at_restaurant' => ['en_route', 'Salir al cliente', 'btn-warning', 'tabler-bike'], 'en_route' => ['delivered', 'Marcar como entregado', 'btn-success', 'tabler-checks'], default => null, }; $nextActionBlocked = $missingCustomerDetails && $nextAction && in_array($nextAction[0], ['en_route', 'delivered'], true); $phoneForDial = preg_replace('/[^\d+]/', '', (string) ($delivery->customer_phone ?? '')); $phoneDialHref = $phoneForDial ? ('tel:' . $phoneForDial) : null; @endphp @extends('layouts/layoutMaster') @section('title', 'Pedido') @section('content')