biohazard-vfx/.next/static/chunks/app/admin/team/page-4864b40fe27e97d2.js
Nicholai 98a4c8f7db
Some checks failed
Build and Push to Docker Hub / Push Docker image to Docker Hub (push) Has been cancelled
Build and Push Docker Image / build-and-push (push) Has been cancelled
Fixed uploading and database integration, slightly updated NAV and made admin functionality live
2025-08-16 11:46:04 -06:00

1 line
12 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2126],{3960:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>u});var s=a(95155),r=a(12115),l=a(12108),i=a(35695),n=a(66766),o=a(70627),c=a(87481),d=a(32941),m=a(49903);function u(){let{data:e,status:t}=(0,l.useSession)(),a=(0,i.useRouter)(),[u,h]=(0,r.useState)([]),[p,x]=(0,r.useState)(!0),[f,g]=(0,r.useState)(null),[b,j]=(0,r.useState)(!1);(0,r.useEffect)(()=>{"loading"!==t&&(e||a.push("/admin/login"))},[e,t,a]),(0,r.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();h(t)}catch(e){console.error("Error fetching team members:",e)}finally{x(!1)}};e&&t()},[e]);let v=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();h(t)}catch(e){console.error("Error fetching team members:",e)}};await t(),(0,c.o)({title:"Success",description:"Member deleted successfully",status:"success"})}catch(e){console.error("Error deleting member:",e),(0,c.o)({title:"Error",description:"Failed to delete member",status:"error"})}},y=async e=>{if(e.preventDefault(),f)try{let e;if(!(e=f.id?await fetch("/api/team/".concat(f.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}):await fetch("/api/team",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).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();h(t)}catch(e){console.error("Error fetching team members:",e)}};await t(),j(!1),g(null),(0,c.o)({title:"Success",description:"Member saved successfully",status:"success"})}catch(e){console.error("Error saving member:",e),(0,c.o)({title:"Error",description:"Failed to save member",status:"error"})}},N=async(e,t)=>{let a=u.findIndex(t=>t.id===e);if(-1===a)return;let s=[...u],r="up"===t?a-1:a+1;if(!(r<0)&&!(r>=u.length)){[s[a],s[r]]=[s[r],s[a]],s.forEach((e,t)=>e.order=t);try{let e=s.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();h(t)}catch(e){console.error("Error fetching team members:",e)}};await t()}catch(e){console.error("Error reordering members:",e),(0,c.o)({title:"Error",description:"Failed to reorder members",status:"error"})}}};return"loading"===t||p?(0,s.jsx)("div",{className:"flex items-center justify-center min-h-[40vh]",children:(0,s.jsx)("span",{className:"spinner w-8 h-8"})}):(0,s.jsxs)("div",{children:[(0,s.jsx)(d.zY,{title:"Manage Team",subtitle:"Add, reorder, and update crew profiles.",actions:(0,s.jsx)(m.$n,{onClick:()=>{g({id:"",name:"",title:"",quote:"",image:"",instagram:"",order:u.length}),j(!0)},children:"Add Team Member"})}),(0,s.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:u.sort((e,t)=>e.order-t.order).map((e,t)=>(0,s.jsxs)("div",{className:"card overflow-hidden",children:[(0,s.jsx)("div",{className:"relative aspect-[3/4]",children:(0,s.jsx)(n.default,{src:e.image,alt:e.name,fill:!0,className:"object-cover"})}),(0,s.jsxs)("div",{className:"p-6",children:[(0,s.jsx)("h3",{className:"text-xl font-bold text-white",children:e.name}),(0,s.jsx)("p",{className:"text-accent",children:e.title}),(0,s.jsxs)("p",{className:"text-sm italic text-primary mb-4",children:['"',e.quote,'"']}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.$n,{variant:"ghost",onClick:()=>N(e.id,"up"),disabled:0===t,children:"↑"}),(0,s.jsx)(m.$n,{variant:"ghost",onClick:()=>N(e.id,"down"),disabled:t===u.length-1,children:"↓"}),(0,s.jsx)(m.$n,{variant:"secondary",onClick:()=>{g(e),j(!0)},children:"Edit"}),(0,s.jsx)(m.$n,{variant:"danger",onClick:()=>v(e.id),children:"Remove"})]})]})]},e.id))}),b&&f&&(0,s.jsx)("div",{className:"modal-backdrop flex items-center justify-center p-6",onClick:e=>{e.target===e.currentTarget&&(j(!1),g(null))},children:(0,s.jsxs)("div",{className:"modal-content left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 max-w-2xl w-full p-6 max-h-[90vh] overflow-y-auto",children:[(0,s.jsx)("h2",{className:"text-2xl font-semibold text-white mb-6",children:f.id?"Edit Team Member":"Add Team Member"}),(0,s.jsxs)("form",{onSubmit:y,className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Name"}),(0,s.jsx)("input",{type:"text",value:f.name,onChange:e=>g({...f,name:e.target.value}),className:"input",required:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Title"}),(0,s.jsx)("input",{type:"text",value:f.title,onChange:e=>g({...f,title:e.target.value}),className:"input",placeholder:"e.g., Founder & CEO",required:!0})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Quote"}),(0,s.jsx)("input",{type:"text",value:f.quote,onChange:e=>g({...f,quote:e.target.value}),className:"input",placeholder:"A memorable quote"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"label",children:"Photo"}),f.image&&(0,s.jsx)("div",{className:"relative w-full h-48 mb-2 rounded-lg overflow-hidden",children:(0,s.jsx)(n.default,{src:f.image,alt:"Team member photo preview",fill:!0,className:"object-cover"})}),(0,s.jsx)(o.A,{endpoint:"imageUploader",onUploadComplete:e=>g({...f,image:e}),className:"mb-2"}),(0,s.jsx)("input",{type:"text",value:f.image,onChange:e=>g({...f,image:e.target.value}),className:"input",placeholder:"Or enter URL manually"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Instagram URL"}),(0,s.jsx)("input",{type:"text",value:f.instagram,onChange:e=>g({...f,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,s.jsxs)("div",{className:"flex justify-end gap-3 pt-4",children:[(0,s.jsx)(m.$n,{type:"button",variant:"ghost",onClick:()=>{j(!1),g(null)},children:"Cancel"}),(0,s.jsx)(m.$n,{type:"submit",children:"Save Member"})]})]})]})})]})}},32941:(e,t,a)=>{"use strict";a.d(t,{mc:()=>i,wn:()=>l,xA:()=>n,zY:()=>r});var s=a(95155);function r(e){let{title:t,subtitle:a,actions:r}=e;return(0,s.jsx)("div",{className:"mb-8",children:(0,s.jsxs)("div",{className:"flex items-start justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-4xl font-display tracking-tight text-white mb-2",children:t}),a&&(0,s.jsx)("p",{className:"text-text-muted text-lg max-w-3xl",children:a})]}),r&&(0,s.jsx)("div",{className:"flex items-center gap-3",children:r})]})})}function l(e){let{children:t,className:a=""}=e;return(0,s.jsx)("section",{className:"section-spacing ".concat(a),children:t})}function i(e){let{children:t,className:a=""}=e;return(0,s.jsx)("div",{className:"container-custom ".concat(a),children:t})}function n(e){let{children:t,cols:a=3,gap:r="md",className:l=""}=e;return(0,s.jsx)("div",{className:"grid ".concat({1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"}[a]," ").concat({sm:"gap-4",md:"gap-6",lg:"gap-8"}[r]," ").concat(l),children:t})}a(12115)},41474:(e,t,a)=>{Promise.resolve().then(a.bind(a,3960))},49903:(e,t,a)=>{"use strict";a.d(t,{$n:()=>i,z9:()=>n});var s=a(95155),r=a(6874),l=a.n(r);function i(e){let{variant:t="primary",size:a="md",isLoading:r=!1,children:l,className:i="",disabled:n,...o}=e;return(0,s.jsx)("button",{className:"".concat({primary:"btn-primary",secondary:"btn-secondary",ghost:"btn-ghost",danger:"btn bg-red-500 hover:bg-red-600 text-white"}[t]," ").concat({sm:"px-3 py-1.5 text-sm",md:"px-4 py-2",lg:"px-6 py-3 text-lg"}[a]," ").concat(i," ").concat(r?"opacity-75 cursor-wait":""),disabled:n||r,...o,children:r?(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"spinner w-4 h-4"}),"Loading..."]}):l})}function n(e){let{variant:t="primary",size:a="md",children:r,className:i="",href:n="#",...o}=e;return(0,s.jsx)(l(),{href:n,className:"".concat({primary:"btn-primary",secondary:"btn-secondary",ghost:"btn-ghost"}[t]," ").concat({sm:"px-3 py-1.5 text-sm",md:"px-4 py-2",lg:"px-6 py-3 text-lg"}[a]," ").concat(i),...o,children:r})}a(12115)},66766:(e,t,a)=>{"use strict";a.d(t,{default:()=>r.a});var s=a(71469),r=a.n(s)},70627:(e,t,a)=>{"use strict";a.d(t,{A:()=>o});var s=a(95155),r=a(12115);let{useUploadThing:l,uploadFiles:i}=(0,a(38897).KB)();var n=a(87481);function o(e){var t,a;let{endpoint:i,onUploadComplete:o,className:c}=e,[d,m]=(0,r.useState)(!1),{startUpload:u,permittedFileInfo:h}=l(i,{onClientUploadComplete:e=>{m(!1),e&&e[0]&&(null==o||o(e[0].url,new File([],e[0].name)),(0,n.o)({title:"Success",description:"File uploaded successfully!",status:"success"}))},onUploadError:e=>{m(!1),(0,n.o)({title:"Error",description:"Upload failed: ".concat(e.message),status:"error"})},onUploadBegin:()=>{m(!0)}});return(0,s.jsxs)("div",{className:c,children:[(0,s.jsx)("div",{className:"flex items-center justify-center w-full",children:(0,s.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,s.jsxs)("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[(0,s.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,s.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,s.jsxs)("p",{className:"mb-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"font-semibold",children:"Click to upload"})," or drag and drop"]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:(null==h||null==(t=h.config.image)?void 0:t.maxFileSize)||(null==h||null==(a=h.config.video)?void 0:a.maxFileSize)||"Any file type"})]}),(0,s.jsx)("input",{type:"file",className:"hidden",onChange:e=>{var t;let a=null==(t=e.target.files)?void 0:t[0];a&&u([a]).catch(e=>{(0,n.o)({title:"Error",description:"Upload failed. Please try again.",status:"error"})})},disabled:d})]})}),d&&(0,s.jsx)("p",{className:"text-text-muted mt-2 text-center",children:"Uploading..."})]})}},71469:(e,t,a)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var a in t)Object.defineProperty(e,a,{enumerable:!0,get:t[a]})}(t,{default:function(){return o},getImageProps:function(){return n}});let s=a(88229),r=a(38883),l=a(33063),i=s._(a(51193));function n(e){let{props:t}=(0,r.getImgProps)(e,{defaultLoader:i.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,a]of Object.entries(t))void 0===a&&delete t[e];return{props:t}}let o=l.Image},87481:(e,t,a)=>{"use strict";a.d(t,{d:()=>d,o:()=>c});var s=a(12115);let r={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"},l=0,i=[],n={toasts:[]};function o(e){n=((e,t)=>{switch(t.type){case r.ADD_TOAST:return{...e,toasts:[t.toast,...e.toasts].slice(0,3)};case r.DISMISS_TOAST:{let{toastId:a}=t;return{...e,toasts:e.toasts.map(e=>e.id===a?{...e,status:"error"}:e)}}case r.REMOVE_TOAST:return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(n,e),i.forEach(e=>{e(n)})}function c(e){var t;let{...a}=e,s=(l=(l+1)%Number.MAX_SAFE_INTEGER).toString();return o({type:r.ADD_TOAST,toast:{...a,id:s,status:null!=(t=a.status)?t:"info",title:a.title,description:a.description,action:a.action}}),{id:s,dismiss:()=>o({type:r.DISMISS_TOAST,toastId:s}),update:e=>o({type:r.UPDATE_TOAST,toast:{...e,id:s}})}}function d(){let[e,t]=s.useState(n);return s.useEffect(()=>(i.push(t),()=>{let e=i.indexOf(t);e>-1&&i.splice(e,1)}),[e]),{...e,toast:c,dismiss:e=>o({type:r.DISMISS_TOAST,toastId:e})}}}},e=>{e.O(0,[6874,3063,6454,8897,8441,5964,7358],()=>e(e.s=41474)),_N_E=e.O()}]);