PageSourceSearch

https://living-corporate.com/assets/notifications-BlEsYWt8.js

js living-corporate.com collected 2026-10-02 05:00:05 UTC 5,716 bytes, 1 lines download raw bytes

1import{e as j,u as k,b as v,v as w,f as L,i as u,r as C,j as e,o as R,B as c,L as x,m as f,k as h}from"./index-QiiZ-xPT.js";import{A as d}from"./AppLayout-DS32LUNS.js";import{u as q}from"./useTranslation-XedzLvcK.js";import{L as A}from"./lock-NaFetfNF.js";import{C as p}from"./chevron-right-f4G5e4zR.js";import{f as z}from"./formatDistanceToNow-Cgxttm8N.js";import{I}from"./info-BcvnRFaV.js";import{L as S}from"./list-music-BmTAMQgl.js";import"./chevron-left-BlU_Pgs7.js";import"./gift-DGFeQbUI.js";import"./log-out-CqAuLeet.js";import"./library-DGVSHwk6.js";import"./history-Db1-bwk2.js";import"./video-DCxcvy3M.js";import"./en-US-BddybvhD.js";const $=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],E=j("bookmark",$);const F=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],M=j("check-check",F);function Y(){const{t:s}=q(),{isAuthenticated:a,isLoading:o}=k(),[,i]=v(),r=w(),{data:n,isLoading:g}=L({queryKey:["/api/notifications"],queryFn:async()=>{const t=await fetch("/api/notifications",{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch notifications");return t.json()},enabled:a}),l=u({mutationFn:async()=>{const t=await fetch("/api/notifications/mark-all-read",{method:"POST",credentials:"include"});if(!t.ok)throw new Error("Failed to mark all as read");return t.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["/api/notifications"]}),r.invalidateQueries({queryKey:["/api/notifications/unread-count"]})}}),y=u({mutationFn:async t=>{const m=await fetch(`/api/notifications/${t}/read`,{method:"POST",credentials:"include"});if(!m.ok)throw new Error("Failed to mark as read");return m.json()},onSuccess:()=>{r.invalidateQueries({queryKey:["/api/notifications"]}),r.invalidateQueries({queryKey:["/api/notifications/unread-count"]})}});if(C.useEffect(()=>{!o&&!a&&i("/login?redirect=/me/notifications")},[o,a,i]),o||g)return e.jsx(d,{children:e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(R,{className:"w-8 h-8 animate-spin text-primary"})})});if(!a)return e.jsx(d,{children:e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(A,{size:48,className:"mx-auto text-muted-foreground mb-4"}),e.jsx("h1",{className:"text-3xl font-bold mb-4",children:s("notifications.loginRequired")}),e.jsx("p",{className:"text-muted-foreground mb-8",children:s("notifications.loginMessage")}),e.jsx(c,{onClick:()=>i("/login?redirect=/me/notifications"),"data-testid":"button-login",children:s("notifications.logIn")})]})})});const b=t=>{switch(t){case"new_content":return e.jsx(E,{className:"w-5 h-5 text-primary"});case"list_update":return e.jsx(S,{className:"w-5 h-5 text-accent"});case"subscription":return e.jsx(h,{className:"w-5 h-5 text-green-500"});default:return e.jsx(I,{className:"w-5 h-5 text-muted-foreground"})}},N=n?.filter(t=>!t.isRead).length||0;return e.jsx(d,{children:e.jsxs("div",{className:"min-h-screen p-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6 text-sm text-muted-foreground",children:[e.jsx(x,{href:"/",children:e.jsx("span",{className:"hover:text-foreground cursor-pointer",children:s("notifications.home")})}),e.jsx(p,{size:14}),e.jsx(x,{href:"/dashboard",children:e.jsx("span",{className:"hover:text-foreground cursor-pointer",children:s("notifications.dashboard")})}),e.jsx(p,{size:14}),e.jsx("span",{className:"text-foreground",children:s("notifications.title")})]}),e.jsxs(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4},children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold","data-testid":"text-page-title",children:s("notifications.title")}),N>0&&e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>l.mutate(),disabled:l.isPending,"data-testid":"button-mark-all-read",children:[e.jsx(M,{size:16,className:"mr-2"}),s("notifications.markAllRead")]})]}),n&&n.length>0?e.jsx("div",{className:"space-y-3",children:n.map(t=>e.jsx(f.div,{initial:{opacity:0,x:-10}
1,animate:{opacity:1,x:0},className:`p-4 rounded-xl border ${t.isRead?"bg-card border-border":"bg-primary/5 border-primary/20"} transition-colors cursor-pointer hover:border-primary/40`,onClick:()=>{t.isRead||y.mutate(t.id),t.listId?i(`/lists/${t.listId}`):t.contentSlug&&i(`/learning/${t.contentSlug}`)},"data-testid":`notification-${t.id}`,children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-card flex items-center justify-center border border-border",children:b(t.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:`font-medium ${t.isRead?"text-foreground":"text-primary"}`,children:t.title}),!t.isRead&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-primary flex-shrink-0 mt-2"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.message}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:t.createdAt&&z(new Date(t.createdAt),{addSuffix:!0})})]})]})},t.id))}):e.jsxs("div",{className:"bg-card rounded-xl border border-border p-12 text-center",children:[e.jsx(h,{size:48,className:"mx-auto text-muted-foreground mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:s("notifications.noNotifications")}),e.jsx("p",{className:"text-muted-foreground mb-6",children:s("notifications.subscribePrompt")}),e.jsx(c,{variant:"outline",onClick:()=>i("/lists"),"data-testid":"button-explore-lists",children:s("notifications.exploreLists")})]})]})]})})}export{Y 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.