(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,17053,e=>{"use strict";var t=e.i(86909);function a(){return"https://api.banglayon.com/api".replace(/\/+$/,"")}function i(){let e=a();if(!e)throw{status:0,message:"API Base URL সেট করা নেই। `nextjsadmin/.env.local` এ NEXT_PUBLIC_API_BASE_URL দিন (example দেখুন), তারপর dev server restart করুন।"};return e}function s(e){let a=(0,t.getAdminApiKey)(),i=new Headers(e?.headers);return a&&i.set("x-admin-key",a),{...e,headers:i}}async function n(e){return await e.json().catch(()=>null)}async function r(e){let t=await n(e),a=(()=>{if(t&&"object"==typeof t&&"message"in t){let e=t.message;if(null!=e)return String(e)}return`Request failed (${e.status})`})();return{status:e.status,message:a}}async function c(e,t){let a=new URL(`${i()}${e}`);t&&Object.entries(t).forEach(([e,t])=>a.searchParams.set(e,t));let c=await fetch(a.toString(),s({method:"GET"}));if(!c.ok)throw await r(c);let d=await n(c);return d?.data??d}async function d(e,t){let a=await fetch(`${i()}${e}`,s({method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(t)}));if(!a.ok)throw await r(a);let c=await n(a);return c?.data??c}async function l(e,t){let a=await fetch(`${i()}${e}`,s({method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}));if(!a.ok)throw await r(a);let c=await n(a);return c?.data??c}async function o(e){let t=await fetch(`${i()}${e}`,s({method:"DELETE"}));if(!t.ok)throw await r(t);return!0}async function m(e){let t=`${i()}/admin/books`,a=new Headers;a.set("x-admin-key",e.trim());let s=await fetch(t,{method:"GET",headers:a});if(401===s.status)throw{status:401,message:"ভুল Admin API Key। সঠিক key দিন।"};if(!s.ok)throw await r(s)}async function f(e,t,a){let c=new FormData;for(let[e,t]of Object.entries(a))c.set(e,t);c.set("file",t,t.name);let d=await fetch(`${i()}${e}`,s({method:"POST",body:c}));if(!d.ok)throw await r(d);let l=await n(d);return l?.data??l}async function u(e,t,a=!1){let c=new FormData;c.set("file",t,t.name);let d=await fetch(`${i()}/admin/contents/${e}/file${a?"?keepName=true":""}`,s({method:"PUT",body:c}));if(!d.ok)throw await r(d);let l=await n(d);return l?.data??l}e.s(["apiDelete",0,o,"apiGet",0,c,"apiPost",0,l,"apiPut",0,d,"apiReplacePdf",0,u,"apiUploadPdf",0,f,"getApiBaseUrl",0,a,"validateAdminKey",0,m])},65861,e=>{"use strict";var t=e.i(43476),a=e.i(22016),i=e.i(71645),s=e.i(17053);e.s(["default",0,function(){let[e,n]=(0,i.useState)([]),[r,c]=(0,i.useState)(!0),[d,l]=(0,i.useState)(null);async function o(){c(!0),l(null);try{let e=await (0,s.apiGet)("/admin/directors");n(e??[])}catch(e){l(e?.message??String(e))}finally{c(!1)}}return(0,i.useEffect)(()=>{o()},[]),(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-4",children:[(0,t.jsx)("div",{className:"flex-1",children:(0,t.jsx)("div",{className:"text-xl font-semibold",children:"Directors"})}),(0,t.jsx)("button",{onClick:()=>void o(),className:"px-3 py-2 rounded-lg border border-zinc-800 hover:border-zinc-700 text-sm",children:"Refresh"})]}),(0,t.jsx)("div",{className:"flex gap-2",children:(0,t.jsx)(a.default,{href:"/admin/directors/new",className:"px-4 py-2 rounded-xl bg-[#D4AF37] text-zinc-950 font-semibold text-sm",children:"Add Director"})}),r?(0,t.jsx)("div",{className:"py-10 text-center text-zinc-300 text-sm",children:"Loading…"}):0===e.length?(0,t.jsx)("div",{className:"py-10 text-center text-zinc-300 text-sm",children:"No directors"}):(0,t.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,t.jsxs)("div",{className:"rounded-2xl border border-zinc-800 bg-black/40 p-4 flex items-start gap-4",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"font-semibold truncate",children:String(e.name??"")}),(0,t.jsxs)("div",{className:"text-sm text-zinc-400 truncate",children:[String(e.phone??""),e.thana?` • ${e.thana}`:"",e.district?` • ${e.district}`:""]})]}),(0,t.jsx)(a.default,{href:`/admin/directors/${e._id}`,className:"px-3 py-2 rounded-lg border border-zinc-800 hover:border-zinc-700 text-sm",children:"Edit"}),(0,t.jsx)("button",{className:"px-3 py-2 rounded-lg border border-red-900/60 text-red-200 hover:border-red-800 text-sm",onClick:async()=>{if(confirm("Delete director?"))try{await (0,s.apiDelete)(`/admin/directors/${e._id}`),await o()}catch(e){l(e?.message??String(e))}},children:"Delete"})]},String(e._id)))}),d?(0,t.jsx)("div",{className:"text-sm text-red-300",children:d}):null]})}])}]);