import React from "react"; import { useNotificationPreferences } from "../../hooks/useNotifications"; import { usePushNotifications } from "../../hooks/usePushNotifications"; import { Panel } from "../UI/Panel"; import { Bell, Settings } from "../UI/Icons"; const ALL_NOTIF_TYPES = [ { key: "order_status_change", label: "Изменение статуса", description: "Статус заказа или доставки изменился", roles: ["manager", "logistician", "driver", "admin", "mega_admin"] }, { key: "driver_assigned", label: "Назначение на заказ", description: "Вам назначили заказ или доставку", roles: ["driver"] }, { key: "driver_unassigned", label: "Снятие с заказа", description: "Вас сняли с заказа или доставки", roles: ["driver"] }, { key: "delivery_problem", label: "Проблемы и отмены", description: "Отмена, проблема, невозможность дозвониться", roles: ["manager", "logistician", "admin", "mega_admin"] }, { key: "new_order", label: "Новый заказ", description: "Создан новый заказ в системе", roles: ["manager", "logistician", "admin", "mega_admin"] }, { key: "group_status_change", label: "Изменение группы доставки", description: "Статус группы доставки обновлён", roles: ["logistician", "manager", "admin", "mega_admin"] }, ]; export function NotificationSettings({ userId, userRole, onBack }) { const { prefs, isLoading: prefsLoading, updatePref } = useNotificationPreferences(userId); const { isSupported, isSubscribed, isLoading: pushLoading, subscribe, unsubscribe } = usePushNotifications(userId); const role = userRole || "manager"; const visibleTypes = ALL_NOTIF_TYPES.filter((t) => t.roles.includes(role)); const loading = prefsLoading || pushLoading; return (
{onBack && ( )}

Настройки уведомлений

{/* Push toggle */}

Push-уведомления

{isSupported ? isSubscribed ? "Включены — вы получаете уведомления на устройстве" : "Выкл — нажмите чтобы включить" : "Не поддерживаются в этом браузере"}

{isSupported && ( )}
{/* Type preferences */}

Что уведомлять

{visibleTypes.map(({ key, label, description }) => ( ))}
); }