1import{c as C,r as R,t as l,b as S,j as t}from"./index-C3Qps0S4.js";import{C as $}from"./check-check-CghvDYsT.js";import{L as M}from"./loader-circle-DohmWZz_.js";import{B as x}from"./bell-BS0Ukiqj.js";import{Z as f}from"./zap-Dg3Ucl6s.js";import{C as p}from"./coins-Cn4zgY_g.js";import{M as u}from"./megaphone-BztIUHgH.js";import{S as N}from"./settings-Cj6VgvAK.js";function T(c){switch(c){case"formula":return"text-blue-400 bg-blue-500/20";case"credit":return"text-amber-400 bg-amber-500/20";case"promotion":return"text-green-400 bg-green-500/20";case"system":return"text-gray-400 bg-gray-500/20";default:return"text-gray-400 bg-gray-500/20"}}function A(c){switch(c){case"formula":return t.jsx(f,{"data-loc":"client/src/pages/NotificationsPage.tsx:21",className:"w-4 h-4"});case"credit":return t.jsx(p,{"data-loc":"client/src/pages/NotificationsPage.tsx:22",className:"w-4 h-4"});case"promotion":return t.jsx(u,{"data-loc":"client/src/pages/NotificationsPage.tsx:23",className:"w-4 h-4"});case"system":return t.jsx(N,{"data-loc":"client/src/pages/NotificationsPage.tsx:24",className:"w-4 h-4"});default:return t.jsx(x,{"data-loc":"client/src/pages/NotificationsPage.tsx:25",className:"w-4 h-4"})}}function H(){const{t:c,lang:a}=C(),[n,h]=R.useState("all"),j=[{id:"all",label:a==="th"?"à¸à¸±à¹à¸à¸«à¸¡à¸":"All",icon:t.jsx(x,{"data-loc":"client/src/pages/NotificationsPage.tsx:34",className:"w-3 h-3"})},{id:"formula",label:a==="th"?"สูà¸à¸£":"Formula",icon:t.jsx(f,{"data-loc":"client/src/pages/NotificationsPage.tsx:35",className:"w-3 h-3"})},{id:"credit",label:"Point",icon:t.jsx(p,{"data-loc":"client/src/pages/NotificationsPage.tsx:36",className:"w-3 h-3"})},{id:"promotion",label:a==="th"?"à¹à¸à¸£à¹à¸¡à¸à¸±à¹à¸":"Promo",icon:t.jsx(u,{"data-loc":"client/src/pages/NotificationsPage.tsx:37",className:"w-3 h-3"})},{id:"system",label:a==="th"?"ระà¸à¸":"System",icon:t.jsx(N,{"data-loc":"client/src/pages/NotificationsPage.tsx:38",className:"w-3 h-3"})}],r=l.useUtils(),{data:P,isLoading:b}=l.notifications.list.useQuery(),{data:d}=l.notifications.unreadCount.useQuery(),y=l.notifications.markRead.useMutation({onSuccess:()=>{r.notifications.list.invalidate(),r.notifications.unreadCount.invalidate()}}),w=l.notifications.markAllRead.useMutation({onSuccess:()=>{r.notifications.list.invalidate(),r.notifications.unreadCount.invalidate(),S.success(a==="th"?"à¸à¹à¸²à¸à¸à¸±à¹à¸à¸«à¸¡à¸à¹à¸¥à¹à¸§":"All marked as read")}}),m=P?.filter(e=>n==="all"||e.type===n)??[],v=e=>{const g=new Date(e),k=new Date().getTime()-g.getTime(),s=Math.floor(k/6e4);if(a==="th"){if(s<1)return"à¹à¸¡à¸·à¹à¸à¸ªà¸±à¸à¸à¸£à¸¹à¹";if(s<60)return`${s} à¸à¸²à¸à¸µà¸à¸µà¹à¹à¸¥à¹à¸§`;const i=Math.floor(s/60);if(i<24)return`${i} à¸à¸¡.à¸à¸µà¹à¹à¸¥à¹à¸§`;const o=Math.floor(i/24);return o<7?`${o} วัà¸à¸à¸µà¹à¹à¸¥à¹à¸§`:g.toLocaleDateString("th-TH")}else{if(s<1)return"Just now";if(s<60)return`${s}m ago`;const i=Math.floor(s/60);if(i<24)return`${i}h ago`;const o=Math.floor(i/24);return o<7?`${o}d ago`:g.toLocaleDateString("en-US")}};return t.jsxs("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:87",className:"space-y-4",children:[t.jsxs("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:89",className:"flex items-center justify-between",children:[t.jsxs("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:90",className:"flex items-center gap-2",children:[t.jsx("h1",{"data-loc":"client/src/pages/NotificationsPage.tsx:91",className:"text-xl font-bold text-gold-gradient",children:c.notification.title}),(d??0)>0&&t.jsxs("span",{"data-loc":"client/src/pages/NotificationsPage.tsx:93",className:"px-2 py-0.5 rounded-full bg-red-500/20 text-[10px] text-red-400 font-medium",children:[d," ",a==="th"?"à¹à¸«à¸¡à¹":"new"]})]}),(d??0)>0&&t.jsxs("button",{"data-loc":"client/src/pages/NotificationsPage.tsx:99",onClick:()=>w.mutate(),className:"flex items-center gap-1 px-2 py-1 rounded-lg bg-black/40 border border-green-500/20 text-[10px] text-green-400",children:[t.jsx($,{"data-loc":"client/src/pages/NotificationsPage.tsx:103",className:"w-3 h-3"}),c.notification.markAllRead]})]}),t.jsx("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:110",className:"flex gap-1 overflow-x-auto pb-1 scrollbar-hide",children:j.map(e=>t.jsxs("button",{"data-loc":"client/src/pages/NotificationsPage.tsx:112",onClick:()=>h(e.id),className:`flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium whitespace-nowrap transition-all ${n===e.id?"bg-gradient-to-r from-red-500 to-orange-500 text-white":"bg-black/40 text-gray-400 border border-red-500/10"}`,children:[e.icon,e.label]},e.id))}),b?t.jsx("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:129",className:"flex items-center justify-center py-12",children:t.jsx(M,{"data-loc":"client/src/pages/NotificationsPage.tsx:130",className:"w-6 h-6 text-orange-400 animate-spin"})}):m.length===0?t.jsxs("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:133",className:"glass-card rounded-xl p-8 text-center",children:[t.jsx(x,{"data-loc":"client/src/pages/NotificationsPage.tsx:134",className:"w-10 h-10 mx-auto text-gray-600 mb-3"}),t.jsx("p",{"data-loc":"client/src/pages/NotificationsPage.tsx:135",className:"text-sm text-gray-400",children:"à¹à¸¡à¹à¸¡à¸µà¸à¸²à¸£à¹à¸à¹à¸à¹à¸à¸·à¸à¸"}),t.jsx("p",{"data-loc":"client/src/pages/NotificationsPage.tsx:136",className:"text-[10px] text-gray-600 mt-1",children:n!=="all"?"ลà¸à¸à¹à¸à¸¥à¸µà¹à¸¢à¸à¸à¸±à¸§à¸à¸£à¸à¸à¸à¸¹":"à¸à¸²à¸£à¹à¸à¹à¸à¹à¸à¸·à¸à¸à¸à¸°à¸à¸£à¸²à¸à¸à¸à¸µà¹à¸à¸µà¹à¹à¸¡à¸·à¹à¸à¸¡à¸µà¸à¸´à¸à¸à¸£à¸£à¸¡"})]}):t.jsx("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:141",className:"space-y-1.5",children:m.map(e=>t.jsx("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:143",onClick:()=>{e.isRead||y.mutate({id:e.id})},className:`glass-card rounded-xl p-3 transition-all cursor-pointer active:scale-[0.98] ${e.isRead?"":"border-l-4 border-l-orange-500/60"}`,children:t.jsxs("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:154",className:"flex items-start gap-3",children:[t.jsx("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:155",className:`p-2 rounded-lg shrink-0 ${T(e.type)}`,children:A(e.type)}),t.jsxs("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:158",className:"flex-1 min-w-0",children:[t.jsxs("div",{"data-loc":"client/src/pages/NotificationsPage.tsx:159",className:"flex items-center justify-between",children:[t.jsx("p",{"data-loc":"client/src/pages/NotificationsPage.tsx:160",className:`text-sm font-medium truncate ${e.isRead?"text-gray-400":"text-white"}`,children:e.title}),!e.isRead&&t.jsx("span",{"data-loc":"client/src/pages/NotificationsPage.tsx:164",className:"w-2 h-2 rounded-full bg-orange-400 shrink-0 ml-2"})]}),e.message&&t.jsx("p",{"data-loc":"client/src/pages/NotificationsPage.tsx:168",className:"text-[11px] text-gray-500 mt-0.5 line-clamp-2",children:e.message}),t.jsx("p",{"data-loc":"client/src/pages/NotificationsPage.tsx:170",className:"text-[10px] text-gray-600 mt-1",children:v(e.createdAt)})]})]})},e.id))})]})}export{H 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.