import { useEffect, useState } from "react"; import { Bell, BellOff, ChevronLeft } from "lucide-react"; import { usePushNotifications } from "~/hooks/usePushNotifications"; const SNOOZE_KEY = "store_push_prompt_snoozed_until"; const SNOOZE_MS = 24 * 60 * 60 * 1000; // 24h — a soft nudge, not a dismissal. /** * Seller-facing card at the top of the store dashboard that nudges the owner * (or a staff member) to turn on browser/PWA notifications. Order notifications * are business-critical, so unlike the global buyer banner this one is NOT * dismissible-forever — a snooze hides it for a day; the prompt returns until * push is actually subscribed. When permission was denied, we can't * re-request programmatically, so the copy switches to a "how to re-enable in * the browser" instruction. */ export function StorePushPromptCard() { const { supported, permission, isSubscribed, subscribe, busy } = usePushNotifications(); const [snoozed, setSnoozed] = useState(false); useEffect(() => { if (typeof window === "undefined") return; const until = Number(localStorage.getItem(SNOOZE_KEY) || 0); setSnoozed(!!until && Date.now() < until); }, []); // Nothing to show if the browser can't do push, they already subscribed, // or they hit "later" in the last 24h. if (!supported) return null; if (isSubscribed) return null; if (snoozed) return null; const snoozeUntilTomorrow = () => { localStorage.setItem(SNOOZE_KEY, String(Date.now() + SNOOZE_MS)); setSnoozed(true); }; const enable = async () => { await subscribe(); }; // Permission denied — we cannot prompt again from JS. Show recovery hint. if (permission === "denied") { return (
اعلانها در مرورگر مسدود شدهاند
برای دریافت اعلان سفارشهای جدید، از تنظیمات مرورگر یا PWA اعلانها را برای این سایت فعال کنید و سپس صفحه را رفرش کنید.
اعلان سفارشهای جدید را فعال کنید
تا لحظهای که یک مشتری سفارش میثبت، روی مرورگر یا موبایل خود پیامی میگیرید و هیچ سفارشی را از دست نمیدهید.