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

1 line
14 KiB
JavaScript
Raw Normal View History

2024-12-15 11:57:19 +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}}})},67777:(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(49407),d=s(89600),c=s(8732),o=s(82015),u=s.n(o),m=s(95222),p=s(20048),x=s.n(p),h=s(84312),v=s(58548),f=s(21347);function y({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)(f.A,{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)(f.A,{userObject:e,setTargetUser:t},s+1))]})]})]})})}var j=s(63715),g=s(32415);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)(g.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,j.A)("/api/acceptUserInvitation",{method:"post",body:{...e}},!0).then(e=>{e.success&&(window.alert("Invitation Accepted!"),window.location.reload()),setTimeout(()=>{s(!1)},500)})},children:"Accept Invitation"})]},e.id)}function A(e){let{user:t,databases:s,pendingInvitations:a,pendingInvitationsReceived:i,adminUsers:r,invitedAccounts:n,setTargetUser:l}=u().useContext(w),[d,o]=u().useState(!1);return(0,c.jsxs)(u().Fragment,{children:[(0,c.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,c.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,c.jsx)("h1",{className:"text-3xl m-0",children:"Users"}),(0,c.jsxs)("a",{href:`/admin/${t?.id}/users/add-user`,className:"flex items-center gap-2 whitespace-normal button",children:[(0,c.jsx)("span",{className:"symbol",children:"+"}),(0,c.jsx)("span",{children:"Add New User"})]})]}),(0,c.jsx)(v.A,{user:t})]}),(0,c.jsxs)("div",{className:"w-full grid grid-cols-1 items-start justify-start",children:[(0,c.jsx)("div",{className:"flex-col items-stretch justify-start",children:(0,c.jsx)(y,{setTargetUser:l,user:t,adminUsers:r,invitedAccounts:n})}),(0,c.jsxs)("div",{className:"flex-col items-stretch justify-start",children:[a&&a[0]&&(0,c.jsx)(u().Fragment,{children:(0,c.jsx)("section",{className:"p-4 items-start gap-4 overflow-visible",children:(0,c.jsxs)("div",{className:"flex-col w-full items-start",children:[(0,c.jsx)("h2",{className:"text-xl m-0",children:"Invitations Sent"}),a.map((e,t)=>(0,c.jsxs)("div",{className:"bg-slate-100 px-4 py-2 rounded w-full justify-between",child