1import{j as a,R as f,as as m,ac as g,a7 as d,T as c,ab as x,ao as h,Q as y}from"./mui-CRsYZxVY.js";import{r as b}from"./vendor-Dwao9eNC.js";import{u as w,a as j,b as v}from"./query-8ViTdhdk.js";import{u,w as p,b as T,b8 as k,eR as E,ev as _,cF as I,T as N,f1 as R,K as l}from"./index-TALscxEc.js";import"./datePickers-BIJXYOKG.js";import"./icons-D8aatgQ4.js";import"./lab-DSem1Osk.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="b13568b4-9053-405f-9873-966ad0c980c2",e._sentryDebugIdIdentifier="sentry-dbid-b13568b4-9053-405f-9873-966ad0c980c2")})()}catch{}const S=()=>{const{user:e}=u(),s=e==null?void 0:e.id;return w({queryKey:["notifications"],queryFn:async()=>{if(!s)throw new Error("Usuário não autenticado");const{data:o,error:t}=await p.from("notificacao").select("*").limit(200).eq("user_id",s).order("criado_em",{ascending:!1});if(t)throw new Error(t.message);const i=[],r=new Set;return o.forEach(n=>{n.grupo_id?r.has(n.grupo_id)||(i.push(n),r.add(n.grupo_id)):i.push(n)}),i},enabled:!!s})},q=({titulo:e,corpo:s,lido:o,criado_em:t,path:i})=>{const r=T(),n=()=>{i&&r(i)};return a.jsx(f,{disablePadding:!0,children:a.jsx(m,{onClick:n,sx:{padding:2},children:a.jsx(g,{primaryTypographyProps:{component:"div"},primary:a.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[!o&&a.jsx(d,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:"primary.main",flexShrink:0}}),a.jsx(c,{component:"span",noWrap:!0,sx:{...k,flex:1,minWidth:0},children:e}),a.jsx(c,{component:"span",sx:E,children:_(I(t))})]}),secondary:a.jsx(c,{component:"div",variant:"body2",marginTop:.25,color:"text.secondary",sx:{pl:o?0:2},children:s})})})})},C=()=>{const e=j(),{user:s}=u(),o=s==null?void 0:s.id;return v({mutationFn:async()=>{if(!o)throw new Error("User must be logged in to mark notifications as read.");const{error:t}=await p.from("notificacao").update({lido:!0}).eq("user_id",o).eq("lido",!1);if(t)throw t;return!0},onSuccess:()=>{e.invalidateQueries({queryKey:["notifications"]}),e.invalidateQueries({queryKey:["unreadNotificationCount"]})}})},F=()=>{const{data:e,isLoading:s,isError:o}=S(),{mutate:t}=C(),i=!!(e&&(e==null?void 0:e.length)>0);return b.useEffect(()=>()=>{i&&t()},[i,t]),a.jsxs(d,{sx:{width:"100%",display:"flex",flexDirection:"column",flexGrow:1,overflow:"hidden"},children:[a.jsx(N,{title:"Notificações",navigateBack:!0}),a.jsxs(d,{sx:{position:"relative",padding:"16px",overflow:"auto"},children:[a.jsx(R,{title:"Notificações desativadas",subtitle:"Ative para receber alertas de pedidos e mensagens",trackingLocation:"notifications_page",sx:{mb:2}}),s?a.jsx(x,{spacing:1,sx:{backgroundColor:"background.paper",marginBottom:12},children:Array.from({length:10}).map((r,n)=>a.jsx(h,{variant:"rectangular",sx:{borderRadius:1},width:"100%",height:"96px"},n))}):o?a.jsx(l,{primaryText:"Erro ao carregar notificações"}):e&&e.length===0?a.jsx(l,{primaryText:"Nenhuma notificação"}):e&&a.jsx(y,{sx:{backgroundColor:"background.paper"},children:e.map(r=>a.jsx(q,{id:r.id,titulo:r.titulo,corpo:r.corpo,lido:r.lido,criado_em:r.criado_em,path:r.path},r.id))})]})]})};export{F 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.