import{j as t,H as n,L as p,a as s}from"./app-BQEFzdw6.js";import{A as g}from"./AppLayout-kozc03ce.js";import{P as h}from"./PageHeader-Bj1OQnqr.js";import{F as i}from"./CheckIcon-Bouy3_zC.js";import{F as u}from"./TrashIcon-D0d0jw01.js";import"./useThemeColor-qPCpc713.js";const o={lead_assigned:"🎯",task_assigned:"📋",invoice_paid:"💰",quotation_approved:"✅",follow_up:"🔔",leave_request:"🏖️",general:"📢",status_change:"🔄",created:"✨",deleted:"🗑️"};function y(r){const a=Math.floor((Date.now()-new Date(r))/1e3);return a<60?"just now":a<3600?`${Math.floor(a/60)} min ago`:a<86400?`${Math.floor(a/3600)} hours ago`:a<604800?`${Math.floor(a/86400)} days ago`:new Date(r).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}function w({notifications:r,unread_count:a}){const l=(r==null?void 0:r.data)??[];function d(e){s.patch(route("notifications.read",e),{},{preserveScroll:!0})}function m(e){s.delete(route("notifications.destroy",e),{preserveScroll:!0})}function c(){s.post(route("notifications.read-all"))}return t.jsxs(g,{children:[t.jsx(n,{title:"Notifications"}),t.jsx(h,{title:"Notifications",subtitle:`${a} unread`,children:a>0&&t.jsxs("button",{onClick:c,className:"btn btn-secondary text-sm flex items-center gap-2",children:[t.jsx(i,{className:"w-4 h-4"})," Mark all read"]})}),t.jsxs("div",{className:"p-4 sm:p-6 max-w-3xl",children:[t.jsxs("div",{className:"card overflow-hidden divide-y divide-gray-50",children:[l.length===0&&t.jsx("p",{className:"px-5 py-12 text-center text-gray-400",children:"No notifications yet."}),l.map(e=>t.jsxs("div",{className:`flex items-start gap-3 px-4 sm:px-5 py-4 group transition-colors ${e.read_at?"hover:bg-gray-50":"bg-primary-50/20"}`,children:[t.jsx("span",{className:"text-xl flex-shrink-0 mt-0.5",children:o[e.type]??o.general}),t.jsxs("div",{className:"flex-1 min-w-0",children:[e.link?t.jsx(p,{href:e.link,className:`text-sm hover:text-primary-600 ${e.read_at?"text-gray-700":"font-semibold text-gray-900"}`,children:e.title}):t.jsx("p",{className:`text-sm ${e.read_at?"text-gray-700":"font-semibold text-gray-900"}`,children:e.title}),e.message&&t.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:e.message}),t.jsx("p",{className:"text-[10px] text-gray-400 mt-1",children:y(e.created_at)})]}),t.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:[!e.read_at&&t.jsx("button",{onClick:()=>d(e.id),className:"p-1.5 rounded-lg hover:bg-gray-100 text-gray-400 hover:text-primary-600",title:"Mark read",children:t.jsx(i,{className:"w-4 h-4"})}),t.jsx("button",{onClick:()=>m(e.id),className:"p-1.5 rounded-lg hover:bg-red-50 text-gray-400 hover:text-red-500",title:"Delete",children:t.jsx(u,{className:"w-4 h-4"})})]}),!e.read_at&&t.jsx("div",{className:"w-2 h-2 rounded-full bg-primary-500 mt-2 flex-shrink-0"})]},e.id))]}),(r==null?void 0:r.links)&&t.jsx("div",{className:"mt-4 flex justify-center gap-1",children:r.links.map((e,x)=>t.jsx("button",{disabled:!e.url||e.active,onClick:()=>e.url&&s.get(e.url,{},{preserveState:!0}),className:`px-3 py-1.5 text-sm rounded border ${e.active?"bg-primary-600 text-white border-primary-600":"border-gray-200 text-gray-600 hover:bg-gray-50 disabled:opacity-40"}`,dangerouslySetInnerHTML:{__html:e.label}},x))})]})]})}export{w as default};
