PageSourceSearch

https://xterns.ai/assets/SuperAdminNotifications-BdNAY343.js

js xterns.ai collected 2026-10-05 13:23:40 UTC 7,564 bytes, 1 lines download raw bytes

1import{E as R,r as y,j as e,h as l,m as r,a9 as j,J as v,i as d,k as m,B as n,H as _,b as B,s as w}from"./index-DLd_kDlx.js";import{S as q}from"./switch-7Twrb7Os.js";import{S as C}from"./SuperAdminLayout-BsUvQU2j.js";import{u as P,N as U}from"./NotificationItem-Dc2WXW-y.js";import{u as W}from"./useNotificationPreferences-DhCaj2cc.js";import{A as H,a as L,b as $,c as G,d as Q,e as I,f as J,g as K,h as O}from"./alert-dialog-Ct5JsrY0.js";import{M as A}from"./message-square-CtxeCfRz.js";import{M as V}from"./mail-BVn2o8AP.js";import{S as X}from"./shield-T2sbDX4y.js";import{G as Y}from"./git-branch-C-twpC7K.js";import{T as Z}from"./trash-2-0uuZSTFd.js";import"./NotificationIcon-C1wwYnH5.js";import"./popover-BMD5FOmU.js";import"./scroll-area-BXTuUF24.js";import"./index-Deh-4PO1.js";import"./index-BdQq_4o_.js";import"./dropdown-menu-DSd1c3Vk.js";import"./index-lTaZyIGy.js";import"./chevron-right-CD1gvy-q.js";import"./crown-hzm_bRIt.js";import"./user-check-DxoAQXwU.js";import"./star-BH1OFEcs.js";import"./globe-C057RQ73.js";import"./timer-CZhDpZys.js";import"./briefcase-business-CphIeAJd.js";import"./key-round-B79BulHq.js";import"./search-DFH5eAlA.js";import"./formatDistanceToNow-57P64IbE.js";import"./en-US-9SRVm7yB.js";import"./differenceInCalendarMonths-BA0TPVs2.js";import"./endOfDay-DkR3ZXc8.js";import"./endOfMonth-CYn6pTOm.js";import"./trophy-DBX-jNOC.js";import"./triangle-alert-Chqk_WK7.js";const Re=()=>{const{notifications:a,unreadCount:x,loading:b,markAllAsRead:k,refetch:D}=P(),{preferences:h,loading:S,updateEmailPreference:T}=W(),{toast:u}=R(),[t,f]=y.useState(null),[p,g]=y.useState(!1),z=a.filter(s=>{const i=new Date().toDateString();return new Date(s.created_at).toDateString()===i}).length,M=a.filter(s=>{const i=new Date;return i.setDate(i.getDate()-7),new Date(s.created_at)>=i}).length,E=a.filter(s=>s.action_required&&!s.read_at).length,c=s=>a.filter(i=>i.type===s&&!i.read_at).length,N=t?a.filter(s=>s.type===t):a,o=s=>{f(t===s?null:s)},F=async()=>{var s;try{g(!0);const{error:i}=await w.from("notifications").delete().eq("user_id",(s=(await w.auth.getUser()).data.user)==null?void 0:s.id);if(i)throw i;u({title:"All notifications cleared",description:"All notifications have been permanently deleted."}),D()}catch(i){console.error("Error clearing all notifications:",i),u({title:"Error",description:"Failed to clear notifications. Please try again.",variant:"destructive"})}finally{g(!1)}};return b?e.jsx(C,{children:e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-center",children:"Loading notifications..."})})}):e.jsx(C,{children:e.jsxs("div",{className:"flex-1 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(l,{children:e.jsx(r,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Unread"}),e.jsx("p",{className:"text-2xl font-bold",children:x})]}),e.jsx(j,{className:"h-8 w-8 text-blue-500"})]})})}),e.jsx(l,{children:e.jsx(r,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Today"}),e.jsx("p",{className:"text-2xl font-bold",children:z})]}),e.jsx(v,{className:"bg-green-100 text-green-800",children:"New"})]})})}),e.jsx(l,{children:e.jsx(r,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This Week"}),e.jsx("p",{className:"text-2xl font-bold",children:M})]}),e.jsx(A,{className:"h-8 w-8 text-purple-500"})]})})}),e.jsx(l,{children:e.jsx(r,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Actions Required"}),e.jsx("p",{className:"text-2xl font-bold",children:E})]}),e.jsx(v,{className:"bg-red-100 text-red-800",children:"Urgent"})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("div",{className:"lg:col-span-2",children:e.jsxs(l,{children:[e.jsx(d,{children:e.jsxs(m,{className:"flex items-center gap-2 capitalize",children:[e.jsx(j,{className:"h-5 w-5"}),t?`${t} Notifications`:"Recent Notifications",t&&e.jsx(n,{variant:"ghost",size:"sm",onClick:()=>f(null),className:"ml-2",children:"Clear Filter"})]})}),e.jsx(r,{className:"space-y-4",children:N.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(j,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:t?`No ${t} notifications`:"No notifications yet"}),e.jsx("p",{className:"text-sm",children:t?"Try a different filter or clear the current filter.":"When you receive notifications, they'll appear here."})]}):N.map(s=>e.jsx(U,{notification:s,showMarkAsRead:!0},s.id))})]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(m,{className:"text-base",children:"Notification Settings"})}),e.jsxs(r,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:"Email notifications"})]}),e.jsx(q,{checked:(h==null?void 0:h.email_enabled)??!0,onCheckedChange:T,disabled:S})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"When disabled, you'll only receive in-app notifications."})]})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(m,{className:"text-base",children:"Qu
1ick Filters"})}),e.jsxs(r,{className:"space-y-3",children:[e.jsxs(n,{size:"sm",variant:t==="system"?"default":"outline",className:"w-full justify-start",onClick:()=>o("system"),children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"System (",c("system"),")"]}),e.jsxs(n,{size:"sm",variant:t==="project"?"default":"outline",className:"w-full justify-start",onClick:()=>o("project"),children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Project Updates (",c("project"),")"]}),e.jsxs(n,{size:"sm",variant:t==="meeting"?"default":"outline",className:"w-full justify-start",onClick:()=>o("meeting"),children:[e.jsx(_,{className:"h-4 w-4 mr-2"}),"Meetings (",c("meeting"),")"]}),e.jsxs(n,{size:"sm",variant:t==="message"?"default":"outline",className:"w-full justify-start",onClick:()=>o("message"),children:[e.jsx(A,{className:"h-4 w-4 mr-2"}),"Messages (",c("message"),")"]})]})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(m,{className:"text-base",children:"Quick Actions"})}),e.jsxs(r,{className:"space-y-2",children:[e.jsxs(n,{size:"sm",variant:"outline",className:"w-full",onClick:k,disabled:x===0,children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Mark All as Read (",x,")"]}
1),e.jsxs(H,{children:[e.jsx(L,{asChild:!0,children:e.jsxs(n,{size:"sm",variant:"outline",className:"w-full text-destructive hover:text-destructive",disabled:a.length===0||p,children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),p?"Clearing...":`Clear All (${a.length})`]})}),e.jsxs($,{children:[e.jsxs(G,{children:[e.jsx(Q,{children:"Clear All Notifications"}),e.jsxs(I,{children:["Are you sure you want to permanently delete all ",a.length," notifications? This action cannot be undone."]})]}),e.jsxs(J,{children:[e.jsx(K,{children:"Cancel"}),e.jsx(O,{onClick:F,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Clear All"})]})]})]})]})]})]})]})]})})};export{Re 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.