1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[886],{20118:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d});var n=s(37876),a=s(14232),r=s(35793),l=s(14e3),i=s(14173),c=s(82392);let d=e=>{let{children:t}=e,s=(0,l.usePathname)(),d=(null==s?void 0:s.startsWith("/"))?s.slice(1):s,{hasPermission:o,permissions:m,isSuperAdmin:x,loading:u,adminData:h}=(0,i.A)(),[f,g]=(0,a.useState)(!1),[p,j]=(0,a.useState)(!0),y=(0,l.useRouter)();return((0,a.useEffect)(()=>{if(g(!0),u)return;if(!localStorage.getItem("admin_token"))return void y.replace("/admin");if((null==h?void 0:h.role)==="IPMASTER"||(null==h?void 0:h.email)==="[email protected]")return d.startsWith("admin/ip-management")?void j(!1):void y.push("/admin/ip-management");if(x)return void j(!1);if(!m||0===m.length)return void y.push("/admin/no-access");let e=[...r.W,...r.D].filter(e=>e.href).sort((e,t)=>t.href.length-e.href.length).find(e=>d.startsWith(e.href)),t=e?e.permission||e.name:null;if(e&&t&&o(t,"view"))return void j(!1);if(o("Dashboard","view"))return void y.push("/admin/dashboard");let s=[...r.W,...r.D].find(e=>e.name&&o(e.name,"view"));if(s)return void y.push(s.href);y.push("/admin/no-access")},[u,m,x,d,o,y]),!f||p)?null:(0,n.jsxs)("div",{className:"flex bg-gray-100",children:[(0,n.jsx)(c.default,{}),(0,n.jsx)("div",{className:"pt-16 px-10 overflow-x-auto w-full h-screen",children:(0,n.jsx)("main",{className:"flex-1 overflow-x-hidden overflow-y-auto bg-gray-100",children:t})})]})}},52331:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/announcement-list",function(){return s(93240)}])},54746:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>l});var n=s(37876),a=s(93784),r=s(28249);function l(e){let{isOpen:t,onClose:s,onConfirm:l,announcement:i}=e;return t&&i?(0,n.jsx)("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:(0,n.jsxs)("div",{className:"flex min-h-screen items-center justify-center p-4",children:[(0,n.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:s}),(0,n.jsxs)("div",{className:"relative bg-white rounded-xl shadow-xl max-w-md w-full mx-4 transform transition-all",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-gray-200",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)("div",{className:"flex-shrink-0 w-10 h-10 bg-red-100 rounded-full flex items-center justify-center",children:(0,n.jsx)(a.A,{className:"w-5 h-5 text-red-600"})}),(0,n.jsx)("h2",{className:"ml-3 text-xl font-semibold text-gray-900",children:"Delete Announcement"})]}),(0,n.jsx)("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 transition-colors duration-200",children:(0,n.jsx)(r.A,{className:"w-6 h-6"})})]}),(0,n.jsxs)("div",{className:"p-6",children:[(0,n.jsx)("p",{className:"text-gray-600 mb-4",children:"Are you sure you want to delete this announcement? This action cannot be undone."}),(0,n.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4 mb-6",children:[(0,n.jsx)("h3",{className:"font-medium text-gray-900 mb-2",children:i.title}),(0,n.jsx)("p",{className:"text-sm text-gray-600 break-all",children:i.link}),(0,n.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium mt-2 ".concat(i.status?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:i.status?"Active":"Inactive"})]}),(0,n.jsxs)("div",{className:"flex space-x-3",children:[(0,n.jsx)("button",{onClick:s,className:"flex-1 px-4 py-2 text-gray-700 bg-gray-100 hover:bg-gray-200 rounded-lg font-medium transition-colors duration-200",children:"Cancel"}),(0,n.jsx)("button",{onClick:l,className:"flex-1 px-4 py-2 bg-red-600 hover:bg-red-700 text-white font-medium rounded-lg transition-colors duration-200",children:"Delete"})]})]})]})]})}):null}},93240:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>f});var n=s(37876),a=s(14232),r=s(60148),l=s(54746),i=s(60383),c=s(45691),d=s(12602),o=s(93536),m=s(64041),x=s(79247);s(82392);var u=s(54196),h=s(20118);function f(){let[e,t]=(0,a.useState)([]),[s,f]=(0,a.useState)(!0),[g,p]=(0,a.useState)(!1),[j,y]=(0,a.useState)(!1),[N,b]=(0,a.useState)(null),[v,w]=(0,a.useState)(null),[k,A]=(0,a.useState)(""),[C,_]=(0,a.useState)(""),S=async()=>{try{f(!0);let e=await fetch("".concat(u.Qs,"announcement/all"),{method:"GET",credentials:"include"}),s=await e.json();s.status?t(s.data):A("Failed to fetch announcements")}catch(e){A("Error connecting to server"),console.error("Fetch error:",e)}finally{f(!1)}},E=async(e,t)=>{try{var s;let n=null==(s=localStorage.getItem("admin_token"))?void 0:s.replaceAll('"',""),a={"Content-Type":"application/json"};n&&(a.Authorization="Bearer ".concat(n));let r=await fetch("".concat(u.Qs,"announcement/toggle-status"),{method:"POST",headers:a,body:JSON.stringify({_id:e,status:!t}),credentials:"include"}),l=await r.json();l.status?(_("Announcement ".concat(t?"deactivated":"activated"," successfully")),S(),setTimeout(()=>_(""),3e3)):A(l.message||"Failed to update status")}catch(e){A("Error updating status"),console.error("Toggle error:",e)}},T=async e=>{try{var t;let s=null==(t=localStorage.getItem("admin_token"))?void 0:t.replaceAll('"',""),n={"Content-Type":"application/json"};s&&(n.Authorization="Bearer ".concat(s));let a=await fetch("".concat(u.Qs,"announcement/delete"),{method:"POST",headers:n,body:JSON.stringify({_id:e}),credentials:"include"}),r=await a.json();r.status?(_("Announcement deleted successfully"),S(),y(!1),w(null),setTimeout(()=>_(""),3e3)):A(r.message||"Failed to delete announcement")}catch(e){A("Error deleting announcement"),console.error("Delete error:",e)}},D=e=>{b(e),p(!0)},L=e=>{w(e),y(!0)},O=()=>{p(!1),b(null)},z=e=>new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return(0,a.useEffect)(()=>{S()},[]),(0,a.useEffect)(()=>{k&&setTimeout(()=>A(""),5e3)},[k]),(0,n.jsxs)(h.default,{children:[(0,n.jsx)("div",{className:"bg-white shadow-sm border-b",children:(0,n.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,n.jsxs)("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center py-6 gap-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-2xl md:text-3xl font-bold text-gray-900",children:"Announcements"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:"Manage your announcements and their visibility"})]}),(0,n.jsxs)("button",{onClick:()=>p(!0),className:"inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg shadow-sm transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",children:[(0,n.jsx)(i.A,{className:"w-5 h-5 mr-2"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Add New Announcement"}),(0,n.jsx)("span",{className:"sm:hidden",children:"Add New"})]})]})})}),C&&(0,n.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-4",children:(0,n.jsx)("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4",children:(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)("div",{className:"flex-shrink-0",children:(0,n.jsx)("svg",{className:"h-5 w-5 text-green-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})}),(0,n.jsx)("div",{className:"ml-3",children:(0,n.jsx)("p",{className:"text-sm font-medium text-green-800",children:C})})]})})}),k&&(0,n.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pt-4",children:(0,n.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)("div",{className:"flex-shrink-0",children:(0,n.jsx)("svg",{className:"h-5 w-5 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:(0,n.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),(0,n.jsx)("div",{className:"ml-3",children:(0,n.jsx)("p",{className:"text-sm font-medium text-red-800",children:k})})]})})}),(0,n.jsx)("div",{className:" mx-auto px-2 py-8",children:s?(0,n.jsx)("div",{className:"flex justify-center items-center py-12",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"})}):0===e.length?(0,n.jsxs)("div",{className:"text-center py-12",children:[(0,n.jsx)("div",{className:"mx-auto h-24 w-24 text-gray-400",children:(0,n.jsx)("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2M4 13h2m13-8V4a1 1 0 00-1-1H7a1 1 0 00-1 1v1m8 0V4.5"})})}),(0,n.jsx)("h3",{className:"mt-4 text-lg font-medium text-gray-900",children:"No announcements yet"}),(0,n.jsx)("p",{className:"mt-2 text-gray-500",children:"Get started by creating your first announcement."}),(0,n.jsxs)("button",{onClick:()=>p(!0),className:"mt-6 inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg shadow-sm transition-colors duration-200",children:[(0,n.jsx)(i.A,{className:"w-5 h-5 mr-2"}),"Add New Announcement"]})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"hidden md:block bg-white rounded-lg shadow-sm border border-gray-200 overflow-x-auto",children:(0,n.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,n.jsx)("thead",{className:"bg-gray-50",children:(0,n.jsxs)("tr",{children:[(0,n.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Status"}),(0,n.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Title"}),(0,n.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Link"}),(0,n.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Created"}),(0,n.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Updated"}),(0,n.jsx)("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),(0,n.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 overflow-x-scroll",children:e.map(e=>(0,n.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,n.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,n.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,n.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ".concat(e.status?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:e.status?"Active":"Inactive"}),(0,n.jsx)("button",{onClick:()=>E(e._id,e.status),className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(e.status?"bg-blue-600":"bg-gray-200"),children:(0,n.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white transition-transform ".concat(e.status?"translate-x-6":"translate-x-1")})})]})}),(0,n.jsx)("td",{className:"px-6 py-4",children:(0,n.jsx)("div",{className:"text-sm font-medium text-gray-900 max-w-xs truncate",children:e.title})}),(0,n.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,n.jsxs)("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-blue-600 hover:text-blue-800 text-sm font-medium transition-colors duration-200",children:[(0,n.jsx)(c.A,{className:"w-4 h-4 mr-1"}),"View"]}
1)}),(0,n.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:z(e.createdAt)}),(0,n.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.updatedAt!==e.createdAt?z(e.updatedAt):"-"}),(0,n.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm font-medium",children:(0,n.jsxs)("div",{className:"flex items-center justify-end space-x-2",children:[(0,n.jsxs)("button",{onClick:()=>D(e),className:"inline-flex items-center px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-medium rounded-md transition-colors duration-200",children:[(0,n.jsx)(d.A,{className:"w-4 h-4 mr-1"}),"Edit"]}),(0,n.jsxs)("button",{onClick:()=>L(e),className:"inline-flex items-center px-3 py-1.5 bg-red-100 hover:bg-red-200 text-red-700 text-sm font-medium rounded-md transition-colors duration-200",children:[(0,n.jsx)(o.A,{className:"w-4 h-4 mr-1"}),"Delete"]})]})})]},e._id))})]})}),(0,n.jsx)("div",{className:"md:hidden space-y-4",children:e.map(e=>(0,n.jsxs)("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,n.jsx)("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ".concat(e.status?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"),children:e.status?"Active":"Inactive"}),(0,n.jsx)("button",{onClick:()=>E(e._id,e.status),className:"relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ".concat(e.status?"bg-blue-600":"bg-gray-200"),children:(0,n.jsx)("span",{className:"inline-block h-4 w-4 transform rounded-full bg-white transition-transform ".concat(e.status?"translate-x-6":"translate-x-1")})})]}),(0,n.jsx)("h3",{className:"text-base font-semibold text-gray-900 mb-2 line-clamp-2",children:e.title}),(0,n.jsx)("div",{className:"mb-3",children:(0,n.jsxs)("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-blue-600 hover:text-blue-800 text-sm font-medium transition-colors duration-200",children:[(0,n.jsx)(c.A,{className:"w-4 h-4 mr-1"}),"View Link"]})}),(0,n.jsxs)("div",{className:"space-y-1 mb-4 text-xs text-gray-500",children:[(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(m.A,{className:"w-3 h-3 mr-2"}),(0,n.jsx)("span",{className:"font-medium",children:"Created:"}),(0,n.jsx)("span",{className:"ml-1",children:z(e.createdAt)})]}),e.updatedAt!==e.createdAt&&(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)(x.A,{className:"w-3 h-3 mr-2"}),(0,n.jsx)("span",{className:"font-medium",children:"Updated:"}),(0,n.jsx)("span",{className:"ml-1",children:z(e.updatedAt)})]})]}),(0,n.jsxs)("div",{className:"flex space-x-2",children:[(0,n.jsxs)("button",{onClick:()=>D(e),className:"flex-1 inline-flex items-center justify-center px-3 py-2 bg-gray-100 hover:bg-gray-200 text-gray-700 text-sm font-medium rounded-lg transition-colors duration-200",children:[(0,n.jsx)(d.A,{className:"w-4 h-4 mr-2"}),"Edit"]}),(0,n.jsxs)("button",{onClick:()=>L(e),className:"flex-1 inline-flex items-center justify-center px-3 py-2 bg-red-100 hover:bg-red-200 text-red-700 text-sm font-medium rounded-lg transition-colors duration-200",children:[(0,n.jsx)(o.A,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]},e._id))})]})}),(0,n.jsx)(r.default,{isOpen:g,onClose:O,onSuccess:()=>{S(),O(),_(N?"Announcement updated successfully":"Announcement created successfully"),setTimeout(()=>_(""),3e3)},announcement:N,onError:A}),(0,n.jsx)(l.default,{isOpen:j,onClose:()=>{y(!1),w(null)},onConfirm:()=>T(v._id),announcement:v})]})}}},e=>{e.O(0,[4e3,8230,4587,9742,2392,148,636,6593,8792],()=>e(e.s=52331)),_N_E=e.O()}]);
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.