1import{E as L,r as v,j as e,aK as y,bK as b,bu as w,h as l,m as r,a9 as j,J as C,i as d,k as m,B as n,H as P,a as q,b as H,s as A}from"./index-DLd_kDlx.js";import{S as U}from"./switch-7Twrb7Os.js";import{T as k}from"./TechLeadHeader-eLOg3V3h.js";import{u as W,N as $}from"./NotificationItem-Dc2WXW-y.js";import{u as G}from"./useNotificationPreferences-DhCaj2cc.js";import{A as I,a as J,b as K,c as Q,d as O,e as V,f as X,g as Y,h as Z}from"./alert-dialog-Ct5JsrY0.js";import{M as D}from"./message-square-CtxeCfRz.js";import{M as ee}from"./mail-BVn2o8AP.js";import{G as se}from"./git-branch-C-twpC7K.js";import{A as te}from"./award-MEJfpupD.js";import{T as ae}from"./trash-2-0uuZSTFd.js";import"./dropdown-menu-DSd1c3Vk.js";import"./index-Deh-4PO1.js";import"./index-lTaZyIGy.js";import"./chevron-right-CD1gvy-q.js";import"./NotificationIcon-C1wwYnH5.js";import"./popover-BMD5FOmU.js";import"./scroll-area-BXTuUF24.js";import"./index-BdQq_4o_.js";import"./rotate-ccw-Bx1C64Ur.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 Ee=()=>{const{notifications:i,unreadCount:x,loading:T,markAllAsRead:S,refetch:z}=W(),{preferences:h,loading:E,updateEmailPreference:M}=G(),{toast:f}=L(),[t,u]=v.useState(null),[N,p]=v.useState(!1),B=i.filter(s=>{const a=new Date().toDateString();return new Date(s.created_at).toDateString()===a}).length,F=i.filter(s=>{const a=new Date;return a.setDate(a.getDate()-7),new Date(s.created_at)>=a}).length,_=i.filter(s=>s.action_required&&!s.read_at).length,c=s=>i.filter(a=>a.type===s&&!a.read_at).length,g=t?i.filter(s=>s.type===t):i,o=s=>{u(t===s?null:s)},R=async()=>{var s;try{p(!0);const{error:a}=await A.from("notifications").delete().eq("user_id",(s=(await A.auth.getUser()).data.user)==null?void 0:s.id);if(a)throw a;f({title:"All notifications cleared",description:"All notifications have been permanently deleted."}),z()}catch(a){console.error("Error clearing all notifications:",a),f({title:"Error",description:"Failed to clear notifications. Please try again.",variant:"destructive"})}finally{p(!1)}};return T?e.jsx(y,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-gray-50",children:[e.jsx(b,{}),e.jsxs(w,{className:"flex-1",children:[e.jsx(k,{title:"Notifications"}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"text-center",children:"Loading notifications..."})})]})]})}):e.jsx(y,{children:e.jsxs("div",{className:"min-h-screen flex w-full bg-gray-50",children:[e.jsx(b,{}),e.jsxs(w,{className:"flex-1",children:[e.jsx(k,{title:"Notifications"}),e.jsxs("div",{className:"flex-1 space-y-6 p-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-gray-600",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-gray-600",children:"Today"}),e.jsx("p",{className:"text-2xl font-bold",children:B})]}),e.jsx(C,{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-gray-600",children:"This Week"}),e.jsx("p",{className:"text-2xl font-bold",children:F})]}),e.jsx(D,{className:"h-8 w-8 text-xterns-navy"})]})})}),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-gray-600",children:"Actions"}),e.jsx("p",{className:"text-2xl font-bold",children:_})]}),e.jsx(C,{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:()=>u(null),className:"ml-2",children:"Clear Filter"})]})}),e.jsx(r,{className:"space-y-4",children:g.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."})]}):g.map(s=>e.jsx($,{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(ee,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:"Email notifications"})]}),e.jsx(U,{checked:(h==null?void 0:h.email_enabled)??!0,onCheckedChange:M,disabled:E})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"When disabled, you'll only receive in-app notifications. Email notifications will be turned off."})]})]}),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==="project"?"default":"outline",className:"w-full justify-start",onClick:()=>o("project"),children:[e.jsx(se,{className:"h-4 w-4 mr-2"}),"Project Updates (",c("project"),")"]}),e.jsxs(n,{size:"sm",variant:t==="achievement"?"default":"outline",className:"w-full justify-start",onClick:()=>o("achievement"),children:[e.jsx(te,{className:"h-4 w-4 mr-2"}),"Achievements (",c("achievement"),")"]}),e.jsxs(n,{size:"sm",variant:t==="meeting"?"default":"outline",className:"w-full justify-start",onClick:()=>o("meeting"),children:[e.jsx(P,{className:"h-4 w-4 mr-2"}),"Meetings (",c("meeting"),")"]}),e.jsxs(n,{size:"sm",variant:t==="job"?"default":"outline",className:"w-full justify-start",onClick:()=>o("job"),children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"Job Alerts (",c("job"),")"]}),e.jsxs(n,{size:"sm",variant:t==="message"?"default":"outline",className:"w-full justify-start",onClick:()=>o("message"),children:[e.jsx(D,{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:S,disabled:x===0,children:[e.jsx(H,{className:"h-4 w-4 mr-2"}),"Mark All as Read (",x,")"]}),e.jsxs(I,{children:[e.jsx(J,{asChild:!0,children:e.jsxs(n,{size:"sm",variant:"outline",className:"w-full text-destructive hover:text-destructive",disabled:i.length===0||N,children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),N?"Clearing...":`Clear All (${i.length})`]})}),e.jsxs(K,{children:[e.jsxs(Q,{children:[e.jsx(O,{children:"Clear All Notifications"}),e.jsxs(V,{children:["Are you sure you want to permanently delete all ",i.length," notifications? This action cannot be undone."]})]}),e.jsxs(X,{children:[e.jsx(Y,{children:"Cancel"}),e.jsx(Z,{onClick:R,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Clear All"})]})]})]})]})]})]})]})]})]})]})})};export{Ee 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.