PageSourceSearch

https://redgo.in/assets/js/Notifications-A-xFppIS.js

js redgo.in collected 2026-09-24 15:05:34 UTC 7,660 bytes, 1 lines download raw bytes

1import{r as l,j as t,d as T}from"./index-Cf_ajVON.js";import{A as B}from"./AnimatedPage-B7ZsTwkH.js";import{B as w}from"./button-B3Z62-N_.js";import{C as I,d as $}from"./card-Dg3aNavH.js";import{B as R}from"./badge-CH6QMqMp.js";import{u as J}from"./useNotificationInbox-VAdTR4w4.js";import{A as P}from"./arrow-left-1EukSswS.js";import{B as x}from"./bell-DTCvULxx.js";import{T as M}from"./trash-2-B1Y_baWX.js";import{C as U}from"./circle-alert-Dghg6EjM.js";import{G as _}from"./gift-CAkmCbUl.js";import{T as G}from"./tag-BuvDaRmB.js";import{C as Y}from"./circle-check-CLROJLC6.js";import{X as z}from"./x-BzwCsDoT.js";import{C as K}from"./clock-BLUAwf4T.js";import"./index-Bx4n9Pg3.js";import"./index-DvNrSChk.js";import"./index-D2QmRZ8G.js";import"./index-BZFWozEr.js";const g="food_user_notifications",q={CheckCircle2:Y,Tag:G,Gift:_,AlertCircle:U,Bell:x},h=r=>{if(!r||typeof r!="object")return!0;const d=String(r.id||""),o=String(r.title||""),n=String(r.message||"");return!!(d==="1"||d==="2"||o==="Order Confirmed"&&n.includes("#12345")||o==="Special Offer"&&n.includes("50% off"))},u=()=>{try{const r=localStorage.getItem(g);if(!r)return[];const d=JSON.parse(r);return Array.isArray(d)?d.filter(o=>!h(o)):[]}catch{return[]}};function ge(){const[r,d]=l.useState(()=>u()),{items:o,unreadCount:n,markAsRead:N,dismiss:j,dismissAll:k,loading:v}=J("user",{limit:100});l.useEffect(()=>{const e=u();try{localStorage.setItem(g,JSON.stringify(e))}catch{}d(e)},[]),l.useEffect(()=>{try{localStorage.setItem(g,JSON.stringify(r))}catch{}queueMicrotask(()=>{window.dispatchEvent(new CustomEvent("notificationsUpdated",{detail:{count:r.filter(e=>!e.read).length}}))})},[r]),l.useEffect(()=>{const e=()=>{const s=u();d(a=>{try{if(JSON.stringify(a)===JSON.stringify(s))return a}catch{}return s})},i=s=>{s.key===g&&e()};return window.addEventListener("notificationsUpdated",e),window.addEventListener("storage",i),()=>{window.removeEventListener("notificationsUpdated",e),window.removeEventListener("storage",i)}},[]),l.useEffect(()=>{const e=i=>{const{orderId:s,otp:a,message:E,orderType:O}=i.detail||{},L=O==="takeaway",p={id:`otp-${s||"x"}-${a||Date.now()}`,type:"alert",title:L?"Takeaway OTP Received":"Delivery OTP Received",message:E||`Your OTP for order #${s} is ${a}`,time:"Just now",timestamp:Date.now(),read:!1,icon:"AlertCircle",iconColor:"text-[#991B1B]"};d(y=>{const b=y.filter(m=>!h(m)),D=`otp-${s||"x"}`;return b.some(m=>String(m.id||"").startsWith(D)||m.title===p.title&&m.message===p.message)?y:[p,...b].slice(0,100)})};return window.addEventListener("deliveryOtpReceived",e),()=>window.removeEventListener("deliveryOtpReceived",e)},[]);const c=l.useMemo(()=>{const e=(r||[]).filter(s=>!h(s)).map(s=>({...s,source:"local"}));return[...(o||[]).map(s=>({...s,source:"broadcast",type:"broadcast",time:s.createdAt?new Date(s.createdAt).toLocaleString("en-IN",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit",hour12:!0}):"Just now",timestamp:s.createdAt||Date.now(),icon:"Bell",iconColor:"text-blue-600"})),...e].sort((s,a)=>new Date(a.timestamp||a.createdAt||0).getTime()-new Date(s.timestamp||s.createdAt||0).getTime())},[o,r]),f=r.filter(e=>!e.read&&!h(e)).length+n,C=(e,i="local")=>{if(i==="broadcast"){N(e);return}d(s=>s.map(a=>a.id===e?{...a,read:!0}:a))},A=()=>{d([]),k()},S=(e,i="local")=>{if(i==="broadcast"){j(e);return}d(s=>s.filter(a=>a.id!==e))};return t.jsx(B,{className:"min-h-screen bg-white dark:bg-[#0a0a0a]",children:t.jsxs("div",{className:"max-w-md md:max-w-2xl lg:max-w-4xl xl:max-w-5xl mx-auto px-3 sm:px-4 md:px-6 lg:px-8 py-4 sm:py-6 md:py-8",children:[t.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 mb-4 md:mb-6 lg:mb-8",children:[t.jsx(T,{to:"/food/user",children:t.jsx(w,{variant:"ghost",size:"icon",className:"rounded-full h-8 w-8 sm:h-10 sm:w-10",children:t.jsx(P,{className:"h-4 w-4 sm:h-5 sm:w-5"})})}),t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-1",children:[t.jsx(x,{className:"h-5 w-5 sm:h-6 sm:w-6 text-[#DC2626] fill-[#DC2626]"}),t.jsx("h1",{className:"text-lg sm:text-xl md:text-2xl lg:text-3xl font-bold text-gray-800 dark:text-white",children:"Notifications"}),f>0&&t.jsx(R,{className:"bg-green-500 text-white text-xs md:text-sm",children:f})]}),c.length>0&&t.jsxs(w,{variant:"ghost",size:"sm",onClick:A,className:"text-gray-500 hover:text-red-500 transition-colors flex items-center gap-1.5 px-2 md:px-3",children:[t.jsx(M,{className:"h-4 w-4"}),t.jsx("span",{className:"text-xs md:text-sm font-medium",children:"Clear All"})]})]}),v&&c.length===0?t.jsx("div",{className:"space-y-3 md:space-y-4 pt-1",children:[1,2,3].map(e=>t.jsxs("div",{className:"animate-pulse bg-white dark:bg-gray-800 rounded-2xl p-4 border border-gray-200 dark:border-gray-700 flex items-start gap-4",children:[t.jsx("div",{className:"w-10 h-10 sm:w-12 sm:h-12 rounded-full bg-gray-200 dark:bg-gray-700 shrink-0"}),t.jsxs("div",{className:"flex-1 space-y-2 py-1",children:[t.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/3"}),t.jsx("div",{className:"h-3.5 bg-gray-200 dark:bg-gray-700 rounded w-5/6"}),t.jsx("div",{className:"h-3 bg-gray-150 dark:bg-gray-750 rounded w-1/4"})]})]},e))}):c.length>0?t.jsx("div",{className:"space-y-3 md:space-y-4",children:c.map(e=>{const i=q[e.icon]||x;return t.jsxs(I,{onClick:()=>C(e.id,e.source),className:`relative cursor-pointer transition-all duration-200 py-1 hover:shadow-md ${e.read?"bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-700":"bg-red-50/50 dark:bg-red-900/20 border-red-200 dark:border-red-800"}`,children:[!e.read&&t.jsx("div",{className:"absolute top-2 right-2 w-2.5 h-2.5 md:w-3 md:h-3 bg-[#DC2626] rounded-full"}),t.jsx($,{className:"p-3 md:p-4 lg:p-5",children:t.jsxs("div",{className:"flex items-start gap-3 sm:gap-4 md:gap-5",children:[t.jsx("div",{className:`flex-shrink-0 w-10 h-10 sm:w-12 sm:h-12 md:w-14 md:h-14 roun
1ded-full flex items-center justify-center ${e.type==="order"?"bg-green-100 dark:bg-green-900/40":e.type==="offer"?"bg-red-100 dark:bg-red-900/40":e.type==="broadcast"?"bg-blue-100 dark:bg-blue-900/40":"bg-orange-100 dark:bg-orange-900/40"}`,children:t.jsx(i,{className:`h-5 w-5 sm:h-6 sm:w-6 md:h-7 md:w-7 ${e.iconColor}`})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-start justify-between gap-2 mb-1 md:mb-2",children:[t.jsx("h3",{className:`text-sm sm:text-base md:text-lg font-semibold ${e.read?"text-gray-700 dark:text-gray-300":"text-gray-900 dark:text-white"}`,children:e.title}),t.jsx("button",{type:"button","aria-label":"Delete notification",onClick:s=>{s.stopPropagation(),S(e.id,e.source)},className:"flex-shrink-0 rounded-full p-1 text-gray-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:t.jsx(z,{className:"h-4 w-4"})})]}),t.jsx("p",{className:"text-xs sm:text-sm md:text-base text-gray-600 dark:text-gray-400 mb-2 md:mb-3 whitespace-pre-line break-words",children:e.message}),t.jsxs("div",{className:"flex items-center gap-1 text-xs md:text-sm text-gray-500 dark:text-gray-400",children:[t.jsx(K,{className:"h-3 w-3 md:h-4 md:w-4"}),t.jsx("span",{children:e.time})]})]})]})})]},`${e.source}-${e.id}`)})}):t.jsxs("div",{className:"text-center py-12 md:py-16 lg:py-20",children:[t.jsx(x,{className:"h-16 w-16 md:h-20 md:w-20 lg:h-24 lg:w-24 text-gray-300 dark:text-gray-600 mx-auto mb-4 md:mb-5 lg:mb-6"}),t.jsx("h3",{className:"text-lg md:text-xl lg:text-2xl font-semibold text-gray-700 dark:text-gray-300 mb-2 md:mb-3",children:"No notifications"}),t.jsx("p",{className:"text-sm md:text-base text-gray-500 dark:text-gray-400",children:"You're all caught up!"})]})]})})}export{ge as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.