1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[126],{3960:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>u});var a=r(95155),s=r(12115),l=r(12108),o=r(35695),i=r(6874),n=r.n(i),c=r(66766),d=r(65581),m=r(87481);function u(){let{data:e,status:t}=(0,l.useSession)(),r=(0,o.useRouter)(),[i,u]=(0,s.useState)([]),[h,b]=(0,s.useState)(!0),[x,p]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1);(0,s.useEffect)(()=>{"loading"!==t&&(e||r.push("/admin/login"))},[e,t,r]),(0,s.useEffect)(()=>{let t=async()=>{try{let e=await fetch("/api/team");if(!e.ok)throw Error("Failed to fetch team members");let t=await e.json();u(t)}catch(e){console.error("Error fetching team members:",e)}finally{b(!1)}};e&&t()},[e]);let j=async e=>{if(confirm("Are you sure you want to remove this team member?"))try{if(!(await fetch("/api/team/".concat(e),{method:"DELETE"})).ok)throw Error("Failed to delete member");let t=async()=>{try{let e=await fetch("/api/team");if(!e.ok)throw Error("Failed to fetch team members");let t=await e.json();u(t)}catch(e){console.error("Error fetching team members:",e)}};await t(),(0,m.o)({title:"Success",description:"Member deleted successfully",status:"success"})}catch(e){console.error("Error deleting member:",e),(0,m.o)({title:"Error",description:"Failed to delete member",status:"error"})}},v=async e=>{if(e.preventDefault(),x)try{let e;if(!(e=x.id?await fetch("/api/team/".concat(x.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)}):await fetch("/api/team",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)})).ok){let t=await e.json();throw Error(t.error||"Failed to save member")}let t=async()=>{try{let e=await fetch("/api/team");if(!e.ok)throw Error("Failed to fetch team members");let t=await e.json();u(t)}catch(e){console.error("Error fetching team members:",e)}};await t(),g(!1),p(null),(0,m.o)({title:"Success",description:"Member saved successfully",status:"success"})}catch(e){console.error("Error saving member:",e),(0,m.o)({title:"Error",description:"Failed to save member",status:"error"})}},y=async(e,t)=>{let r=i.findIndex(t=>t.id===e);if(-1===r)return;let a=[...i],s="up"===t?r-1:r+1;if(!(s<0)&&!(s>=i.length)){[a[r],a[s]]=[a[s],a[r]],a.forEach((e,t)=>e.order=t);try{let e=a.map(e=>fetch("/api/team/".concat(e.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}));await Promise.all(e);let t=async()=>{try{let e=await fetch("/api/team");if(!e.ok)throw Error("Failed to fetch team members");let t=await e.json();u(t)}catch(e){console.error("Error fetching team members:",e)}};await t()}catch(e){console.error("Error reordering members:",e),(0,m.o)({title:"Error",description:"Failed to reorder members",status:"error"})}}};return"loading"===t||h?(0,a.jsx)("div",{className:"min-h-screen bg-bg-dark flex items-center justify-center",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-accent"})}):(0,a.jsxs)("div",{className:"min-h-screen bg-bg-dark",children:[(0,a.jsx)("header",{className:"bg-bg-light border-b border-bg-light/50",children:(0,a.jsxs)("div",{className:"max-w-7xl mx-auto px-6 py-4 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsx)(n(),{href:"/admin",className:"text-text-muted hover:text-white",children:"← Back"}),(0,a.jsx)("h1",{className:"text-2xl font-bold text-white",children:"Manage Team"})]}),(0,a.jsx)("button",{onClick:()=>{p({id:"",name:"",title:"",role:"",quote:"",image:"",instagram:"",bio:"",order:i.length}),g(!0)},className:"bg-accent text-bg-dark px-4 py-2 rounded hover:bg-accent/90 transition-colors",children:"Add Team Member"})]})}),(0,a.jsx)("main",{className:"max-w-7xl mx-auto px-6 py-8",children:(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:i.sort((e,t)=>e.order-t.order).map((e,t)=>(0,a.jsxs)("div",{className:"bg-bg-light rounded-lg overflow-hidden",children:[(0,a.jsx)("div",{className:"relative aspect-[3/4]",children:(0,a.jsx)(c.default,{src:e.image,alt:e.name,fill:!0,className:"object-cover"})}),(0,a.jsxs)("div",{className:"p-6",children:[(0,a.jsx)("h3",{className:"text-xl font-bold text-white",children:e.name}),(0,a.jsx)("p",{className:"text-accent",children:e.title}),(0,a.jsx)("p",{className:"text-text-muted text-sm mb-2",children:e.role}),(0,a.jsxs)("p",{className:"text-sm italic text-primary mb-4",children:['"',e.quote,'"']}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("button",{onClick:()=>y(e.id,"up"),disabled:0===t,className:"p-2 text-text-muted hover:text-white disabled:opacity-50",children:"↑"}),(0,a.jsx)("button",{onClick:()=>y(e.id,"down"),disabled:t===i.length-1,className:"p-2 text-text-muted hover:text-white disabled:opacity-50",children:"↓"}),(0,a.jsx)("button",{onClick:()=>{p(e),g(!0)},className:"px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Edit"}),(0,a.jsx)("button",{onClick:()=>j(e.id),className:"px-3 py-1 bg-red-500 text-white rounded hover:bg-red-600",children:"Remove"})]})]})]},e.id))})}),f&&x&&(0,a.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-6",onClick:e=>{e.target===e.currentTarget&&(g(!1),p(null))},children:(0,a.jsxs)("div",{className:"bg-bg-light rounded-lg p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold mb-6",children:x.id?"Edit Team Member":"Add Team Member"}),(0,a.jsxs)("form",{onSubmit:v,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Name"}),(0,a.jsx)("input",{type:"text",value:x.name,onChange:e=>p({...x,name:e.target.value}),className:"w-full px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Title"}),(0,a.jsx)("input",{type:"text",value:x.title,onChange:e=>p({...x,title:e.target.value}),className:"w-full px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",placeholder:"e.g., Founder & CEO",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Role"}),(0,a.jsx)("input",{type:"text",value:x.role,onChange:e=>p({...x,role:e.target.value}),className:"w-full px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",placeholder:"e.g., VFX Supervisor • 3D Artist",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Quote"}),(0,a.jsx)("input",{type:"text",value:x.quote,onChange:e=>p({...x,quote:e.target.value}),className:"w-full px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",placeholder:"A memorable quote"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Photo"}),x.image&&(0,a.jsx)("div",{className:"relative w-full h-48 mb-2",children:(0,a.jsx)(c.default,{src:x.image,alt:"Team member photo preview",fill:!0,className:"object-cover rounded"})}),(0,a.jsx)(d.A,{endpoint:"imageUploader",onUploadComplete:e=>p({...x,image:e}),className:"mb-2"}),(0,a.jsx)("input",{type:"text",value:x.image,onChange:e=>p({...x,image:e.target.value}),className:"w-full px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",placeholder:"Or enter URL manually"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Instagram URL"}),(0,a.jsx)("input",{type:"text",value:x.instagram,onChange:e=>p({...x,instagram:e.target.value}),className:"w-full px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",placeholder:"https://www.instagram.com/username/"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Bio"}),(0,a.jsx)("textarea",{value:x.bio,onChange:e=>p({...x,bio:e.target.value}),className:"w-full px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",rows:4,required:!0})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-4 pt-4",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{g(!1),p(null)},className:"px-4 py-2 text-text-muted hover:text-white",children:"Cancel"}),(0,a.jsx)("button",{type:"submit",className:"px-4 py-2 bg-accent text-bg-dark rounded hover:bg-accent/90",children:"Save Member"})]})]})]})})]})}},41474:(e,t,r)=>{Promise.resolve().then(r.bind(r,3960))},65581:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});var a=r(95155);r(12115);var s=r(87481);function l(e){var t,r;let{endpoint:l,onUploadComplete:o,className:i}=e,[n,c]=useState(!1),{startUpload:d,permittedFileInfo:m}=useUploadThing(l,{onClientUploadComplete:e=>{c(!1),e&&e[0]&&(null==o||o(e[0].url,new File([],e[0].name)),(0,s.o)({title:"Success",description:"File uploaded successfully!",status:"success"}))},onUploadError:e=>{c(!1),(0,s.o)({title:"Error",description:"Upload failed: ".concat(e.message),status:"error"})},onUploadBegin:()=>{c(!0)}});return(0,a.jsxs)("div",{className:i,children:[(0,a.jsx)("div",{className:"flex items-center justify-center w-full",children:(0,a.jsxs)("label",{className:"flex flex-col items-center justify-center w-full h-64 border-2 border-dashed border-text-muted rounded-lg cursor-pointer bg-bg-light hover:bg-bg-light/50 transition-colors",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[(0,a.jsx)("svg",{className:"w-8 h-8 mb-4 text-text-muted","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 16",children:(0,a.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"})}),(0,a.jsxs)("p",{className:"mb-2 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Click to upload"})," or drag and drop"]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(null==m||null==(t=m.config.image)?void 0:t.maxFileSize)||(null==m||null==(r=m.config.video)?void 0:r.maxFileSize)||"Any file type"})]}),(0,a.jsx)("input",{type:"file",className:"hidden",onChange:e=>{var t;let r=null==(t=e.target.files)?void 0:t[0];r&&d([r]).catch(e=>{(0,s.o)({title:"Error",description:"Upload failed. Please try again.",status:"error"})})},disabled:n})]})}),n&&(0,a.jsx)("p",{className:"text-text-muted mt-2 text-center",children:"Uploading..."})]})}},66766:(e,t,r)=>{"use strict";r.d(t,{default:()=>s.a});var a=r(71469),s=r.n(a)},71469:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{default:function(){return n},getImageProps:function(){return i}});let a=r(88229),s=r(38883),l=r(33063),o=a._(r(51193));function i(e){let{props:t}=(0,s.getImgProps)(e,{defaultLoader:o.default,imgConf:{deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[16,32,48,64,96,128,256,384],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1}});for(let[e,r]of Object.entries(t))void 0===r&&delete t[e];return{props:t}}let n=l.Image},87481:(e,t,r)=>{"use strict";r.d(t,{d:()=>d,o:()=>c});var a=r(12115);let s={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"},l=0,o=[],i={toasts:[]};function n(e){i=((e,t)=>{switch(t.type){case s.ADD_TOAST:return{...e,toasts:[t.toast,...e.toasts].slice(0,3)};case s.DISMISS_TOAST:{let{toastId:r}=t;return{...e,toasts:e.toasts.map(e=>e.id===r?{...e,status:"error"}:e)}}case s.REMOVE_TOAST:return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(i,e),o.forEach(e=>{e(i)})}function c(e){var t;let{...r}=e,a=(l=(l+1)%Number.MAX_SAFE_INTEGER).toString();return n({type:s.ADD_TOAST,toast:{...r,id:a,status:null!=(t=r.status)?t:"info",title:r.title,description:r.description,action:r.action}}),{id:a,dismiss:()=>n({type:s.DISMISS_TOAST,toastId:a}),update:e=>n({type:s.UPDATE_TOAST,toast:{...e,id:a}})}}function d(){let[e,t]=a.useState(i);return a.useEffect(()=>(o.push(t),()=>{let e=o.indexOf(t);e>-1&&o.splice(e,1)}),[e]),{...e,toast:c,dismiss:e=>n({type:s.DISMISS_TOAST,toastId:e})}}}},e=>{e.O(0,[874,63,454,441,964,120],()=>e(e.s=41474)),_N_E=e.O()}]); |