"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[39255],{39255:(e,t,s)=>{s.r(t),s.d(t,{default:()=>p});var l=s(95155),a=s(12115),n=s(30571),i=s(30313),c=s(75560),r=s(2581);let d={GENERAL:"Notice",EVENT:"Event",HOLIDAY:"Holiday"},o={GENERAL:"bg-slate-100 text-slate-700",EVENT:"bg-sky-50 text-sky-800",HOLIDAY:"bg-violet-50 text-violet-800"};function p(){let[e,t]=(0,a.useState)([]),[s,p]=(0,a.useState)(!0),[x,m]=(0,a.useState)(null);return(0,a.useEffect)(()=>{let e=!1;return(0,c.BZ)().then(s=>{e||t(s)}).catch(t=>{e||(0,r.Qg)(t instanceof Error?t.message:"Failed to load notices")}).finally(()=>{e||p(!1)}),()=>{e=!0}},[]),(0,l.jsx)(n.o,{title:"Notices",description:"School announcements, events, and holidays for you.",children:s?(0,l.jsx)("div",{className:"space-y-3 animate-pulse",children:Array.from({length:3}).map((e,t)=>(0,l.jsx)("div",{className:"h-24 rounded-lg bg-slate-100"},t))}):0===e.length?(0,l.jsx)(i.i0,{title:"No notices yet",description:"When your school publishes announcements for you, they will show up here."}):(0,l.jsx)("ul",{className:"space-y-3",children:e.map(e=>{let t=x===e.id;return(0,l.jsx)("li",{children:(0,l.jsxs)("div",{className:"overflow-hidden rounded-lg border border-slate-100 bg-white shadow-sm",children:[(0,l.jsxs)("button",{type:"button",className:"w-full p-4 text-left touch-manipulation sm:p-5",onClick:()=>m(t?null:e.id),children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"mb-1.5 flex flex-wrap items-center gap-2",children:[(0,l.jsx)("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${o[e.noticeType]||o.GENERAL}`,children:d[e.noticeType]||"Notice"}),e.isPinned?(0,l.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-amber-700",children:"Pinned"}):null]}),(0,l.jsx)("p",{className:"font-semibold text-slate-900",children:e.title}),(0,l.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:[e.eventDate?`${e.eventDate} \xb7 `:"",e.publishAt?new Date(e.publishAt).toLocaleDateString():""]})]}),(0,l.jsx)("span",{className:"shrink-0 text-xs font-medium text-primary-700",children:t?"Hide":"Read"})]}),t?null:(0,l.jsx)("p",{className:"mt-2 line-clamp-2 text-sm text-slate-500",children:e.body})]}),t?(0,l.jsx)("div",{className:"border-t border-slate-100 px-4 py-3 text-sm whitespace-pre-wrap text-slate-800 sm:px-5",children:e.body}):null]})},e.id)})})})}}}]);