fix: driver badge shows only assigned deliveries, add agreed+paid_storage to visible statuses
- DashboardPage: driver badge now counts only groups visible to driver AND assigned to current user - DRIVER_VISIBLE_DELIVERY_STATUSES: added 'agreed' and 'paid_storage' so driver sees all relevant statuses - DriverDeliveryPlanner: added agreed/paid_storage to status sort order - Previously badge showed allOrderGroups.length (5) but list was empty because filter was too strict
This commit is contained in:
parent
3e5be5edf1
commit
d313a3b6b9
|
|
@ -347,7 +347,7 @@ export const DriverDeliveryPlanner = ({ orderGroups = [], onOpenOrder, currentUs
|
||||||
statusBuckets.get(s).items.push(item);
|
statusBuckets.get(s).items.push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusOrder = ["driver_assigned", "loaded", "on_route", "delivered", "picked_up", "problem"];
|
const statusOrder = ["agreed", "driver_assigned", "loaded", "on_route", "delivered", "picked_up", "paid_storage", "problem"];
|
||||||
const sortedBuckets = Array.from(statusBuckets.entries()).sort(([a], [b]) => {
|
const sortedBuckets = Array.from(statusBuckets.entries()).sort(([a], [b]) => {
|
||||||
const ia = statusOrder.indexOf(a);
|
const ia = statusOrder.indexOf(a);
|
||||||
const ib = statusOrder.indexOf(b);
|
const ib = statusOrder.indexOf(b);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Navigate, useNavigate, useSearchParams, useLocation } from "react-router-dom";
|
import { Navigate, useNavigate, useSearchParams, useLocation } from "react-router-dom";
|
||||||
import { DriverDeliveryPlanner } from "../components/driver/DriverDeliveryPlanner";
|
import { DriverDeliveryPlanner } from "../components/driver/DriverDeliveryPlanner";
|
||||||
|
import { isOrderGroupVisibleToDriver } from "../services/orderGroupViews";
|
||||||
import { LogisticsReadinessBoard } from "../components/logistics/LogisticsReadinessBoard";
|
import { LogisticsReadinessBoard } from "../components/logistics/LogisticsReadinessBoard";
|
||||||
import { OrdersTable } from "../components/orders/OrdersTable";
|
import { OrdersTable } from "../components/orders/OrdersTable";
|
||||||
import { AdminDashboard } from "../components/admin/AdminDashboard";
|
import { AdminDashboard } from "../components/admin/AdminDashboard";
|
||||||
|
|
@ -108,6 +109,16 @@ export const DashboardPage = () => {
|
||||||
return [...set].sort();
|
return [...set].sort();
|
||||||
}, [allOrderGroups]);
|
}, [allOrderGroups]);
|
||||||
|
|
||||||
|
// ── Driver order count (for badge) ────────────────────────────────────────
|
||||||
|
const driverOrderCount = React.useMemo(() => {
|
||||||
|
if (userRole !== "driver" || !user) return 0;
|
||||||
|
return allOrderGroups.filter((g) => {
|
||||||
|
const isVisible = isOrderGroupVisibleToDriver(g);
|
||||||
|
const isAssignedToMe = g.assignedDriverId === user.id;
|
||||||
|
return isVisible && isAssignedToMe;
|
||||||
|
}).length;
|
||||||
|
}, [allOrderGroups, user, userRole]);
|
||||||
|
|
||||||
// ── Navigation Builder ────────────────────────────────────────────────────
|
// ── Navigation Builder ────────────────────────────────────────────────────
|
||||||
const openGroupPage = React.useCallback((groupId) => {
|
const openGroupPage = React.useCallback((groupId) => {
|
||||||
navigate("/dashboard/group/" + groupId);
|
navigate("/dashboard/group/" + groupId);
|
||||||
|
|
@ -130,7 +141,7 @@ export const DashboardPage = () => {
|
||||||
{ key: "logistics", label: "Логистика", description: "Группы доставки по готовности к уведомлению.", badge: String(allOrderGroups.length || orderGroups.length || 0) },
|
{ key: "logistics", label: "Логистика", description: "Группы доставки по готовности к уведомлению.", badge: String(allOrderGroups.length || orderGroups.length || 0) },
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
{ key: section.key, label: section.label, description: section.description, badge: String(allOrderGroups.length || orderGroups.length || 0) },
|
{ key: section.key, label: section.label, description: section.description, badge: String(userRole === "driver" ? driverOrderCount : (allOrderGroups.length || orderGroups.length || 0)) },
|
||||||
{ key: "suggestions", label: "Предложения", description: "Предложить улучшение.", badge: null },
|
{ key: "suggestions", label: "Предложения", description: "Предложить улучшение.", badge: null },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,14 @@ export const NOTIFICATION_STATUS_LABELS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const DRIVER_VISIBLE_DELIVERY_STATUSES = [
|
export const DRIVER_VISIBLE_DELIVERY_STATUSES = [
|
||||||
|
"agreed",
|
||||||
"driver_assigned",
|
"driver_assigned",
|
||||||
"loaded",
|
"loaded",
|
||||||
"on_route",
|
"on_route",
|
||||||
"problem",
|
"problem",
|
||||||
"delivered",
|
"delivered",
|
||||||
"picked_up",
|
"picked_up",
|
||||||
|
"paid_storage",
|
||||||
];
|
];
|
||||||
|
|
||||||
export const DRIVER_ACTIVE_DELIVERY_STATUSES = ["driver_assigned", "loaded", "on_route", "problem"];
|
export const DRIVER_ACTIVE_DELIVERY_STATUSES = ["driver_assigned", "loaded", "on_route", "problem"];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue