diff --git a/src/components/orders/OrderDetailPanel.jsx b/src/components/orders/OrderDetailPanel.jsx index 5a2bf17..cdb8163 100644 --- a/src/components/orders/OrderDetailPanel.jsx +++ b/src/components/orders/OrderDetailPanel.jsx @@ -353,6 +353,12 @@ const normalizeDateForInput = (value) => { return `20${year}-${month}-${day}`; } + const fullDateMatch = normalized.match(/^(\d{2})\.(\d{2})\.(\d{4})$/); + if (fullDateMatch) { + const [, day, month, year] = fullDateMatch; + return `${year}-${month}-${day}`; + } + return ""; }; @@ -654,7 +660,7 @@ export const OrderDetailPanel = ({ }, [order?.id, order?.assignedDriverId]); React.useEffect(() => { - const normalizedDeliveryDate = normalizeDateForInput(order?.deliveryDate); + const normalizedDeliveryDate = normalizeDateForInput(order?.deliveryDate || order?.customerDate); const nextSelectableDateKey = getNextSelectableDateKey(); const canUsePastDate = ["logistician", "admin", "mega_admin", "manager"].includes(userRole); const selectedDateKey = (normalizedDeliveryDate && (canUsePastDate || isFutureDeliveryDate(normalizedDeliveryDate))) @@ -1197,11 +1203,7 @@ export const OrderDetailPanel = ({ return statusOptions.map((statusOption) => { const isSelected = pendingStatus?.value === statusOption.value; const isMismatch = statusOption.mismatch; - const hasDeliveryDate = !!(order?.deliveryDate || order?.customerDate); - const hasDeliverySchedule = hasDeliveryDate && !!(order?.deliveryTime || order?.deliveryHalfDay || order?.delivery_time); - const canSkipHalfDay = ["logistician", "admin", "mega_admin", "manager"].includes(userRole); - const scheduleReady = canSkipHalfDay ? hasDeliveryDate : hasDeliverySchedule; - const blockedBySchedule = statusOption.requiresSchedule && !scheduleReady; + const blockedBySchedule = statusOption.requiresSchedule && !hasDeliverySchedule; return (