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:
root 2026-06-12 19:22:36 +00:00
parent 3e5be5edf1
commit d313a3b6b9
3 changed files with 15 additions and 2 deletions

View File

@ -347,7 +347,7 @@ export const DriverDeliveryPlanner = ({ orderGroups = [], onOpenOrder, currentUs
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 ia = statusOrder.indexOf(a);
const ib = statusOrder.indexOf(b);

View File

@ -7,6 +7,7 @@
import React from "react";
import { Navigate, useNavigate, useSearchParams, useLocation } from "react-router-dom";
import { DriverDeliveryPlanner } from "../components/driver/DriverDeliveryPlanner";
import { isOrderGroupVisibleToDriver } from "../services/orderGroupViews";
import { LogisticsReadinessBoard } from "../components/logistics/LogisticsReadinessBoard";
import { OrdersTable } from "../components/orders/OrdersTable";
import { AdminDashboard } from "../components/admin/AdminDashboard";
@ -108,6 +109,16 @@ export const DashboardPage = () => {
return [...set].sort();
}, [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
const openGroupPage = React.useCallback((groupId) => {
navigate("/dashboard/group/" + groupId);
@ -130,7 +141,7 @@ export const DashboardPage = () => {
{ 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 },
];

View File

@ -29,12 +29,14 @@ export const NOTIFICATION_STATUS_LABELS = {
};
export const DRIVER_VISIBLE_DELIVERY_STATUSES = [
"agreed",
"driver_assigned",
"loaded",
"on_route",
"problem",
"delivered",
"picked_up",
"paid_storage",
];
export const DRIVER_ACTIVE_DELIVERY_STATUSES = ["driver_assigned", "loaded", "on_route", "problem"];