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

1 line
6.6 KiB
JavaScript
Raw Normal View History

2024-12-08 19:56:57 +00:00
"use strict";(()=>{var e={};e.id=9326,e.ids=[636,9326],e.modules={53088:(e,r,t)=>{t.r(r),t.d(r,{config:()=>W,default:()=>V,getServerSideProps:()=>H,getStaticPaths:()=>I,getStaticProps:()=>k,reportWebVitals:()=>U,routeModule:()=>G,unstable_getServerProps:()=>Q,unstable_getServerSideProps:()=>z,unstable_getStaticParams:()=>O,unstable_getStaticPaths:()=>$,unstable_getStaticProps:()=>B});var s={};t.r(s),t.d(s,{MediaContext:()=>D,default:()=>L,getServerSideProps:()=>R});var i=t(63865),u=t(9455),a=t(30671),o=t(49407),l=t(68268),n=t(8732),d=t(82015),p=t.n(d),c=t(95222),m=t(20048),x=t.n(m),g=t(58548),q=t(55158),S=t(24671),h=t(2628),f=t(62506);function j(e){let{media:r,setTargetMedia:t,user:s,folders:i,staticHost:u}=p().useContext(D);return(0,n.jsxs)(p().Fragment,{children:[(0,n.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,n.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,n.jsx)("h1",{className:"text-3xl m-0",children:"Media"}),(0,n.jsxs)(f.A,{children:[(0,n.jsxs)("button",{className:"flex items-center gap-2",onClick:e=>{(0,q.PB)("choose-media-type-popoup")},children:[(0,n.jsx)("span",{className:"symbol",children:"+"}),(0,n.jsx)("span",{children:"Add Media"})]}),(0,n.jsxs)("button",{className:"flex items-center gap-2 outlined gray",onClick:e=>{(0,q.PB)("add-folder-popoup")},children:[(0,n.jsx)("span",{className:"symbol",children:"+"}),(0,n.jsx)("span",{children:"Add Folder"})]})]})]}),(0,n.jsx)(g.A,{user:s})]}),s?.verification_status?.toString().match(/1/)?(0,n.jsxs)(p().Fragment,{children:[(0,n.jsx)(h.A,{media:r,setTargetMedia:t,folders:i,staticHost:u,user:s}),r&&r[0]&&(0,n.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,q.PB)("choose-media-type-popoup")},children:[(0,n.jsx)("span",{className:"symbol",children:"+"}),(0,n.jsx)("span",{className:"",children:"Add Media"})]})]}):(0,n.jsx)(S.A,{})]})}var y=t(83531),P=t(90194),b=t(70161),M=t(30180),v=t(31700),A=t(73413),_=t(32415),w=t(67216),N=t.n(w),C=t(33873),F=t.n(C),E=t(65693);let T=t(29021),D=p().createContext({});function L({user:e,media:r,folders:t,staticHost:s}){let i=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("title",{children:"User Dashboard | Datasquirel"}),(0,n.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[u,a]=p().useState(null),[o,l]=p().useState(null),[d,m]=p().useState(null),[x,g]=p().useState(!1),[q,S]=p().useState(null);return(0,n.jsx)(c.A,{head:i,user:e,children:(0,n.jsxs)(D.Provider,{value:{user:e,media:r,targetMedia:q,setTargetMedia:S,folders:t,staticHost:s},children:[x&&(0,n.jsx)(_.A,{screen:!0,title:"Processing Files ..."}),(0,n.jsx)(j,{}),(0,n.jsx)(y.A,{setNewMedia:a,setLoading:g}),(0,n.jsx)(v.A,{setNewFile:l,setLoading:g}),(0,n.jsx)(E.A,{setNewVideo:m,setLoading:g}),(0,n.jsx)(P.A,{newMedia:u,setNewMedia:a,newFile:o,setNewFile:l,newVideo:d,setNewVideo:m}),(0,n.jsx)(b.A,{targetMedia:q,setTargetMedia:S,staticHost:s,media:r}),(0,n.jsx)(M.A,{}),(0,n.jsx)(A.A,{user:e})]})})}async function R({req:e,res:r,query:t}){let s=await x()(e,r);if(!s?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let i=await N()(`SELECT * FROM user_media WHERE user_id='${s.id}' AND folder IS NULL`),u=process.env.DSQL_STATIC_SERVER_DIR;if(!u)return console.log("Static File ENV not Found!"),{redirect:{destination:"/admin",permanent:!1}};let a=F().join(u,`images/user-images/user-${s.id}/`);return T.existsSync(a)?{props:{user:s,media:i,folders:T.readdirSync(a).filter(e=>!e.match(/\..{3,4}$/)),staticHost:process.env.DSQL_STATIC_HOST||""}}:{redirect:{destination:"/admin",permanent:!1}}}let V=(0,a.M)(s,"default"),k=(0,a.M)(s,"getStaticProps"),I=(0,a.M)(s,"getStaticPaths"),H=(0,a.M)(s,"getServerSideProps"),W=(0,a.M)(s,"config"),U=(0,a.M)(s,"reportWebVitals"),B=(0,a.M)(s,"unstable_getStaticProps"),$=(0,a.M)(s,"unstable_getStaticPaths"),O=(0,a.M)(s,"unstable_getStaticParams"),Q=(0,a.M)(s,"unstable_getServerProps"),z=(0,a.M)(s,"unstable_getServerSideProps"),G=new i.PagesRou