1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[47371,45348],{27144:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/content-controller/[pageName]",function(){return r(41407)}])},47105:function(e,t,r){"use strict";var n=r(85893);t.Z=function(e){let{classname:t,color:r}=e;return(0,n.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",className:"fill-current ".concat(t||""),children:(0,n.jsx)("path",{d:"M3.71542 2.42974L7.06075 5.77507L10.3888 2.44707C10.4623 2.36883 10.5508 2.30624 10.6491 2.26305C10.7474 2.21986 10.8534 2.19697 10.9608 2.19574C11.1906 2.19574 11.411 2.28705 11.5736 2.44958C11.7361 2.61211 11.8274 2.83255 11.8274 3.06241C11.8294 3.16866 11.8097 3.27421 11.7695 3.37257C11.7292 3.47093 11.6693 3.56003 11.5934 3.63441L8.22209 6.96241L11.5934 10.3337C11.7363 10.4735 11.82 10.6627 11.8274 10.8624C11.8274 11.0923 11.7361 11.3127 11.5736 11.4752C11.411 11.6378 11.1906 11.7291 10.9608 11.7291C10.8503 11.7337 10.7401 11.7152 10.6372 11.6749C10.5342 11.6347 10.4408 11.5734 10.3628 11.4951L7.06075 8.14974L3.72409 11.4864C3.65086 11.562 3.56338 11.6224 3.46669 11.6641C3.37 11.7057 3.26602 11.7278 3.16075 11.7291C2.9309 11.7291 2.71046 11.6378 2.54793 11.4752C2.3854 11.3127 2.29409 11.0923 2.29409 10.8624C2.29207 10.7562 2.31178 10.6506 2.35202 10.5522C2.39226 10.4539 2.45217 10.3648 2.52809 10.2904L5.89942 6.96241L2.52809 3.59107C2.38525 3.45133 2.30149 3.2621 2.29409 3.06241C2.29409 2.83255 2.3854 2.61211 2.54793 2.44958C2.71046 2.28705 2.9309 2.19574 3.16075 2.19574C3.36875 2.19834 3.56809 2.28241 3.71542 2.42974Z",fill:r||"#9B9B9B"})})}},80599:function(e,t,r){"use strict";var n=r(85893),a=r(47105),o=r(67294);t.Z=e=>{let{isOpen:t,onClose:r,children:s,width:i="max-w-md",rounded:l="rounded-lg",marginPadding:c,bg:d}=e,u=(0,o.useRef)(null);return((0,o.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return t&&(document.body.classList.add("overflow-hidden"),window.addEventListener("keydown",e)),()=>{document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",e)}},[t,r]),t)?(0,n.jsx)("div",{className:"fixed inset-0 z-[1001] flex items-center justify-center bg-black/40 p-4 backdrop-blur-sm",onClick:e=>{u.current&&!u.current.contains(e.target)&&r()},children:(0,n.jsxs)("div",{ref:u,className:" ".concat(null!=d?d:"bg-white"," relative transform shadow-xl transition-all duration-300 ease-out ").concat(i," ").concat(l," max-h-[90vh] w-full overflow-hidden"),children:[(0,n.jsx)("button",{className:"absolute right-4 top-4 z-10 hover:text-black",onClick:r,children:(0,n.jsx)(a.Z,{classname:"h-6 w-6 transition-transform duration-200 hover:scale-110 text-black",color:"black"})}),(0,n.jsx)("div",{className:"max-h-[80vh] overflow-y-auto p-4 md:mt-16 md:p-8",children:s})]})}):null}},7486:function(e,t,r){"use strict";var n=r(55678);r(37677),t.Z=()=>({showToast:(e,t)=>{"error"===e?n.Am.error(t,{theme:"dark"}):"success"===e?n.Am.success(t,{theme:"dark"}):(0,n.Am)(t,{theme:"dark"})}})},56818:function(e,t,r){"use strict";r.d(t,{Z:function(){return p}});var n=r(85893),a=r(41664),o=r.n(a),s=r(11163),i=r(67294),l=r(74442),c=r(37864),d=e=>{let{question:t,onConfirm:r,onCancel:a}=e;return(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",children:(0,n.jsxs)("div",{className:"w-full max-w-md rounded-lg bg-white p-6 shadow-lg",children:[(0,n.jsx)("p",{className:"mb-6 text-lg font-semibold text-gray-800",children:t}),(0,n.jsxs)("div",{className:"flex justify-end space-x-4",children:[(0,n.jsx)("button",{onClick:a,className:"rounded-lg bg-gray-500 px-4 py-2 text-white transition duration-300 hover:bg-gray-600",children:"No"}),(0,n.jsx)("button",{onClick:r,className:"rounded-lg bg-red-500 px-4 py-2 text-white transition duration-300 hover:bg-red-600",children:"Yes"})]})]})})},u=r(7486),m=function(){let e=(0,s.useRouter)(),[t,r]=(0,i.useState)([]),[a,m]=(0,i.useState)(!1),[h,p]=(0,i.useState)(""),[x,g]=(0,i.useState)(null),[f,y]=(0,i.useState)(""),[b,v]=(0,i.useState)(null),[w,N]=(0,i.useState)(!1),{showToast:j}=(0,u.Z)(),k=e=>t.includes(e),C=async()=>{try{let e=await fetch("/api/admin/content-controller/page/get-page",{method:"GET"});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let t=await e.json();r(t.pages)}catch(e){j("error","Error while getting page"),console.error("Error fetching pages:",e)}},S=async t=>{try{if(k(t)){j("error","page already exists with same name");return}let n=await fetch("/api/admin/content-controller/page/create-page",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageName:t})});if(!n.ok)throw Error("HTTP error! status: ".concat(n.status));r(e=>[...e,t]),e.push("/admin/content-controller/".concat(t)),j("success","".concat(t," page added"))}catch(e){console.error("Error adding page:",e),j("error","Error while adding a new page")}},E=async t=>{try{let n=await fetch("/api/admin/content-controller/page/delete-page/".concat(t),{method:"DELETE"});if(!n.ok)throw Error("HTTP error! status: ".concat(n.status));r(e=>e.filter(e=>e!==t)),v(null),e.query.pageName===t&&e.push("/admin/content-controller"),j("success","".concat(t," page deleted"))}catch(e){console.error("Error deleting page:",e),j("error","Error while deleting")}},T=async(t,n)=>{if(n!==t)try{if(k(n)){j("error","page already exists with same name");return}let a=await fetch("/api/admin/content-controller/page/update-page",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPageName:t,newPageName:n})});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));r(e=>e.map(e=>e===t?n:e)),g(null),y(""),e.push("/admin/content-controller/".concat(n)),j("success","".concat(t," is now changed to ").concat(n))}catch(e){console.error("Error updating page:",e),j("error","Error while renaming")}},O=e=>{"Enter"===e.key&&(null!==x?T(t[x],f):(S(h),p(""),m(!1)))},Z=e=>{v(e),N(!0)};return(0,i.useEffect)(()=>{C()},[]),(0,n.jsxs)("div",{className:"flex w-[340px] flex-col border-r-2 px-2",children:[(0,n.jsx)("div",{className:"mb-2 border-b-2 px-2 pb-8",children:a?(0,n.jsx)("input",{type:"text",value:h,onChange:e=>p(e.target.value),onKeyPress:O,placeholder:"Page Name",className:"h-[38px] w-full px-4 py-2 transition-all duration-300 ease-in-out placeholder:px-4",onBlur:()=>m(!1),autoFocus:!0}):(0,n.jsx)("button",{onClick:()=>{m(!0)},className:"inline-flex items-center rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",children:"+ Add Page"})}),(0,n.jsx)("div",{className:"h-[80vh] overflow-y-auto",children:null==t?void 0:t.map((t,r)=>{let a=e.query.pageName===t;return(0,n.jsxs)("div",{className:"flex cursor-pointer items-center justify-between px-[14px] py-[12px] ".concat(a?"bg-gray-200":""," group rounded-[8px] px-2"),children:[x===r?(0,n.jsx)("input",{type:"text",value:f,onChange:e=>y(e.target.value),onKeyPress:O,className:"z-20 h-[44px] w-full flex-grow rounded border-0 bg-transparent px-2 transition-all duration-300 focus-visible:border-none",onBlur:()=>g(null),autoFocus:!0}):(0,n.jsx)(o(),{href:"/admin/content-controller/".concat(t),children:(0,n.jsx)("div",{className:"flex-grow",children:t})}),(0,n.jsxs)("div",{className:"z-10 flex items-end justify-end rounded-[8px] px-2 py-2 ".concat(x===r?"opacity-0":"group-hover:opacity-100"),children:[(0,n.jsx)(l.Z,{onClick:()=>{g(r),y(t)},className:"h-5 w-5 cursor-pointer hover:text-blue-600 ".concat(x===r?"hidden":"opacity-0 group-hover:opacity-100")}),(0,n.jsx)(c.Z,{onClick:()=>Z(t),className:"ml-2 h-5 w-5 cursor-pointer hover:text-red-600 ".concat(x===r?"hidden":"opacity-0 group-hover:opacity-100")})]})]},r)})}),w&&b&&(0,n.jsx)(d,{question:'Are you sure you want to delete the page "'.concat(b,'"? This action cannot be undone.'),onConfirm:()=>{b&&(E(b),N(!1))},onCancel:()=>{v(null),N(!1)}})]})},h=r(33299),p=function(e){let{children:t}=e,{data:r}=(0,h.useSession)();return(0,n.jsx)("div",{className:"mx-auto mt-20 max-w-[1160px]",children:r&&(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(m,{}),(0,n.jsx)("div",{className:"w-full overflow-y-auto",children:t})]})})})}},31134:function(e,t,r){"use strict";r.d(t,{Z:function(){return d}});var n=r(67294);let a=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),o=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,r)=>r?r.toUpperCase():t.toLowerCase()),s=e=>
1{let t=o(e);return t.charAt(0).toUpperCase()+t.slice(1)},i=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.filter((e,t,r)=>!!e&&""!==e.trim()&&r.indexOf(e)===t).join(" ").trim()};var l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,n.forwardRef)((e,t)=>{let{color:r="currentColor",size:a=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:c="",children:d,iconNode:u,...m}=e;return(0,n.createElement)("svg",{ref:t,...l,width:a,height:a,stroke:r,strokeWidth:s?24*Number(o)/Number(a):o,className:i("lucide",c),...m},[...u.map(e=>{let[t,r]=e;return(0,n.createElement)(t,r)}),...Array.isArray(d)?d:[d]])}),d=(e,t)=>{let r=(0,n.forwardRef)((r,o)=>{let{className:l,...d}=r;return(0,n.createElement)(c,{ref:o,iconNode:t,className:i("lucide-".concat(a(s(e))),"lucide-".concat(e),l),...d})});return r.displayName=s(e),r}},43832:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(31134).Z)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]])},15928:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(31134).Z)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},78497:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(31134).Z)("menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]])},31855:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(31134).Z)("pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]])},74442:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(31134).Z)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]])},37864:function(e,t,r){"use strict";r.d(t,{Z:function(){return n}});let n=(0,r(31134).Z)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},41407:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return w}});var n=r(85893),a=r(67294),o=r(31855),s=r(37864),i=r(15928),l=r(43832),c=e=>{let{item:t,index:r,handleDragStart:a,handleDragEnter:c,handleDragEnd:d,deleteContent:u,toggleVisibility:m,contentIndex:h,addContent:p}=e,x=Object.keys(t).find(e=>/\.(jpg|jpeg|png|gif)$/i.test(t[e])||/^https?:\/\/.*(firebase|googleapis)/i.test(t[e])),g=Object.keys(t).find(e=>"string"==typeof t[e]&&!/\.(jpg|jpeg|png|gif)$/i.test(t[e])&&!/^https?:\/\//i.test(t[e])&&"_id"!==e),f=t.order;return(0,n.jsxs)("div",{draggable:!0,onDragStart:()=>a(h),onDragEnter:()=>c(h),onDragEnd:d,className:"group relative m-4 min-w-[200px] max-w-xs transform cursor-grab rounded-lg border border-gray-300 bg-white p-4 pt-9 shadow-lg transition-transform hover:scale-105 ".concat(x?"bg-cover bg-center":""),children:[(0,n.jsxs)("div",{className:"absolute right-2 top-2 z-10 flex space-x-2",children:[(0,n.jsx)(o.Z,{className:"h-5 w-5 cursor-pointer text-gray-700 transition hover:text-gray-900",onClick:()=>p(t)}),(0,n.jsx)(s.Z,{onClick:()=>u(r,h),className:"h-5 w-5 cursor-pointer text-red-600 transition hover:text-red-800"}),t.visibility?(0,n.jsx)(i.Z,{className:"h-5 w-5 cursor-pointer text-gray-700 transition hover:text-gray-900",onClick:()=>m(r,h)}):(0,n.jsx)(l.Z,{className:"h-5 w-5 cursor-pointer text-gray-700 transition hover:text-gray-900",onClick:()=>m(r,h)})]}),(0,n.jsxs)("div",{className:"relative p-2 ".concat(!t.visibility&&"opacity-30"),children:[(0,n.jsx)("div",{className:"absolute inset-0 rounded-lg bg-black opacity-65 ".concat(x?"":"bg-blue-200")}),(0,n.jsxs)("div",{className:"relative z-10 p-2 text-white",children:[(0,n.jsx)("h4",{className:"text-lg font-semibold",children:t[g]||"No Text"}),(0,n.jsxs)("p",{className:"text-sm",children:["Order: ",f]})]})]})]})},d=e=>{let{items:t,setItems:r,index:o,deleteContent:s,toggleVisibility:i,addContent:l}=e,[d,u]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),p=(0,a.useRef)(null),x=e=>{u(e)},g=e=>{if(h(e),p.current){let r=p.current.clientWidth,n=p.current.scrollLeft;0===e&&n>50&&null===m?p.current.scrollTo({left:n-50,behavior:"smooth"}):e===t.length-1&&n<p.current.scrollWidth-r-50&&null===m&&p.current.scrollTo({left:n+50,behavior:"smooth"})}},f=()=>{if(null!==m&&m!==d){let e=[...t],n=e[d];e.splice(d,1),e.splice(m,0,n),e.forEach((e,t)=>{e.order=t+1}),r(e,o)}u(null),h(null)};return(0,n.jsx)("div",{className:"drag-and-drop overflow-x-auto rounded-[4px] border-2 p-2",children:(0,n.jsx)("div",{ref:p,className:"flex flex-nowrap",style:{scrollBehavior:"smooth"},children:t.map((e,t)=>(0,n.jsx)(c,{item:e,index:o,contentIndex:t,handleDragStart:x,handleDragEnter:g,handleDragEnd:f,deleteContent:s,toggleVisibility:i,addContent:l},t))})})},u=function(e){let{fields:t,onSubmit:r,onClose:o,mode:s,initialData:i,sectionName:l}=e,[c,d]=(0,a.useState)({}),[u,m]=(0,a.useState)([]),[h,p]=(0,a.useState)(!1),[x,g]=(0,a.useState)({});(0,a.useEffect)(()=>
1{if("edit"===s&&i){d(i);let e={};t.forEach(t=>{"image"===t.image&&i[t.name]&&(e[t.name]=i[t.name])}),g(e)}},[s,i,t]);let f=(e,t)=>{d({...c,[t]:e.target.value})},y=async(e,t)=>{p(!0),m(await b(l,t)),p(!1),0===t.length&&m([])},b=async(e,t)=>{try{let r=await fetch("/api/admin/content-controller/content/get-image?sectionName=".concat(encodeURIComponent(e),"&query=").concat(encodeURIComponent(t)));if(!r.ok)throw Error("Error fetching images");return(await r.json()).map(e=>e.url)}catch(e){return console.error("Error searching images:",e),[]}},v=async e=>{let t=new FormData;t.append("file",e),t.append("sectionName",l);let r=await fetch("/api/admin/content-controller/content/upload-image",{method:"POST",body:t});if(!r.ok)throw Error("Error uploading file");return(await r.json()).imageURL},w=(e,t)=>{d({...c,[e]:t}),g({...x,[e]:t}),m([])},N=async(e,t)=>{let r=await v(t),n=URL.createObjectURL(t);d({...c,[e]:r}),g({...x,[e]:n})},j=t.every(e=>c[e.name]&&""!==c[e.name]);return(0,n.jsx)("div",{className:"fixed inset-0 z-[1001] flex items-center justify-center bg-black bg-opacity-50",children:(0,n.jsxs)("div",{className:"w-full max-w-md
1scale-95 transform space-y-6 rounded-lg bg-white p-8 shadow-lg transition-transform hover:scale-100",children:[(0,n.jsx)("h2",{className:"mb-4 text-center text-2xl font-bold",children:"edit"===s?"Edit Data":"Add New Data"}),(0,n.jsxs)("form",{onSubmit:e=>{e.preventDefault(),r(c)},className:"space-y-6",children:[(0,n.jsx)("div",{className:"max-h-[60vh] space-y-6 overflow-auto",children:t.map(e=>(0,n.jsxs)("div",{className:"",children:[(0,n.jsx)("label",{className:"block font-semibold text-gray-700",children:e.name}),"text"===e.image?(0,n.jsx)("textarea",{value:c[e.name]||"",onChange:t=>f(t,e.name),className:"mt-1 block h-[80px] w-full rounded-md border-2 border-gray-300 px-2 shadow-sm focus:border-blue-500 focus:ring-blue-500"}):(0,n.jsxs)("div",{className:"mt-1",children:[(0,n.jsx)("input",{type:"text",placeholder:"Search for an image",onChange:t=>y(e.name,t.target.value),className:"block h-[36px] w-full rounded-md border-2 border-gray-300 px-2 shadow-sm placeholder:px-2 focus:border-blue-500 focus:ring-blue-500"}),h&&(0,n.jsx)("div",{className:"mt-2 text-gray-500",children:"Loading..."}),(0,n.jsx)("div",{className:"mt-2 flex max-h-[10vh] flex-wrap gap-2 overflow-y-scroll",children:u.map(t=>(0,n.jsx)("div",{children:(0,n.jsx)("img",{src:t,alt:e.name,className:"h-16 max-h-40 cursor-pointer rounded-md border border-gray-300 shadow-sm",onClick:()=>w(e.name,t)})},t))}),(0,n.jsx)("input",{type:"file",onChange:t=>t.target.files&&N(e.name,t.target.files[0]),className:"mt-2 block"}),x[e.name]&&(0,n.jsx)("img",{src:x[e.name],alt:e.name,className:"mt-2 max-h-16 rounded-md border border-gray-300 shadow-sm"})]})]},e.name))}),(0,n.jsxs)("div",{className:"flex justify-end space-x-4",children:[(0,n.jsx)("button",{type:"button",onClick:o,className:"rounded-md bg-gray-300 px-4 py-2 transition-colors hover:bg-gray-400",children:"Close"}),(0,n.jsx)("button",{type:"submit",disabled:!j,className:"rounded-md bg-blue-600 px-4 py-2 text-white transition-colors hover:bg-blue-700 disabled:opacity-50",children:"Submit"})]})]})]})})},m=r(11163),h=function(e){let{handleOrderChange:t,items:r,btnDisabled:i,index:l,addContent:c,updateContent:h,deleteContent:p,toggleVisibility:x,setEditingIndex:g,setIsFormEdit:f,deleteSection:y,handleSaveOrder:b}=e,[v,w]=(0,a.useState)(!1),[N,j]=(0,a.useState)("add"),[k,C]=(0,a.useState)(null),S=(0,m.useRouter)().query.pageName,E=async e=>{if("add"===N){let t={content:{...e,order:r.content.length+1,visibility:!1},sectionName:r.sectionName,pageName:S};await c(l,t)}else if("edit"===N){let t={content:{...e},sectionName:r.sectionName,pageName:S};await h(l,t)}T()},T=()=>{w(!1)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"group/contentWrapper w-full space-y-2 rounded-[8px] border-2 border-gray-400 p-10",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)("div",{children:r.sectionName}),(0,n.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,n.jsx)("button",{className:"hidden animate-fadeIn rounded-[4px] bg-accelerator-gradient px-[16px] py-[8px] text-white opacity-80 group-hover/contentWrapper:block hover:opacity-100 disabled:opacity-30",onClick:()=>{j("add"),w(!0)},children:"Add a ".concat(r.sectionName||"content")}),(0,n.jsx)(o.Z,{className:"cursor-pointer hover:text-blue-700",onClick:()=>{f(!0),g(l)}}),(0,n.jsx)(s.Z,{className:"cursor-pointer hover:text-red-700",onClick:()=>y(l)}),(0,n.jsx)("button",{disabled:i,className:"rounded-[4px] bg-accelerator-gradient px-[16px] py-[8px] text-white opacity-80 hover:opacity-100 disabled:opacity-30",onClick:()=>b(l),children:"Save Order"})]})]}),0===r.content.length?(0,n.jsx)("div",{children:"No Data "}):(0,n.jsx)(d,{index:l,items:r.content,setItems:e=>t(e,l),deleteContent:p,toggleVisibility:x,addContent:e=>{j("edit"),C(e),w(!0)}})]}),v&&(0,n.jsx)(u,{fields:Object.entries(r.fields).map(e=>{let[t,r]=e;return{name:t,image:r}}),onSubmit:E,onClose:T,mode:N,initialData:k,sectionName:r.sectionName})]})},p=e=>{let{sectionData:t,index:r,updateSection:o}=e,[i,l]=(0,a.useState)(t.sectionName),[c,d]=(0,a.useState)([]);(0,a.useEffect)(()=>{d(Object.entries(t.sectionFields).map(e=>{let[t,r]=e;return{variableName:t,dataType:r}}))},[t]);let u=async e=>{e.preventDefault(),await o(r,{sectionName:i,fields:c})},m=(e,t,r)=>{let n=[...c];n[e][t]=r,d(n)},h=e=>{d(c.filter((t,r)=>r!==e))};return(0,n.jsxs)("form",{onSubmit:u,className:"z-[1001] p-4",children:[(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("label",{htmlFor:"sectionName",className:"block text-sm font-medium text-gray-700",children:"Section Name"}),(0,n.jsx)("input",{type:"text",id:"sectionName",value:i,onChange:e=>l(e.target.value),className:"mt-1 block w-full rounded-md border border-gray-300 p-2",required:!0})]}),(0,n.jsx)("div",{className:"grid max-h-[60vh] grid-cols-1 gap-4 overflow-y-auto sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3",children:c.map((e,t)=>(0,n.jsxs)("div",{className:"relative mb-4 flex flex-col rounded-md border p-4",children:[(0,n.jsxs)("label",{className:"block text-sm font-medium text-gray-700",children:["Field ",t+1]}),(0,n.jsxs)("div",{className:"mt-2 flex space-x-2",children:[(0,n.jsx)("input",{type:"text",value:e.variableName,onChange:e=>m(t,"variableName",e.target.value),placeholder:"Variable Name",className:"max-w-[150px] flex-grow rounded-md border border-gray-300 p-2",required:!0}
1),(0,n.jsxs)("select",{value:e.dataType,onChange:e=>m(t,"dataType",e.target.value),className:"rounded-md border border-gray-300 p-2",children:[(0,n.jsx)("option",{value:"text",children:"Text"}),(0,n.jsx)("option",{value:"image",children:"Image"})]})]}),(0,n.jsx)("button",{type:"button",onClick:()=>h(t),className:"absolute right-0 top-0 mr-1 mt-1 p-2 text-red-600 hover:text-red-800",children:(0,n.jsx)(s.Z,{className:"h-4 w-4"})})]},t))}),(0,n.jsxs)("div",{className:"mt-4 flex justify-between",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{d([...c,{variableName:"",dataType:"text"}])},className:"inline-flex items-center rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",children:"+ Add Field"}),(0,n.jsx)("button",{type:"submit",className:"inline-flex items-center rounded-md border border-transparent bg-green-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2",children:"Submit"})]})]})},x=e=>{let{addSection:t}=e,[r,o]=(0,a.useState)(""),[i,l]=(0,a.useState)([{variableName:"",dataType:"text"}]),[c,d]=(0,a.useState)(!1),u=async e=>{e.preventDefault(),d(!0),await t({sectionName:r,fields:i}),d(!1)},m=(e,t,r)=>{let n=[...i];n[e][t]=r,l(n)},h=e=>{l(i.filter((t,r)=>r!==e))};return(0,n.jsxs)("form",{onSubmit:u,className:"h-full p-4",children:[(0,n.jsxs)("div",{className:"mb-4",children:[(0,n.jsx)("label",{htmlFor:"sectionName",className:"block text-sm font-medium text-gray-700",children:"Section Name"}),(0,n.jsx)("input",{type:"text",id:"sectionName",value:r,onChange:e=>o(e.target.value),className:"mt-1 block w-full rounded-md border border-gray-300 p-2",required:!0})]}),(0,n.jsx)("div",{className:"grid max-h-[60vh] grid-cols-1 gap-4 overflow-y-auto sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-3",children:i.map((e,t)=>(0,n.jsxs)("div",{className:"relative mb-4 flex flex-col rounded-md border p-4",children:[(0,n.jsxs)("label",{className:"block text-sm font-medium text-gray-700",children:["Field ",t+1]}),(0,n.jsxs)("div",{className:"mt-2 flex space-x-2",children:[(0,n.jsx)("input",{type:"text",value:e.variableName,onChange:e=>m(t,"variableName",e.target.value),placeholder:"Variable Name",className:"max-w-[150px] flex-grow rounded-md border border-gray-300 p-2",required:!0}),(0,n.jsxs)("select",{value:e.dataType,onChange:e=>m(t,"dataType",e.target.value),className:"rounded-md border border-gray-300 p-2",children:[(0,n.jsx)("option",{value:"text",children:"Text"}),(0,n.jsx)("option",{value:"image",children:"Image"})]})]}),(0,n.jsx)("button",{type:"button",onClick:()=>h(t),className:"absolute right-0 top-0 mr-1 mt-1 p-2 text-red-600 hover:text-red-800",children:(0,n.jsx)(s.Z,{className:"h-4 w-4"})})]},t))}),(0,n.jsxs)("div",{className:"mt-4 flex justify-between",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{l([...i,{variableName:"",dataType:"text"}])},className:"inline-flex items-center rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",children:"+ Add Field"}),(0,n.jsx)("button",{type:"submit",className:"inline-flex items-center rounded-md border border-transparent bg-green-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2",disabled:c,children:c?"Submitting...":"Submit"})]})]})},g=r(80599),f=r(7486),y=r(97629),b=r(56818);let v=()=>{let[e,t]=(0,a.useState)(!1),r=(0,m.useRouter)().query.pageName,o=()=>t(!1),[s,i]=(0,a.useState)([]),[l,c]=(0,a.useState)([]),[d,u]=(0,a.useState)(null),[y,v]=(0,a.useState)(!1),w=(0,m.useRouter)(),{showToast:N}=(0,f.Z)(),j=async()=>{var e;let t={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageName:(null===(e=w.query)||void 0===e?void 0:e.pageName)||""})};try{let e=await fetch("/api/admin/content-controller/get-all-content",t),r=await e.json();i(r.data||[]),c(r.data||[])}catch(e){console.error("Error submitting form:",e)}};(0,a.useEffect)(()=>{j()},[]);let k=(e,t)=>{i(r=>{let n=[...r];return n[t]={...n[t],content:e},n})},C=async e=>{let t={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageName:r,sectionName:s[e].sectionName,content:s[e].content.map(e=>{let{_id:t,order:r}=e;return{_id:t,order:r}})})};try{let r=await fetch("/api/admin/content-controller/content/save-content-order",t);if(r.ok)c(t=>{let r=[...t];return r[e].content=[...s[e].content],r}),N("success","Order Saved");else{let e=await r.json();console.error("Failed to save order:",e),N("error","Something went wrong while saving order")}}catch(e){N("error","Something went wrong while saving order"),console.error("Error saving order:",e)}},S=async(e,t)=>{try{let r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},n=await fetch("/api/admin/content-controller/content/add-content",r);if(!n.ok){let e=await n.json();throw Error("Error: ".concat(n.statusText,", ").concat(e.message))}let a=(await n.json())._id,o={...t.content,_id:a};i(t=>{let r=[...t],n=[...r[e].content,o];return r[e]={...r[e],content:n},r}),c(t=>{let r=[...t],n=[...r[e].content,o];return r[e]={...r[e],content:n},r}),N("success","Content added")}catch(e){console.error(e),N("error","Content did not added")}},E=async(e,t)=>{try{let r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},n=await fetch("/api/admin/content-controller/content/update-content",r);if(!n.ok){let e=await n.json();throw Error("Error: ".concat(n.statusText,", ").concat(e.message))}await n.json();let a=r=>{let n=[...r],a=n[e].content.map(e=>e._id===t.content._id?t.content:e);return n[e]={...n[e],content:a},n};i(e=>a(e)),c(e=>a(e)),N("success","Successfully updated")}catch(e){N("error","Cant update, something went wrong"),console.error(e)}},T=async(e,t)=>{try{let n={pageName:r,sectionName:s[e].sectionName,_id:s[e].content[t]._id},a={method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},o=await fetch("/api/admin/content-controller/content/delete-content",a);if(!o.ok){let e=await o.json();throw Error("Error: ".concat(o.statusText,", ").concat(e.message))}i(r=>{let n=[...r],a=[...n[e].content];a.splice(t,1);let o=a.map((e,t)=>({...e,order:t+1}));return n[e]={...n[e],content:o},n}),c(r=>{let n=[...r],a=[...n[e].content];a.splice(t,1);let o=a.map((e,t)=>({...e,order:t+1}));return n[e]={...n[e],content:o},n}),N("success","Deleted Successfully")}catch(e){N("error","Something went wrong while deleting"),console.error(e)}},O=async(e,t)=>{try{let n={...s[e].content[t],visibility:!s[e].content[t].visibility},a={pageName:r,sectionName:s[e].sectionName,content:n},o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)},l=await fetch("/api/admin/content-controller/content/update-content",o);if(!l.ok){let e=await l.json();throw Error("Error: ".concat(l.statusText,", ").concat(e.message))}i(r=>{let a=[...r];return a[e].content[t].visibility=n.visibility,a}),c(r=>{let a=[...r];return a[e].content[t].visibility=n.visibility,a}),N("success","Visibility Toggled Successfully")}catch(e){N("error","Cannot toggle , something went wrong"),console.error(e)}},Z=async e=>
1{let t=e.sectionName||"",n=e.fields||[],a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageName:r,sectionName:t,fields:n})},s={sectionName:t,fields:n.reduce((e,t)=>(e[t.variableName]=t.dataType,e),{}),content:[]};try{let e=await fetch("/api/admin/content-controller/section/create-section",a);if(!e.ok){let t=await e.json();console.error("Error from server:",t);return}i(e=>[...e,s]),c(e=>[...e,s]),N("success","Section Added")}catch(e){console.error("Error submitting form:",e),N("error","Something went wrong")}finally{o()}},L=async(e,t)=>{let n=t.fields.reduce((e,t)=>(e[t.variableName]=t.dataType,e),{}),a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageName:r,oldSectionName:s[e].sectionName,fieldObj:n,newSectionName:t.sectionName})};try{let r=await fetch("/api/admin/content-controller/section/update-section",a);if(!r.ok){let e=await r.json();console.error("Error from server:",e);return}await r.json(),i(r=>{let a=[...r];return a[e]={...a[e],sectionName:t.sectionName,fields:n},a}),c(r=>{let a=[...r];
1return a[e]={...a[e],sectionName:t.sectionName,fields:n},a}),N("success","Section updated")}catch(e){N("error","uh oh!, cannot update section"),console.error("Error submitting form:",e)}finally{v(!1),u(null)}},D=async e=>{try{let t={pageName:r,sectionName:s[e].sectionName},n={method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},a=await fetch("/api/admin/content-controller/section/delete-section",n);if(!a.ok){let e=await a.json();throw Error("Error: ".concat(a.statusText,", ").concat(e.message))}i(t=>{let r=[...t];return r.splice(e,1),r}),c(t=>{let r=[...t];return r.splice(e,1),r}),N("success","Section Deleted")}catch(e){N("error","Something went wrong"),console.error(e)}};return(0,n.jsx)(b.Z,{children:(0,n.jsxs)("div",{className:"px-[24px] pt-2",children:[(0,n.jsx)("div",{className:"text-[20px] font-bold",children:r}),(0,n.jsx)("button",{onClick:()=>t(!0),className:"my-2 inline-flex items-center rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2",children:"+ Add Section"}),(0,n.jsx)(g.Z,{isOpen:e,onClose:o,children:(0,n.jsx)(x,{addSection:Z})}),(0,n.jsx)("div",{className:"h-[80vh] w-full space-y-4 overflow-y-auto","aria-disabled":!0,children:s.map((e,t)=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(h,{handleOrderChange:k,items:s[t],btnDisabled:function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(JSON.stringify(e[r])!==JSON.stringify(t[r]))return!1;return!0}(l[t].content,s[t].content),index:t,addContent:S,updateContent:E,deleteContent:T,setEditingIndex:u,deleteSection:D,toggleVisibility:O,handleSaveOrder:C,setIsFormEdit:v},t),d===t&&(0,n.jsx)(g.Z,{isOpen:y,onClose:()=>{v(!1),u(null)},children:(0,n.jsx)(p,{sectionData:{sectionName:s[t].sectionName,sectionFields:s[t].fields},index:t,updateSection:L})})]}))})]},r)})};var w=v;v.getLayout=e=>(0,n.jsx)(y.Z,{children:e})},37677:function(){}},function(e){e.O(0,[25675,41664,97629,92888,49774,40179],function(){return e(e.s=27144)}),_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.