biohazard-vfx/.next/static/chunks/app/admin/projects/page-219b2626951e3dd8.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
13 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3321],{32941:(e,t,s)=>{"use strict";s.d(t,{mc:()=>r,wn:()=>i,xA:()=>n,zY:()=>l});var a=s(95155);function l(e){let{title:t,subtitle:s,actions:l}=e;return(0,a.jsx)("div",{className:"mb-8",children:(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-4xl font-display tracking-tight text-white mb-2",children:t}),s&&(0,a.jsx)("p",{className:"text-text-muted text-lg max-w-3xl",children:s})]}),l&&(0,a.jsx)("div",{className:"flex items-center gap-3",children:l})]})})}function i(e){let{children:t,className:s=""}=e;return(0,a.jsx)("section",{className:"section-spacing ".concat(s),children:t})}function r(e){let{children:t,className:s=""}=e;return(0,a.jsx)("div",{className:"container-custom ".concat(s),children:t})}function n(e){let{children:t,cols:s=3,gap:l="md",className:i=""}=e;return(0,a.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"}[s]," ").concat({sm:"gap-4",md:"gap-6",lg:"gap-8"}[l]," ").concat(i),children:t})}s(12115)},49903:(e,t,s)=>{"use strict";s.d(t,{$n:()=>r,z9:()=>n});var a=s(95155),l=s(6874),i=s.n(l);function r(e){let{variant:t="primary",size:s="md",isLoading:l=!1,children:i,className:r="",disabled:n,...c}=e;return(0,a.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"}[s]," ").concat(r," ").concat(l?"opacity-75 cursor-wait":""),disabled:n||l,...c,children:l?(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"spinner w-4 h-4"}),"Loading..."]}):i})}function n(e){let{variant:t="primary",size:s="md",children:l,className:r="",href:n="#",...c}=e;return(0,a.jsx)(i(),{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"}[s]," ").concat(r),...c,children:l})}s(12115)},52155:(e,t,s)=>{Promise.resolve().then(s.bind(s,82399))},66766:(e,t,s)=>{"use strict";s.d(t,{default:()=>l.a});var a=s(71469),l=s.n(a)},70627:(e,t,s)=>{"use strict";s.d(t,{A:()=>c});var a=s(95155),l=s(12115);let{useUploadThing:i,uploadFiles:r}=(0,s(38897).KB)();var n=s(87481);function c(e){var t,s;let{endpoint:r,onUploadComplete:c,className:o}=e,[d,u]=(0,l.useState)(!1),{startUpload:m,permittedFileInfo:p}=i(r,{onClientUploadComplete:e=>{u(!1),e&&e[0]&&(null==c||c(e[0].url,new File([],e[0].name)),(0,n.o)({title:"Success",description:"File uploaded successfully!",status:"success"}))},onUploadError:e=>{u(!1),(0,n.o)({title:"Error",description:"Upload failed: ".concat(e.message),status:"error"})},onUploadBegin:()=>{u(!0)}});return(0,a.jsxs)("div",{className:o,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==p||null==(t=p.config.image)?void 0:t.maxFileSize)||(null==p||null==(s=p.config.video)?void 0:s.maxFileSize)||"Any file type"})]}),(0,a.jsx)("input",{type:"file",className:"hidden",onChange:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];s&&m([s]).catch(e=>{(0,n.o)({title:"Error",description:"Upload failed. Please try again.",status:"error"})})},disabled:d})]})}),d&&(0,a.jsx)("p",{className:"text-text-muted mt-2 text-center",children:"Uploading..."})]})}},71469:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var s in t)Object.defineProperty(e,s,{enumerable:!0,get:t[s]})}(t,{default:function(){return c},getImageProps:function(){return n}});let a=s(88229),l=s(38883),i=s(33063),r=a._(s(51193));function n(e){let{props:t}=(0,l.getImgProps)(e,{defaultLoader:r.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,s]of Object.entries(t))void 0===s&&delete t[e];return{props:t}}let c=i.Image},82399:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>m});var a=s(95155),l=s(12115),i=s(12108),r=s(35695),n=s(66766),c=s(87481),o=s(70627),d=s(32941),u=s(49903);function m(){let{data:e,status:t}=(0,i.useSession)(),s=(0,r.useRouter)(),[m,p]=(0,l.useState)([]),[h,x]=(0,l.useState)(!0),[f,j]=(0,l.useState)(null),[g,b]=(0,l.useState)(!1);(0,l.useEffect)(()=>{"loading"!==t&&(e||s.push("/admin/login"))},[e,t,s]),(0,l.useEffect)(()=>{let t=async()=>{try{let e=await fetch("/api/projects");if(!e.ok)throw Error("Failed to fetch projects");let t=await e.json();p(t)}catch(e){(0,c.o)({title:"Error",description:"Failed to load projects",status:"error"})}finally{x(!1)}};e&&t()},[e]);let v=async e=>{if(confirm("Are you sure you want to delete this project?"))try{if(!(await fetch("/api/projects/".concat(e),{method:"DELETE"})).ok)throw Error("Failed to delete project");p(m.filter(t=>t.id!==e)),(0,c.o)({title:"Success",description:"Project deleted successfully",status:"success"})}catch(e){(0,c.o)({title:"Error",description:"Failed to delete project",status:"error"})}},y=async e=>{if(e.preventDefault(),f){console.log("Sending project data:",f);try{let e;if(!(e=f.id?await fetch("/api/projects/".concat(f.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}):await fetch("/api/projects/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).ok){let t=await e.json();throw Error(t.error||"Failed to save project")}let t=await e.json();f.id?p(m.map(e=>e.id===t.id?t:e)):p([...m,t]),b(!1),j(null),(0,c.o)({title:"Success",description:"Project saved successfully",status:"success"})}catch(e){(0,c.o)({title:"Error",description:"Failed to save project",status:"error"})}}};return"loading"===t||h?(0,a.jsx)("div",{className:"flex items-center justify-center min-h-[40vh]",children:(0,a.jsx)("span",{className:"spinner w-8 h-8"})}):(0,a.jsxs)("div",{children:[(0,a.jsx)(d.zY,{title:"Manage Projects",subtitle:"Create, update, and publish portfolio work.",actions:(0,a.jsx)(u.$n,{onClick:()=>{j({id:"",title:"",description:null,thumbnail:"",size:"SMALL",embed:null,video:null,credits:"",info:"",category:null,tags:null,featured:!1,published:!1,createdAt:new Date,updatedAt:new Date}),b(!0)},children:"Add New Project"})}),(0,a.jsx)("div",{className:"space-y-4",children:m.map(e=>(0,a.jsxs)("div",{className:"card flex items-center gap-6",children:[(0,a.jsx)("div",{className:"relative w-32 h-20 flex-shrink-0 rounded-lg overflow-hidden",children:(0,a.jsx)(n.default,{src:e.thumbnail,alt:e.title,fill:!0,className:"object-cover"})}),(0,a.jsxs)("div",{className:"flex-grow",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-white",children:e.title}),(0,a.jsx)("p",{className:"text-text-muted text-sm",children:e.category||"No category"}),e.featured&&(0,a.jsx)("span",{className:"badge badge-accent mt-2",children:"Featured"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(u.$n,{variant:"secondary",onClick:()=>{j(e),b(!0)},children:"Edit"}),(0,a.jsx)(u.$n,{variant:"danger",onClick:()=>v(e.id),children:"Delete"})]})]},e.id))}),g&&f&&(0,a.jsx)("div",{className:"modal-backdrop flex items-center justify-center p-6",onClick:e=>{e.target===e.currentTarget&&(b(!1),j(null))},children:(0,a.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,a.jsx)("h2",{className:"text-2xl font-semibold text-white mb-6",children:f.id?"Edit Project":"Add New Project"}),(0,a.jsxs)("form",{onSubmit:y,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Title"}),(0,a.jsx)("input",{type:"text",value:f.title,onChange:e=>j({...f,title:e.target.value}),className:"input",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Description (optional)"}),(0,a.jsx)("textarea",{value:f.description||"",onChange:e=>j({...f,description:e.target.value}),className:"input",rows:3})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Category (optional)"}),(0,a.jsx)("input",{type:"text",value:f.category||"",onChange:e=>j({...f,category:e.target.value}),className:"input"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Thumbnail"}),f.thumbnail&&(0,a.jsx)("div",{className:"relative w-32 h-20 mb-2",children:(0,a.jsx)(n.default,{src:f.thumbnail,alt:"Thumbnail preview",fill:!0,className:"object-cover rounded"})}),(0,a.jsx)(o.A,{endpoint:"imageUploader",onUploadComplete:e=>j({...f,thumbnail:e}),className:"mb-2"}),(0,a.jsx)("input",{type:"text",value:f.thumbnail,onChange:e=>j({...f,thumbnail:e.target.value}),className:"input",placeholder:"Or enter URL manually"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Size"}),(0,a.jsxs)("select",{value:f.size,onChange:e=>j({...f,size:e.target.value}),className:"input",children:[(0,a.jsx)("option",{value:"SMALL",children:"Small"}),(0,a.jsx)("option",{value:"BIG",children:"Big"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Video Upload (optional)"}),f.video&&(0,a.jsx)("div",{className:"relative w-full h-48 mb-2",children:(0,a.jsx)("video",{src:f.video,controls:!0,className:"w-full h-full object-cover rounded"})}),(0,a.jsx)(o.A,{endpoint:"videoUploader",onUploadComplete:e=>j({...f,video:e}),className:"mb-2"}),(0,a.jsx)("input",{type:"text",value:f.video||"",onChange:e=>j({...f,video:e.target.value}),className:"input",placeholder:"Or enter URL manually"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Embed URL (YouTube/Vimeo) (optional)"}),(0,a.jsx)("input",{type:"text",value:f.embed||"",onChange:e=>j({...f,embed:e.target.value}),className:"input",placeholder:"https://www.youtube.com/embed/..."})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Credits"}),(0,a.jsx)("textarea",{value:f.credits,onChange:e=>j({...f,credits:e.target.value}),className:"input",rows:4,placeholder:"Enter project credits directly"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Project Info"}),(0,a.jsx)("textarea",{value:f.info,onChange:e=>j({...f,info: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,placeholder:"Enter project information directly"})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"featured",checked:f.featured,onChange:e=>j({...f,featured:e.target.checked}),className:"mr-2"}),(0,a.jsx)("label",{htmlFor:"featured",className:"text-sm",children:"Featured Project"})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"published",checked:f.published,onChange:e=>j({...f,published:e.target.checked}),className:"mr-2"}),(0,a.jsx)("label",{htmlFor:"published",className:"text-sm",children:"Published"})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-4",children:[(0,a.jsx)(u.$n,{type:"button",variant:"ghost",onClick:()=>{b(!1),j(null)},children:"Cancel"}),(0,a.jsx)(u.$n,{type:"submit",children:"Save Project"})]})]})]})})]})}},87481:(e,t,s)=>{"use strict";s.d(t,{d:()=>d,o:()=>o});var a=s(12115);let l={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"},i=0,r=[],n={toasts:[]};function c(e){n=((e,t)=>{switch(t.type){case l.ADD_TOAST:return{...e,toasts:[t.toast,...e.toasts].slice(0,3)};case l.DISMISS_TOAST:{let{toastId:s}=t;return{...e,toasts:e.toasts.map(e=>e.id===s?{...e,status:"error"}:e)}}case l.REMOVE_TOAST:return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(n,e),r.forEach(e=>{e(n)})}function o(e){var t;let{...s}=e,a=(i=(i+1)%Number.MAX_SAFE_INTEGER).toString();return c({type:l.ADD_TOAST,toast:{...s,id:a,status:null!=(t=s.status)?t:"info",title:s.title,description:s.description,action:s.action}}),{id:a,dismiss:()=>c({type:l.DISMISS_TOAST,toastId:a}),update:e=>c({type:l.UPDATE_TOAST,toast:{...e,id:a}})}}function d(){let[e,t]=a.useState(n);return a.useEffect(()=>(r.push(t),()=>{let e=r.indexOf(t);e>-1&&r.splice(e,1)}),[e]),{...e,toast:o,dismiss:e=>c({type:l.DISMISS_TOAST,toastId:e})}}}},e=>{e.O(0,[6874,3063,6454,8897,8441,5964,7358],()=>e(e.s=52155)),_N_E=e.O()}]);