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

1 line
15 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
"use strict";(()=>{var e={};e.id=5662,e.ids=[5662],e.modules={30671:(e,s)=>{Object.defineProperty(s,"M",{enumerable:!0,get:function(){return function e(s,t){return t in s?s[t]:"then"in s&&"function"==typeof s.then?s.then(s=>e(s,t)):"function"==typeof s&&"default"===t?s:void 0}}})},63425:(e,s,t)=>{t.r(s),t.d(s,{config:()=>L,default:()=>E,getServerSideProps:()=>M,getStaticPaths:()=>k,getStaticProps:()=>P,reportWebVitals:()=>O,routeModule:()=>B,unstable_getServerProps:()=>T,unstable_getServerSideProps:()=>q,unstable_getStaticParams:()=>U,unstable_getStaticPaths:()=>C,unstable_getStaticProps:()=>R});var a={};t.r(a),t.d(a,{UsersContext:()=>b,default:()=>w,getServerSideProps:()=>D});var r=t(63865),i=t(9455),n=t(30671),l=t(5583),c=t(19796),d=t(8732),o=t(82015),u=t.n(o),m=t(25562),p=t(92702),h=t(55954),x=t(53926),v=t(91140),f=t(46169),_=t(16757),y=t(55904);function g({userObject:e,setTargetUser:s,paradigm:t}){let a=t?.match(/invited/)?`${e.inviteeFirstName} ${e.inviteeLastName} (${e.inviteeEmail})`:`${e.first_name} ${e.last_name} (${e.email})`,r=t?.match(/invited/)?`${e.inviteeImage}`:`${e.image_thumbnail}`,[i,n]=u().useState(!1);return(0,d.jsxs)("div",{className:"card no-hover items-center "+(t?.match(/invited/)?" green green-bg":" primary"),children:[i&&(0,d.jsx)(_.A,{}),(0,d.jsxs)("div",{className:"w-full",children:[(0,d.jsx)("img",{src:r,className:"w-8 h-8 rounded-full object-cover bg-slate-200",onError:e=>{e.target.src="/images/user-preset-thumbnail.png"}}),(0,d.jsx)("span",{className:"text-sm font-semibold",children:a}),e?.user_priviledge?.match(/./)&&(0,d.jsxs)("span",{className:"text-sm ml-auto text-slate-900/50",children:["Priviledges:"," ",(0,d.jsx)("span",{className:"text-slate-600 font-semibold",children:e.user_priviledge.split("|").join(" | ")})]}),!t?.match(/invited/)&&(0,d.jsx)(u().Fragment,{children:(0,d.jsxs)(y.A,{children:[(0,d.jsx)("button",{className:"outlined text-xs px-3 py-1",onClick:t=>{s(e),setTimeout(()=>{(0,v.PB)("target-user-popup")},200)},children:"Edit User Access"}),(0,d.jsx)("button",{className:"outlined text-xs px-3 py-1",onClick:s=>{n(!0),window.confirm("Delete this user")&&(0,f.A)("/api/deleteUserUser",{method:"post",body:{...e}},!0).then(e=>{setTimeout(()=>{n(!1)},500),window.location.reload()})},children:"Delete User"})]})})]})]})}function j({user:e,setTargetUser:s,users:t,adminUsers:a,invitedAccounts:r}){return(0,d.jsx)(u().Fragment,{children:(0,d.jsxs)("section",{className:"paper",children:[(0,d.jsx)("h2",{className:"text-xl m-0",children:"Users List"}),(0,d.jsxs)("div",{className:"card no-hover items-center w-full justify-between",children:[(0,d.jsxs)("div",{className:"gap-2",children:[(0,d.jsx)("div",{className:"w-10 h-10 rounded-full overflow-hidden",children:(0,d.jsx)("img",{src:e.image_thumbnail,alt:"Main User Image",width:40,className:"w-full h-full object-cover"})}),(0,d.jsxs)("span",{className:"font-semibold",children:[e.first_name," ",e.last_name]})]}),(0,d.jsx)("span",{className:"text-sm font-semibold",children:"Super User (Owner)"})]}),(0,d.jsxs)("div",{className:"w-full flex-col items-stretch",children:[r&&r[0]&&(0,d.jsxs)(u().Fragment,{children:[(0,d.jsx)("h4",{className:"m-0 text-sm font-semibold text-slate-400",children:"Accounts that Invited you"}),r.map((e,t)=>(0,d.jsx)(g,{userObject:e,setTargetUser:s,paradigm:"invited"},t+1))]}),a&&a[0]&&(0,d.jsxs)(u().Fragment,{children:[(0,d.jsx)("h4",{className:"m-0 text-sm font-semibold text-slate-400",children:"Accounts you Invited"}),a.map((e,t)=>(0,d.jsx)(g,{userObject:e,setTargetUser:s},t+1))]})]})]})})}function A({invitationObject:e}){let[s,t]=u().useState(!1);return(0,d.jsxs)("div",{className:"bg-slate-100 px-4 py-2 rounded w-full justify-between relative",children:[s&&(0,d.jsx)(_.A,{width:"20px"}),(0,d.jsxs)("span",{className:"text-sm font-semibold",children:[e.first_name," ",e.last_name," (",e.email,")"]}),(0,d.jsx)("button",{className:"py-1.5 px-3 text-sm secondary",onClick:s=>{t(!0),(0,f.A)("/api/acceptUserInvitation",{method:"post",body:{...e}},!0).then(e=>{e.success&&(window.alert("Invitation Accepted!"),window.location.re