veza/.build/incus/web/js/NotificationsPage-DKYvsusD.js
senke 1ed6e7f07b state-ownership: delete unused optimisticStoreUpdates.ts file
- Deleted apps/web/src/utils/optimisticStoreUpdates.ts (unused file)
- File was unused - no imports found in codebase
- Mutations already use React Query's onMutate pattern
- No TypeScript errors after deletion
- Actions 4.4.1.2 and 4.4.1.3 complete
2026-01-15 19:26:53 +01:00

2 lines
5.5 KiB
JavaScript

import{r as f,a3 as I,t as L,a4 as P,a5 as p,j as e,B as w,aA as y,a7 as B,aL as l,aM as n,aV as v,a6 as A,h as D,bt as g,bn as b,ae as O,M as Q}from"./chunk-m7Vgm5hx.js";import{B as K}from"./chunk-CSrBv2n5.js";import{L as U,D as Y,E as $,F as z}from"./index-vht7ZNSp.js";import{f as V,a as G}from"./chunk-B4NZlYwU.js";import"./chunk-Dj70Y9U3.js";import"./chunk-CbPYJovs.js";import"./chunk-VMUEamc6.js";import"./chunk-DZ12PeIs.js";import"./chunk-pW9FG0iV.js";const H={new_message:"Message",track_uploaded:"Track",user_mentioned:"Mention",system:"System",friend_request:"Friend Request",conversation_invite:"Conversation Invite"},J={new_message:e.jsx(g,{className:"h-4 w-4"}),track_uploaded:e.jsx(Q,{className:"h-4 w-4"}),user_mentioned:e.jsx(b,{className:"h-4 w-4"}),system:e.jsx(O,{className:"h-4 w-4"}),friend_request:e.jsx(b,{className:"h-4 w-4"}),conversation_invite:e.jsx(g,{className:"h-4 w-4"})};function ne(){const[a,i]=f.useState("all"),[t,c]=f.useState("all"),{success:r,error:u}=I(),h=L(),{data:C,isLoading:_,isError:M,error:N}=P({queryKey:["notifications",a,t],queryFn:()=>z({read:a==="all"?void 0:a==="read",type:t==="all"?void 0:t})}),o=C?.notifications||[],d=o.filter(s=>!s.read),F=o.filter(s=>s.read),T=p({mutationFn:$,onSuccess:()=>{h.invalidateQueries({queryKey:["notifications"]}),r("Notification marked as read")},onError:s=>{u(s.message||"Failed to mark notification as read")}}),m=p({mutationFn:Y,onSuccess:()=>{h.invalidateQueries({queryKey:["notifications"]}),r("All notifications marked as read")},onError:s=>{u(s.message||"Failed to mark all notifications as read")}}),x=s=>{T.mutate(s)},R=()=>{d.length!==0&&m.mutate()},S=s=>{s.read||x(s.id),s.link},j=a==="all"?o:a==="unread"?d:F,E=d.length>0;return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Notifications"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your notifications and stay updated"})]}),E&&e.jsx(w,{onClick:R,disabled:m.isPending,variant:"outline",children:m.isPending?e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"mr-2 h-4 w-4"}),"Marking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"mr-2 h-4 w-4"}),"Mark All as Read"]})})]}),e.jsx(l,{className:"mb-6",children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Status"}),e.jsx(v,{options:[{value:"all",label:"All"},{value:"unread",label:"Unread"},{value:"read",label:"Read"}],value:a,onChange:s=>i(Array.isArray(s)?s[0]:s)})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Type"}),e.jsx(v,{options:[{value:"all",label:"All Types"},{value:"new_message",label:"Messages"},{value:"track_uploaded",label:"Tracks"},{value:"user_mentioned",label:"Mentions"},{value:"system",label:"System"},{value:"friend_request",label:"Friend Requests"},{value:"conversation_invite",label:"Conversations"}],value:t,onChange:s=>c(Array.isArray(s)?s[0]:s)})]})]})})}),_?e.jsx(l,{children:e.jsx(n,{className:"pt-6",children:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(y,{})})})}):M?e.jsx(l,{children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"text-center text-destructive",children:[e.jsx("p",{children:"Failed to load notifications"}),N instanceof Error&&e.jsx("p",{className:"text-sm mt-2",children:N.message})]})})}):j.length===0?e.jsx(l,{children:e.jsx(n,{className:"pt-6",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(A,{className:"h-16 w-16 mx-auto mb-4 text-muted-foreground opacity-50"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Notifications"}),e.jsx("p",{className:"text-muted-foreground",children:a==="unread"?"You're all caught up! No unread notifications.":"No notifications found."})]})})}):e.jsx("div",{className:"space-y-2",children:j.map(s=>{const q=s.link?e.jsx(U,{to:s.link,onClick:()=>S(s),className:"block",children:e.jsx(k,{notification:s,onMarkAsRead:x})}):e.jsx(k,{notification:s,onMarkAsRead:x});return e.jsx(l,{className:`transition-colors ${s.read?"":"border-primary bg-primary/5"}`,children:q},s.id)})})]})})}function k({notification:a,onMarkAsRead:i}){const t=J[a.type]||e.jsx(A,{className:"h-4 w-4"}),c=H[a.type]||a.type;return e.jsx(n,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"mt-1 flex-shrink-0",children:t}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[!a.read&&e.jsx("span",{className:"h-2 w-2 bg-primary rounded-full flex-shrink-0"}),e.jsx("h3",{className:`text-sm font-medium ${a.read?"":"font-semibold"}`,children:a.title}),e.jsx(K,{variant:"secondary",className:"text-xs",children:c})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:a.content}),e.jsx("p",{className:"text-xs text-muted-foreground",children:V(new Date(a.created_at),{addSuffix:!0,locale:G})})]}),!a.read&&e.jsx(w,{variant:"ghost",size:"icon",className:"h-8 w-8 flex-shrink-0",onClick:r=>{r.preventDefault(),r.stopPropagation(),i(a.id)},"aria-label":"Mark as read",children:e.jsx(D,{className:"h-4 w-4"})})]})})]})})}export{ne as NotificationsPage};
//# sourceMappingURL=NotificationsPage-DKYvsusD.js.map