This commit implements the core admin dashboard functionality including NextAuth authentication, Cloudflare D1 database integration with complete schema, and Cloudflare R2 file upload system for portfolio images. Features include artist management, appointment scheduling, and data migration capabilities.
1 line
26 KiB
JavaScript
1 line
26 KiB
JavaScript
(()=>{var e={};e.id=146,e.ids=[146],e.modules={72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},27790:e=>{"use strict";e.exports=require("assert")},78893:e=>{"use strict";e.exports=require("buffer")},84770:e=>{"use strict";e.exports=require("crypto")},17702:e=>{"use strict";e.exports=require("events")},32615:e=>{"use strict";e.exports=require("http")},35240:e=>{"use strict";e.exports=require("https")},55315:e=>{"use strict";e.exports=require("path")},86624:e=>{"use strict";e.exports=require("querystring")},17360:e=>{"use strict";e.exports=require("url")},21764:e=>{"use strict";e.exports=require("util")},71568:e=>{"use strict";e.exports=require("zlib")},33830:(e,t,s)=>{"use strict";s.r(t),s.d(t,{GlobalError:()=>l.a,__next_app__:()=>m,originalPathname:()=>u,pages:()=>c,routeModule:()=>x,tree:()=>o}),s(88179),s(49446),s(40656),s(40509),s(70546);var a=s(30170),i=s(45002),r=s(83876),l=s.n(r),n=s(66299),d={};for(let e in n)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(d[e]=()=>n[e]);s.d(t,d);let o=["",{children:["admin",{children:["uploads",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(s.bind(s,88179)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/admin/uploads/page.tsx"]}]},{}]},{layout:[()=>Promise.resolve().then(s.bind(s,49446)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/admin/layout.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,57481))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}]},{layout:[()=>Promise.resolve().then(s.bind(s,40656)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/layout.tsx"],error:[()=>Promise.resolve().then(s.bind(s,40509)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/error.tsx"],"not-found":[()=>Promise.resolve().then(s.bind(s,70546)),"/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/not-found.tsx"],metadata:{icon:[async e=>(await Promise.resolve().then(s.bind(s,57481))).default(e)],apple:[],openGraph:[],twitter:[],manifest:void 0}}],c=["/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/app/admin/uploads/page.tsx"],u="/admin/uploads/page",m={require:s,loadChunk:()=>Promise.resolve()},x=new a.AppPageRouteModule({definition:{kind:i.x.APP_PAGE,page:"/admin/uploads/page",pathname:"/admin/uploads",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:o}})},77208:(e,t,s)=>{Promise.resolve().then(s.bind(s,87650)),Promise.resolve().then(s.bind(s,60985))},87650:(e,t,s)=>{"use strict";s.d(t,{FileManager:()=>O});var a=s(97247),i=s(28964),r=s(27757),l=s(58053),n=s(70170),d=s(22394),o=s(98969),c=s(91207),u=s(6274),m=s(10906),x=s(10283),h=s(60985),p=s(60782),f=s(26323);let j=(0,f.Z)("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var g=s(70405);let y=(0,f.Z)("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),v=(0,f.Z)("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),N=(0,f.Z)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),w=(0,f.Z)("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),b=(0,f.Z)("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),k=(0,f.Z)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);var z=s(49256);let C=(0,f.Z)("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var M=s(99219);let F=(0,f.Z)("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]),Z=(0,f.Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);var S=s(33841),D=s(37013),_=s(72402),q=s(62976),P=s(19389),T=s(44597);function O(){let[e,t]=(0,i.useState)([]),[s,f]=(0,i.useState)(null),[O,$]=(0,i.useState)(!0),[V,E]=(0,i.useState)("grid"),[U,A]=(0,i.useState)(""),[L,Y]=(0,i.useState)(new Set),[B,H]=(0,i.useState)("/"),[I,G]=(0,i.useState)(!1),[R,W]=(0,i.useState)(!1),[K,X]=(0,i.useState)(""),{toast:J}=(0,m.pm)(),{uploadFiles:Q,isUploading:ee,progress:et}=(0,x.FL)({maxFiles:50,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf","text/*"]}),es=async()=>{try{let e=await fetch(`/api/files?path=${encodeURIComponent(B)}`);if(!e.ok)throw Error("Failed to load files");let s=await e.json();t(s)}catch(e){J({title:"Error",description:"Failed to load files",variant:"destructive"})}},ea=async()=>{try{let e=await fetch("/api/files/stats");if(!e.ok)throw Error("Failed to load stats");let t=await e.json();f(t)}catch(e){console.error("Failed to load stats:",e)}finally{$(!1)}},ei=async e=>{try{let t=Array.from(e);await Q(t,{keyPrefix:B.replace("/","")}),await es(),await ea(),G(!1),J({title:"Success",description:`Uploaded ${t.length} files successfully`})}catch(e){J({title:"Error",description:"Failed to upload files",variant:"destructive"})}},er=async()=>{if(K.trim())try{if(!(await fetch("/api/files/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K,path:B})})).ok)throw Error("Failed to create folder");await es(),W(!1),X(""),J({title:"Success",description:"Folder created successfully"})}catch(e){J({title:"Error",description:"Failed to create folder",variant:"destructive"})}},el=async()=>{try{if(!(await fetch("/api/files/bulk-delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileIds:Array.from(L)})})).ok)throw Error("Failed to delete files");await es(),await ea(),Y(new Set),J({title:"Success",description:`Deleted ${L.size} items successfully`})}catch(e){J({title:"Error",description:"Failed to delete files",variant:"destructive"})}},en=e=>{let t=new Set(L);t.has(e)?t.delete(e):t.add(e),Y(t)},ed=e=>"folder"===e.type?a.jsx(j,{className:"h-4 w-4"}):e.mimeType?.startsWith("image/")?a.jsx(g.Z,{className:"h-4 w-4"}):e.mimeType?.startsWith("video/")?a.jsx(y,{className:"h-4 w-4"}):e.mimeType?.startsWith("audio/")?a.jsx(v,{className:"h-4 w-4"}):e.mimeType?.includes("pdf")?a.jsx(N,{className:"h-4 w-4"}):e.mimeType?.includes("zip")||e.mimeType?.includes("archive")?a.jsx(w,{className:"h-4 w-4"}):a.jsx(b,{className:"h-4 w-4"}),eo=e=>{if(0===e)return"0 Bytes";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},ec=e.filter(e=>e.name.toLowerCase().includes(U.toLowerCase())),eu=B.split("/").filter(Boolean);return O?a.jsx(h.LoadingSpinner,{}):a.jsx(p.SV,{children:(0,a.jsxs)("div",{className:"space-y-6",children:[s&&(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[(0,a.jsxs)(r.Zb,{children:[(0,a.jsxs)(r.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(r.ll,{className:"text-sm font-medium",children:"Total Files"}),a.jsx(b,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(r.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.totalFiles}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["+",s.recentUploads," this week"]})]})]}),(0,a.jsxs)(r.Zb,{children:[(0,a.jsxs)(r.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(r.ll,{className:"text-sm font-medium",children:"Storage Used"}),a.jsx(k,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(r.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.storageUsed}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"R2 storage usage"})]})]}),(0,a.jsxs)(r.Zb,{children:[(0,a.jsxs)(r.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(r.ll,{className:"text-sm font-medium",children:"Images"}),a.jsx(g.Z,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(r.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.fileTypes.image||0}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Image files"})]})]}),(0,a.jsxs)(r.Zb,{children:[(0,a.jsxs)(r.Ol,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[a.jsx(r.ll,{className:"text-sm font-medium",children:"Documents"}),a.jsx(N,{className:"h-4 w-4 text-muted-foreground"})]}),(0,a.jsxs)(r.aY,{children:[a.jsx("div",{className:"text-2xl font-bold",children:s.fileTypes.document||0}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"Document files"})]})]})]}),(0,a.jsxs)(r.Zb,{children:[(0,a.jsxs)(r.Ol,{children:[a.jsx(r.ll,{children:"File Manager"}),a.jsx(r.SZ,{children:"Manage your uploaded files and organize your storage."})]}),(0,a.jsxs)(r.aY,{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-muted-foreground",children:[a.jsx(l.z,{variant:"ghost",size:"sm",onClick:()=>H("/"),className:"h-auto p-1",children:"Home"}),eu.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[a.jsx("span",{children:"/"}),a.jsx(l.z,{variant:"ghost",size:"sm",onClick:()=>H("/"+eu.slice(0,t+1).join("/")),className:"h-auto p-1",children:e})]},t))]}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[(0,a.jsxs)("div",{className:"flex flex-1 items-center space-x-2",children:[a.jsx(z.Z,{className:"h-4 w-4 text-muted-foreground"}),a.jsx(n.I,{placeholder:"Search files...",value:U,onChange:e=>A(e.target.value),className:"max-w-sm"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)(o.Vq,{open:R,onOpenChange:W,children:[a.jsx(o.hg,{asChild:!0,children:(0,a.jsxs)(l.z,{variant:"outline",size:"sm",children:[a.jsx(C,{className:"mr-2 h-4 w-4"}),"New Folder"]})}),(0,a.jsxs)(o.cZ,{children:[(0,a.jsxs)(o.fK,{children:[a.jsx(o.$N,{children:"Create New Folder"}),a.jsx(o.Be,{children:"Enter a name for the new folder."})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx(d._,{htmlFor:"folderName",children:"Folder Name"}),a.jsx(n.I,{id:"folderName",value:K,onChange:e=>X(e.target.value),placeholder:"Enter folder name"})]}),(0,a.jsxs)("div",{className:"flex justify-end space-x-2",children:[a.jsx(l.z,{variant:"outline",onClick:()=>W(!1),children:"Cancel"}),a.jsx(l.z,{onClick:er,children:"Create"})]})]})]})]}),(0,a.jsxs)(o.Vq,{open:I,onOpenChange:G,children:[a.jsx(o.hg,{asChild:!0,children:(0,a.jsxs)(l.z,{children:[a.jsx(M.Z,{className:"mr-2 h-4 w-4"}),"Upload Files"]})}),(0,a.jsxs)(o.cZ,{children:[(0,a.jsxs)(o.fK,{children:[a.jsx(o.$N,{children:"Upload Files"}),a.jsx(o.Be,{children:"Select files to upload to the current directory."})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[a.jsx(d._,{htmlFor:"files",children:"Select Files"}),a.jsx(n.I,{id:"files",type:"file",multiple:!0,onChange:e=>e.target.files&&ei(e.target.files),disabled:ee})]}),ee&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:["Uploading... ",et.length>0?Math.round(et[0].progress||0):0,"%"]}),a.jsx("div",{className:"w-full bg-secondary rounded-full h-2",children:a.jsx("div",{className:"bg-primary h-2 rounded-full transition-all duration-300",style:{width:`${et.length>0&&et[0].progress||0}%`}})})]})]})]})]})]})]}),L.size>0&&(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[(0,a.jsxs)("span",{className:"text-sm font-medium",children:[L.size," item(s) selected"]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)(l.z,{variant:"outline",size:"sm",children:[a.jsx(F,{className:"mr-2 h-4 w-4"}),"Move"]}),(0,a.jsxs)(l.z,{variant:"outline",size:"sm",children:[a.jsx(Z,{className:"mr-2 h-4 w-4"}),"Copy"]}),(0,a.jsxs)(c.aR,{children:[a.jsx(c.vW,{asChild:!0,children:(0,a.jsxs)(l.z,{variant:"destructive",size:"sm",children:[a.jsx(S.Z,{className:"mr-2 h-4 w-4"}),"Delete"]})}),(0,a.jsxs)(c._T,{children:[(0,a.jsxs)(c.fY,{children:[a.jsx(c.f$,{children:"Delete Files"}),(0,a.jsxs)(c.yT,{children:["Are you sure you want to delete ",L.size," selected items? This action cannot be undone."]})]}),(0,a.jsxs)(c.xo,{children:[a.jsx(c.le,{children:"Cancel"}),a.jsx(c.OL,{onClick:el,children:"Delete"})]})]})]}),(0,a.jsxs)(l.z,{variant:"outline",size:"sm",onClick:()=>Y(new Set),children:[a.jsx(D.Z,{className:"mr-2 h-4 w-4"}),"Clear"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[a.jsx("span",{className:"text-sm font-medium",children:"View:"}),(0,a.jsxs)("div",{className:"flex items-center border rounded-md",children:[a.jsx(l.z,{variant:"grid"===V?"default":"ghost",size:"sm",onClick:()=>E("grid"),className:"rounded-r-none",children:a.jsx(_.Z,{className:"h-4 w-4"})}),a.jsx(l.z,{variant:"list"===V?"default":"ghost",size:"sm",onClick:()=>E("list"),className:"rounded-none",children:a.jsx(q.Z,{className:"h-4 w-4"})}),a.jsx(l.z,{variant:"tree"===V?"default":"ghost",size:"sm",onClick:()=>E("tree"),className:"rounded-l-none",children:a.jsx(j,{className:"h-4 w-4"})})]})]}),(0,a.jsxs)("span",{className:"text-sm text-muted-foreground",children:[ec.length," items"]})]})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:["grid"===V?a.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:ec.map(e=>(0,a.jsxs)(r.Zb,{className:"overflow-hidden cursor-pointer hover:shadow-md transition-shadow",children:[(0,a.jsxs)("div",{className:"relative aspect-square bg-muted flex items-center justify-center",children:["file"===e.type&&e.mimeType?.startsWith("image/")&&e.url?a.jsx(T.default,{src:e.url,alt:e.name,fill:!0,className:"object-cover"}):a.jsx("div",{className:"text-muted-foreground",children:ed(e)}),a.jsx("div",{className:"absolute top-2 left-2",children:a.jsx(u.X,{checked:L.has(e.id),onCheckedChange:()=>en(e.id),className:"bg-background"})}),a.jsx("div",{className:"absolute top-2 right-2",children:a.jsx(l.z,{size:"sm",variant:"secondary",className:"h-8 w-8 p-0",children:a.jsx(P.Z,{className:"h-4 w-4"})})})]}),a.jsx(r.aY,{className:"p-4",children:(0,a.jsxs)("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-semibold truncate",children:e.name}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[a.jsx("span",{children:"file"===e.type&&e.size?eo(e.size):"Folder"}),a.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()})]})]})})]},e.id))}):a.jsx("div",{className:"space-y-2",children:ec.map(e=>a.jsx(r.Zb,{children:a.jsx(r.aY,{className:"p-4",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[a.jsx(u.X,{checked:L.has(e.id),onCheckedChange:()=>en(e.id)}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[ed(e),a.jsx("span",{className:"font-medium",children:e.name})]}),a.jsx("div",{className:"flex-1"}),(0,a.jsxs)("div",{className:"flex items-center space-x-4 text-sm text-muted-foreground",children:[a.jsx("span",{children:"file"===e.type&&e.size?eo(e.size):"Folder"}),a.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()}),a.jsx(l.z,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",children:a.jsx(P.Z,{className:"h-4 w-4"})})]})]})})},e.id))}),0===ec.length&&a.jsx(r.Zb,{children:(0,a.jsxs)(r.aY,{className:"flex flex-col items-center justify-center py-12",children:[a.jsx(j,{className:"h-12 w-12 text-muted-foreground mb-4"}),a.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No files found"}),a.jsx("p",{className:"text-muted-foreground text-center mb-4",children:U?"Try adjusting your search terms":"This directory is empty. Upload some files to get started."}),!U&&(0,a.jsxs)(l.z,{onClick:()=>G(!0),children:[a.jsx(M.Z,{className:"mr-2 h-4 w-4"}),"Upload Files"]})]})})]})]})})}},91207:(e,t,s)=>{"use strict";s.d(t,{OL:()=>f,_T:()=>u,aR:()=>n,f$:()=>h,fY:()=>m,le:()=>j,vW:()=>d,xo:()=>x,yT:()=>p});var a=s(97247);s(28964);var i=s(28980),r=s(25008),l=s(58053);function n({...e}){return a.jsx(i.fC,{"data-slot":"alert-dialog",...e})}function d({...e}){return a.jsx(i.xz,{"data-slot":"alert-dialog-trigger",...e})}function o({...e}){return a.jsx(i.h_,{"data-slot":"alert-dialog-portal",...e})}function c({className:e,...t}){return a.jsx(i.aV,{"data-slot":"alert-dialog-overlay",className:(0,r.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function u({className:e,...t}){return(0,a.jsxs)(o,{children:[a.jsx(c,{}),a.jsx(i.VY,{"data-slot":"alert-dialog-content",className:(0,r.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...t})]})}function m({className:e,...t}){return a.jsx("div",{"data-slot":"alert-dialog-header",className:(0,r.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function x({className:e,...t}){return a.jsx("div",{"data-slot":"alert-dialog-footer",className:(0,r.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function h({className:e,...t}){return a.jsx(i.Dx,{"data-slot":"alert-dialog-title",className:(0,r.cn)("text-lg font-semibold",e),...t})}function p({className:e,...t}){return a.jsx(i.dk,{"data-slot":"alert-dialog-description",className:(0,r.cn)("text-muted-foreground text-sm",e),...t})}function f({className:e,...t}){return a.jsx(i.aU,{className:(0,r.cn)((0,l.d)(),e),...t})}function j({className:e,...t}){return a.jsx(i.$j,{className:(0,r.cn)((0,l.d)({variant:"outline"}),e),...t})}},6274:(e,t,s)=>{"use strict";s.d(t,{X:()=>n});var a=s(97247),i=s(37830),r=s(48799),l=s(25008);function n({className:e,...t}){return a.jsx(i.fC,{"data-slot":"checkbox",className:(0,l.cn)("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:a.jsx(i.z$,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:a.jsx(r.Z,{className:"size-3.5"})})})}},98969:(e,t,s)=>{"use strict";s.d(t,{$N:()=>x,Be:()=>h,Vq:()=>n,cZ:()=>u,fK:()=>m,hg:()=>d});var a=s(97247),i=s(50400),r=s(37013),l=s(25008);function n({...e}){return a.jsx(i.fC,{"data-slot":"dialog",...e})}function d({...e}){return a.jsx(i.xz,{"data-slot":"dialog-trigger",...e})}function o({...e}){return a.jsx(i.h_,{"data-slot":"dialog-portal",...e})}function c({className:e,...t}){return a.jsx(i.aV,{"data-slot":"dialog-overlay",className:(0,l.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function u({className:e,children:t,showCloseButton:s=!0,...n}){return(0,a.jsxs)(o,{"data-slot":"dialog-portal",children:[a.jsx(c,{}),(0,a.jsxs)(i.VY,{"data-slot":"dialog-content",className:(0,l.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...n,children:[t,s&&(0,a.jsxs)(i.x8,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[a.jsx(r.Z,{}),a.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function m({className:e,...t}){return a.jsx("div",{"data-slot":"dialog-header",className:(0,l.cn)("flex flex-col gap-2 text-center sm:text-left",e),...t})}function x({className:e,...t}){return a.jsx(i.Dx,{"data-slot":"dialog-title",className:(0,l.cn)("text-lg leading-none font-semibold",e),...t})}function h({className:e,...t}){return a.jsx(i.dk,{"data-slot":"dialog-description",className:(0,l.cn)("text-muted-foreground text-sm",e),...t})}},10283:(e,t,s)=>{"use strict";s.d(t,{FL:()=>i});var a=s(28964);function i(e={}){let[t,s]=(0,a.useState)([]),[i,r]=(0,a.useState)(!1),[l,n]=(0,a.useState)(null),{maxFiles:d=10,maxSize:o=10485760,allowedTypes:c=["image/jpeg","image/png","image/webp","image/gif"],onProgress:u,onComplete:m,onError:x}=e,h=(0,a.useCallback)(e=>{let t=[],s=[];if(e.length>d)return s.push(`Maximum ${d} files allowed`),{valid:t,errors:s};for(let a of e){if(a.size>o){s.push(`${a.name}: File size exceeds ${Math.round(o/1024/1024)}MB limit`);continue}if(!c.includes(a.type)){s.push(`${a.name}: File type ${a.type} not allowed`);continue}t.push(a)}return{valid:t,errors:s}},[d,o,c]),p=(0,a.useCallback)(async(e,t)=>{let a=`${Date.now()}-${Math.random().toString(36).substring(2)}`,i={id:a,filename:e.name,progress:0,status:"uploading"};s(e=>[...e,i]),n(null);try{let i=setInterval(()=>{s(e=>e.map(e=>e.id===a&&e.progress<90?{...e,progress:Math.min(90,e.progress+20*Math.random())}:e))},200),r=new FormData;r.append("file",e),t&&r.append("key",t);let l=await fetch("/api/upload",{method:"POST",body:r});clearInterval(i);let n=await l.json();if(n.success)return s(e=>e.map(e=>e.id===a?{...e,progress:100,status:"complete",url:n.url}:e)),n;return s(e=>e.map(e=>e.id===a?{...e,status:"error",error:n.error}:e)),{success:!1,error:n.error||"Upload failed"}}catch(t){let e=t instanceof Error?t.message:"Upload failed";return s(t=>t.map(t=>t.id===a?{...t,status:"error",error:e}:t)),{success:!1,error:e}}},[]);return{uploadFiles:(0,a.useCallback)(async(e,s)=>{r(!0),n(null);try{let{valid:a,errors:i}=h(e);if(i.length>0){let e=i.join(", ");n(e),x?.(e);return}if(0===a.length){n("No valid files to upload"),x?.("No valid files to upload");return}let r=[];for(let e of a){let t=s?.keyPrefix?`${s.keyPrefix}/${Date.now()}-${e.name}`:void 0,a=await p(e,t);r.push(a)}let l=r.filter(e=>e.success).map(e=>({filename:a.find(t=>r.indexOf(e)===a.indexOf(t))?.name||"",url:e.url||"",key:e.key||"",size:a.find(t=>r.indexOf(e)===a.indexOf(t))?.size||0,mimeType:a.find(t=>r.indexOf(e)===a.indexOf(t))?.type||""})),d=r.map((e,t)=>({result:e,file:a[t]})).filter(({result:e})=>!e.success).map(({result:e,file:t})=>({filename:t.name,error:e.error||"Upload failed"})),o={successful:l,failed:d,total:a.length};m?.(o);let c=[...t];u?.(c)}catch(t){let e=t instanceof Error?t.message:"Upload failed";n(e),x?.(e)}finally{r(!1)}},[t,h,p,u,m,x]),uploadSingleFile:p,progress:t,isUploading:i,error:l,clearProgress:(0,a.useCallback)(()=>{s([]),n(null)},[]),removeFile:(0,a.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e))},[])}}},19389:(e,t,s)=>{"use strict";s.d(t,{Z:()=>a});let a=(0,s(26323).Z)("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]])},88179:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>d,metadata:()=>n});var a=s(72051),i=s(26269);let r=(0,s(45347).createProxy)(String.raw`/home/Nicholai/Documents/Dev/united_v03/united-tattoo/united-tattoo/components/admin/file-manager.tsx#FileManager`);var l=s(15487);let n={title:"File Manager | United Tattoo Admin",description:"Manage uploaded files and storage"};function d(){return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[a.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"File Manager"}),a.jsx("p",{className:"text-muted-foreground",children:"Manage uploaded files, organize storage, and monitor usage."})]}),a.jsx(i.Suspense,{fallback:a.jsx(l.TK,{}),children:a.jsx(r,{})})]})}},45298:(e,t,s)=>{"use strict";s.d(t,{D:()=>i});var a=s(28964);function i(e){let t=a.useRef({value:e,previous:e});return a.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}}};var t=require("../../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),a=t.X(0,[9379,8213,9234,4128,7598,9906,8472,6609,4486,8224,4926],()=>s(33830));module.exports=a})(); |