dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/media.js

1 line
4.9 KiB
JavaScript
Raw Normal View History

2025-01-13 08:00:21 +00:00
"use strict";(()=>{var e={};e.id=9326,e.ids=[9326],e.modules={37750:(e,t,s)=>{s.r(t),s.d(t,{config:()=>I,default:()=>V,getServerSideProps:()=>H,getStaticPaths:()=>k,getStaticProps:()=>R,reportWebVitals:()=>W,routeModule:()=>G,unstable_getServerProps:()=>Q,unstable_getServerSideProps:()=>U,unstable_getStaticParams:()=>O,unstable_getStaticPaths:()=>$,unstable_getStaticProps:()=>B});var r={};s.r(r),s.d(r,{MediaContext:()=>L,default:()=>T,getServerSideProps:()=>D});var a=s(63865),i=s(9455),n=s(30671),d=s(5583),l=s(19796),o=s(8732),u=s(82015),c=s.n(u),p=s(29021),x=s.n(p),m=s(25562),g=s(92702),S=s(53926),j=s(91140),h=s(66485),f=s(91692),b=s(55904);function P(){let{media:e,setTargetMedia:t,user:s,folders:r,staticHost:a}=c().useContext(L);return(0,o.jsxs)(c().Fragment,{children:[(0,o.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,o.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,o.jsx)("h1",{className:"text-3xl m-0",children:"Media"}),(0,o.jsxs)(b.A,{children:[(0,o.jsxs)("button",{className:"flex items-center gap-2",onClick:e=>{(0,j.PB)("choose-media-type-popoup")},children:[(0,o.jsx)("span",{className:"symbol",children:"+"}),(0,o.jsx)("span",{children:"Add Media"})]}),(0,o.jsxs)("button",{className:"flex items-center gap-2 outlined gray",onClick:e=>{(0,j.PB)("add-folder-popoup")},children:[(0,o.jsx)("span",{className:"symbol",children:"+"}),(0,o.jsx)("span",{children:"Add Folder"})]})]})]}),(0,o.jsx)(S.A,{user:s})]}),s?.verification_status?.toString().match(/1/)?(0,o.jsxs)(c().Fragment,{children:[(0,o.jsx)(f.A,{media:e,setTargetMedia:t,folders:r,staticHost:a,user:s}),e&&e[0]&&(0,o.jsxs)("a",{className:"border-dotted border-slate-400 border-2 px-4 py-3 w-full rounded flex items-center hover:border-primary/50 gap-2 cursor-pointer justify-center",onClick:e=>{(0,j.PB)("choose-media-type-popoup")},children:[(0,o.jsx)("span",{className:"symbol",children:"+"}),(0,o.jsx)("span",{className:"",children:"Add Media"})]})]}):(0,o.jsx)(h.A,{})]})}var M=s(81145),A=s(87081),v=s(14865),_=s(94198),N=s(43430),w=s(67325),q=s(16757),y=s(71934),F=s(33873),C=s.n(F),E=s(10839);let L=c().createContext({});function T({user:e,media:t,folders:s,staticHost:r}){let a=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,o.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[i,n]=c().useState(null),[d,l]=c().useState(null),[u,p]=c().useState(null),[x,g]=c().useState(!1),[S,j]=c().useState(null);return(0,o.jsx)(L.Provider,{value:{user:e,media:t,targetMedia:S,setTargetMedia:j,folders:s,staticHost:r},children:(0,o.jsxs)(c().Fragment,{children:[(0,o.jsxs)(m.A,{head:a,user:e,children:[x&&(0,o.jsx)(q.A,{screen:!0,title:"Processing Files ..."}),(0,o.jsx)(P,{}),(0,o.jsx)(M.A,{setNewMedia:n,setLoading:g}),(0,o.jsx)(N.A,{setNewFile:l,setLoading:g}),(0,o.jsx)(E.A,{setNewVideo:p,setLoading:g})]}),(0,o.jsx)(A.A,{newMedia:i,setNewMedia:n,newFile:d,setNewFile:l,newVideo:u,setNewVideo:p}),(0,o.jsx)(v.A,{targetMedia:S,setTargetMedia:j,staticHost:r,media:t}),(0,o.jsx)(_.A,{}),(0,o.jsx)(w.A,{user:e})]})})}async function D({req:e,res:t,query:s}){let r=await (0,g.default)(e,t);if(!r?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let a=await (0,y.A)(`SELECT * FROM user_media WHERE user_id='${r.id}' AND folder IS NULL`),i=process.env.DSQL_STATIC_SERVER_DIR;if(!i)return console.log("Static File ENV not Found!"),{redirect:{destination:"/admin",permanent:!1}};let n=C().join(i,`images/user-images/user-${r.id}/`);return x().existsSync(n)?{props:{user:r,media:a,folders:x().readdirSync(n).filter(e=>!e.match(/\..{3,4}$/)),staticHost:process.env.DSQL_STATIC_HOST||""}}:{redirect:{destination:"/admin",permanent:!1}}}let V=(0,n.M)(r,"default"),R=(0,n.M)(r,"getStaticProps"),k=(0,n.M)(r,"getStaticPaths"),H=(0,n.M)(r,"getServerSideProps"),I=(0,n.M)(r,"config"),W=(0,n.M)(r,"reportWebVitals"),B=(0,n.M)(r,"unstable_getStaticProps"),$=(0,n.M)(r,"unstable_getStaticPaths"),O=(0,n.M)(r,"unstable_getStaticParams"),Q=(0,n.M)(r,"unstable_getServerProps"),U=(0,n.M)(r,"unst