biohazard-vfx/.next/static/chunks/app/admin/assets/page-d3e2ca2b8ff8d300.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
9.3 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6930],{21626:(e,t,s)=>{Promise.resolve().then(s.bind(s,81236))},32941:(e,t,s)=>{"use strict";s.d(t,{mc:()=>n,wn:()=>i,xA:()=>r,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 n(e){let{children:t,className:s=""}=e;return(0,a.jsx)("div",{className:"container-custom ".concat(s),children:t})}function r(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:()=>n,z9:()=>r});var a=s(95155),l=s(6874),i=s.n(l);function n(e){let{variant:t="primary",size:s="md",isLoading:l=!1,children:i,className:n="",disabled:r,...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(n," ").concat(l?"opacity-75 cursor-wait":""),disabled:r||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 r(e){let{variant:t="primary",size:s="md",children:l,className:n="",href:r="#",...c}=e;return(0,a.jsx)(i(),{href:r,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(n),...c,children:l})}s(12115)},70627:(e,t,s)=>{"use strict";s.d(t,{A:()=>c});var a=s(95155),l=s(12115);let{useUploadThing:i,uploadFiles:n}=(0,s(38897).KB)();var r=s(87481);function c(e){var t,s;let{endpoint:n,onUploadComplete:c,className:d}=e,[o,u]=(0,l.useState)(!1),{startUpload:m,permittedFileInfo:x}=i(n,{onClientUploadComplete:e=>{u(!1),e&&e[0]&&(null==c||c(e[0].url,new File([],e[0].name)),(0,r.o)({title:"Success",description:"File uploaded successfully!",status:"success"}))},onUploadError:e=>{u(!1),(0,r.o)({title:"Error",description:"Upload failed: ".concat(e.message),status:"error"})},onUploadBegin:()=>{u(!0)}});return(0,a.jsxs)("div",{className:d,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==x||null==(t=x.config.image)?void 0:t.maxFileSize)||(null==x||null==(s=x.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,r.o)({title:"Error",description:"Upload failed. Please try again.",status:"error"})})},disabled:o})]})}),o&&(0,a.jsx)("p",{className:"text-text-muted mt-2 text-center",children:"Uploading..."})]})}},81236:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>o});var a=s(95155),l=s(12115),i=s(12108),n=s(35695),r=s(32941),c=s(49903),d=s(70627);function o(){let{data:e,status:t}=(0,i.useSession)(),s=(0,n.useRouter)(),[o,u]=(0,l.useState)([]),[m,x]=(0,l.useState)(!0),[p,h]=(0,l.useState)(null),[g,f]=(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/assets"),t=await e.json();u(t)}finally{x(!1)}};e&&t()},[e]);let j=async e=>{if(e.preventDefault(),!p)return;let{id:t,...s}=p;(await fetch(t?"/api/assets/".concat(t):"/api/assets",{method:t?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})).ok&&(u(await (await fetch("/api/assets")).json()),f(!1),h(null))};return"loading"===t||m?(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)(r.zY,{title:"Site Assets",subtitle:"Backgrounds and media used across pages.",actions:(0,a.jsx)(c.$n,{onClick:()=>{h({id:"",key:"",label:"",type:"IMAGE",url:"",alt:""}),f(!0)},children:"Add asset"})}),(0,a.jsx)("div",{className:"space-y-3",children:o.map(e=>(0,a.jsxs)("div",{className:"card flex items-center gap-4",children:[(0,a.jsx)("div",{className:"w-28 h-16 rounded-lg overflow-hidden bg-surface-600 flex items-center justify-center text-xs text-text-muted",children:"IMAGE"===e.type?(0,a.jsx)("img",{src:e.url,alt:e.alt||e.label,className:"w-full h-full object-cover"}):(0,a.jsx)("video",{src:e.url,className:"w-full h-full object-cover"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm text-text-muted truncate",children:e.key}),(0,a.jsx)("p",{className:"text-white font-medium truncate",children:e.label})]}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)(c.$n,{variant:"secondary",onClick:()=>{h(e),f(!0)},children:"Edit"})})]},e.id))}),g&&p&&(0,a.jsx)("div",{className:"modal-backdrop flex items-center justify-center p-6",onClick:e=>{e.target===e.currentTarget&&(f(!1),h(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:p.id?"Edit Asset":"Create Asset"}),(0,a.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Key"}),(0,a.jsx)("input",{className:"input",value:p.key,onChange:e=>h({...p,key:e.target.value}),placeholder:"home.hero.image",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Label"}),(0,a.jsx)("input",{className:"input",value:p.label,onChange:e=>h({...p,label:e.target.value}),placeholder:"Home Hero Background",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Type"}),(0,a.jsxs)("select",{className:"input",value:p.type,onChange:e=>h({...p,type:e.target.value}),children:[(0,a.jsx)("option",{value:"IMAGE",children:"Image"}),(0,a.jsx)("option",{value:"VIDEO",children:"Video"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"URL"}),(0,a.jsx)(d.A,{endpoint:"VIDEO"===p.type?"videoUploader":"imageUploader",onUploadComplete:e=>h({...p,url:e}),className:"mb-2"}),(0,a.jsx)("input",{className:"input",value:p.url,onChange:e=>h({...p,url:e.target.value}),placeholder:"https://...",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Alt text (optional)"}),(0,a.jsx)("input",{className:"input",value:p.alt||"",onChange:e=>h({...p,alt:e.target.value})})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,a.jsx)(c.$n,{type:"button",variant:"ghost",onClick:()=>{f(!1),h(null)},children:"Cancel"}),(0,a.jsx)(c.$n,{type:"submit",children:"Save"})]})]})]})})]})}},87481:(e,t,s)=>{"use strict";s.d(t,{d:()=>o,o:()=>d});var a=s(12115);let l={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"},i=0,n=[],r={toasts:[]};function c(e){r=((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)}}})(r,e),n.forEach(e=>{e(r)})}function d(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 o(){let[e,t]=a.useState(r);return a.useEffect(()=>(n.push(t),()=>{let e=n.indexOf(t);e>-1&&n.splice(e,1)}),[e]),{...e,toast:d,dismiss:e=>c({type:l.DISMISS_TOAST,toastId:e})}}}},e=>{e.O(0,[6874,6454,8897,8441,5964,7358],()=>e(e.s=21626)),_N_E=e.O()}]);