1 line
9.2 KiB
JavaScript
1 line
9.2 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[709],{65581:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});var l=s(95155);s(12115);var a=s(87481);function r(e){var t,s;let{endpoint:r,onUploadComplete:i,className:o}=e,[n,d]=useState(!1),{startUpload:c,permittedFileInfo:u}=useUploadThing(r,{onClientUploadComplete:e=>{d(!1),e&&e[0]&&(null==i||i(e[0].url,new File([],e[0].name)),(0,a.o)({title:"Success",description:"File uploaded successfully!",status:"success"}))},onUploadError:e=>{d(!1),(0,a.o)({title:"Error",description:"Upload failed: ".concat(e.message),status:"error"})},onUploadBegin:()=>{d(!0)}});return(0,l.jsxs)("div",{className:o,children:[(0,l.jsx)("div",{className:"flex items-center justify-center w-full",children:(0,l.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,l.jsxs)("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[(0,l.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,l.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,l.jsxs)("p",{className:"mb-2 text-sm text-text-muted",children:[(0,l.jsx)("span",{className:"font-semibold",children:"Click to upload"})," or drag and drop"]}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:(null==u||null==(t=u.config.image)?void 0:t.maxFileSize)||(null==u||null==(s=u.config.video)?void 0:s.maxFileSize)||"Any file type"})]}),(0,l.jsx)("input",{type:"file",className:"hidden",onChange:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];s&&c([s]).catch(e=>{(0,a.o)({title:"Error",description:"Upload failed. Please try again.",status:"error"})})},disabled:n})]})}),n&&(0,l.jsx)("p",{className:"text-text-muted mt-2 text-center",children:"Uploading..."})]})}},66766:(e,t,s)=>{"use strict";s.d(t,{default:()=>a.a});var l=s(71469),a=s.n(l)},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 n},getImageProps:function(){return o}});let l=s(88229),a=s(38883),r=s(33063),i=l._(s(51193));function o(e){let{props:t}=(0,a.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,s]of Object.entries(t))void 0===s&&delete t[e];return{props:t}}let n=r.Image},78927:(e,t,s)=>{Promise.resolve().then(s.bind(s,99931))},87481:(e,t,s)=>{"use strict";s.d(t,{d:()=>c,o:()=>d});var l=s(12115);let a={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"},r=0,i=[],o={toasts:[]};function n(e){o=((e,t)=>{switch(t.type){case a.ADD_TOAST:return{...e,toasts:[t.toast,...e.toasts].slice(0,3)};case a.DISMISS_TOAST:{let{toastId:s}=t;return{...e,toasts:e.toasts.map(e=>e.id===s?{...e,status:"error"}:e)}}case a.REMOVE_TOAST:return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(o,e),i.forEach(e=>{e(o)})}function d(e){var t;let{...s}=e,l=(r=(r+1)%Number.MAX_SAFE_INTEGER).toString();return n({type:a.ADD_TOAST,toast:{...s,id:l,status:null!=(t=s.status)?t:"info",title:s.title,description:s.description,action:s.action}}),{id:l,dismiss:()=>n({type:a.DISMISS_TOAST,toastId:l}),update:e=>n({type:a.UPDATE_TOAST,toast:{...e,id:l}})}}function c(){let[e,t]=l.useState(o);return l.useEffect(()=>(i.push(t),()=>{let e=i.indexOf(t);e>-1&&i.splice(e,1)}),[e]),{...e,toast:d,dismiss:e=>n({type:a.DISMISS_TOAST,toastId:e})}}},99931:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>x});var l=s(95155),a=s(12115),r=s(12108),i=s(35695),o=s(6874),n=s.n(o),d=s(66766),c=s(87481),u=s(65581);function x(){let{data:e,status:t}=(0,r.useSession)(),s=(0,i.useRouter)(),[o,x]=(0,a.useState)([]),[h,m]=(0,a.useState)(!0),[p,g]=(0,a.useState)("all"),[f,b]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1);(0,a.useEffect)(()=>{"loading"!==t&&(e||s.push("/admin/login"))},[e,t,s]),(0,a.useEffect)(()=>{let e=localStorage.getItem("biohazard_media_files");e&&x(JSON.parse(e)),m(!1)},[]);let N=e=>{localStorage.setItem("biohazard_media_files",JSON.stringify(e)),x(e)},S="all"===p?o:o.filter(e=>e.category===p),y=["all","uncategorized","projects","blog","team","other"];return"loading"===t||h?(0,l.jsx)("div",{className:"min-h-screen bg-bg-dark flex items-center justify-center",children:(0,l.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-accent"})}):(0,l.jsxs)("div",{className:"min-h-screen bg-bg-dark",children:[(0,l.jsx)("header",{className:"bg-bg-light border-b border-bg-light/50",children:(0,l.jsxs)("div",{className:"max-w-7xl mx-auto px-6 py-4 flex items-center justify-between",children:[(0,l.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,l.jsx)(n(),{href:"/admin",className:"text-text-muted hover:text-white",children:"← Back"}),(0,l.jsx)("h1",{className:"text-2xl font-bold text-white",children:"Media Library"})]}),(0,l.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,l.jsx)("select",{value:p,onChange:e=>g(e.target.value),className:"px-3 py-2 bg-bg-dark border border-bg-light rounded focus:border-accent focus:outline-none",children:y.map(e=>(0,l.jsx)("option",{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),(0,l.jsx)("button",{onClick:()=>j(!0),className:"bg-accent text-bg-dark px-4 py-2 rounded hover:bg-accent/90 transition-colors",children:f?"Uploading...":"Upload Files"})]})]})}),(0,l.jsx)("main",{className:"max-w-7xl mx-auto px-6 py-8",children:0===S.length?(0,l.jsx)("div",{className:"text-center py-12 text-text-muted",children:"No files in this category. Upload some files to get started!"}):(0,l.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:S.map(e=>{var t;return(0,l.jsxs)("div",{className:"bg-bg-light rounded-lg overflow-hidden group",children:[(0,l.jsxs)("div",{className:"relative aspect-square bg-bg-dark",children:["image"===e.type?(0,l.jsx)(d.default,{src:e.url,alt:e.name,fill:!0,className:"object-cover"}):"video"===e.type?(0,l.jsx)("video",{src:e.url,className:"w-full h-full object-cover"}):(0,l.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,l.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted",children:[(0,l.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,l.jsx)("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})}),(0,l.jsxs)("div",{className:"absolute inset-0 bg-black/75 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center space-x-2",children:[(0,l.jsx)("button",{onClick:()=>navigator.clipboard.writeText(e.url),className:"p-2 bg-white/20 rounded hover:bg-white/30",title:"Copy URL",children:(0,l.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,l.jsx)("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),(0,l.jsx)("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})}),(0,l.jsx)("button",{onClick:()=>{var t;return t=e.id,void(confirm("Are you sure you want to delete this file?")&&N(o.filter(e=>e.id!==t)))},className:"p-2 bg-red-500/20 rounded hover:bg-red-500/30",title:"Delete",children:(0,l.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,l.jsx)("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"})})})]})]}),(0,l.jsxs)("div",{className:"p-3",children:[(0,l.jsx)("p",{className:"text-sm font-medium truncate",title:e.name,children:e.name}),(0,l.jsx)("p",{className:"text-xs text-text-muted",children:(t=e.size)<1024?t+" B":t<1048576?(t/1024).toFixed(1)+" KB":(t/1048576).toFixed(1)+" MB"}),(0,l.jsx)("select",{value:e.category,onChange:t=>{var s,l;return s=e.id,l=t.target.value,void N(o.map(e=>e.id===s?{...e,category:l}:e))},className:"mt-2 w-full text-xs px-2 py-1 bg-bg-dark border border-bg-light rounded",children:y.filter(e=>"all"!==e).map(e=>(0,l.jsx)("option",{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]},e.id)})})}),v&&(0,l.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-6",onClick:e=>{e.target===e.currentTarget&&j(!1)},children:(0,l.jsxs)("div",{className:"bg-bg-light rounded-lg p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:[(0,l.jsx)("h2",{className:"text-2xl font-bold mb-6",children:"Upload Files"}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)(u.A,{endpoint:"imageUploader",onUploadComplete:e=>{(0,c.o)({title:"Success",description:"File uploaded successfully!",status:"success"}),j(!1)},className:"mb-4"}),(0,l.jsx)("div",{className:"flex justify-end space-x-4 pt-4",children:(0,l.jsx)("button",{type:"button",onClick:()=>j(!1),className:"px-4 py-2 text-text-muted hover:text-white",children:"Close"})})]})]})})]})}}},e=>{e.O(0,[874,63,454,441,964,120],()=>e(e.s=78927)),_N_E=e.O()}]); |