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

1 line
14 KiB
JavaScript
Raw Normal View History

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