"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6946],{80443:(e,t,a)=>{a.d(t,{A:()=>o});var l=a(74848),s=a(96540),c=a(23698),i=a(45165),d=a(620),n=a(21458),r=a(41301);function o(e){var t,o;let{targetUser:u,user:h,setTargetUser:m}=e,p=a(49436);if(!u)return null;let[x,b]=s.useState(!0),[f,v]=s.useState([]),[y,g]=s.useState(!1),[k,j]=s.useState(u?null===(t=u.user_priviledge)||void 0===t?void 0:t.split("|"):[]),[A,w]=s.useState((null==u?void 0:u.database_access)?u.database_access.split("|"):[]),[_,N]=s.useState(u?null===(o=u.database_access)||void 0===o?void 0:o.split("|")[0]:null),[M,C]=s.useState([]),[E,S]=s.useState([]);return s.useEffect(()=>{(0,c.A)("/api/getUserDatabases").then(e=>{e.success&&v(e.databases)})},[]),s.useEffect(()=>{if(u){if(_)(0,c.A)("/api/getDatabaseTables?dbSlug=".concat(_,"&dbOwnerId=").concat(h.id,"&delegatedUserId=").concat(u.invited_user_id)).then(e=>{e.success&&(C(null),setTimeout(()=>{C([...e.tables])},200)),e.accessed_tables&&e.accessed_tables[0]&&!E[0]&&S(e.accessed_tables.map(e=>"".concat(e.database,"-").concat(e.table)))});else{var e;N((null===(e=u.database_access)||void 0===e?void 0:e.split("|")[0])||null)}}},[_]),s.useEffect(()=>{if(b(!0),u){var e,t;j((null===(e=u.user_priviledge)||void 0===e?void 0:e.split("|"))||[]),w((null===(t=u.database_access)||void 0===t?void 0:t.split("|"))||[])}setTimeout(()=>{b(!1)},500)},[u]),s.useEffect(()=>{N((null==A?void 0:A[0])||null)},[A]),(0,l.jsxs)(i.Ay,{title:"target-user-popup",closePopupDispatch:()=>{m(null)},children:[x&&(0,l.jsx)(d.A,{position:"relative"}),!x&&u&&(0,l.jsx)(s.Fragment,{children:(0,l.jsxs)("div",{className:"flex-col w-full items-start p-4",children:[(0,l.jsxs)("h4",{className:"m-0",children:["Edit ",u.first_name," ",u.last_name,"'s Access"]}),(0,l.jsx)("hr",{}),(0,l.jsxs)("form",{className:"flex flex-col items-start w-full",onSubmit:e=>{e.preventDefault(),b(!0),(0,c.A)("/api/updateAdminUserAccess",{method:"post",body:{userObject:u,user_priviledge:k.join("|"),database_access:null==A?void 0:A.join("|"),db_tables:A&&A[0]?E.join("|"):"",inv_user_id:u.invited_user_id}},!0).then(e=>{window.location.reload(),setTimeout(()=>{b(!1)},500)})},children:[(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-1 text-slate-600",children:"User Priviledges"}),(0,l.jsx)(n.A,{checkBoxValues:p.map(e=>({title:e,name:e,default:!!k.includes(e),onChangeHandler:t=>{k.includes(e)?j([...k.filter(t=>t!=e)]):j(t=>[...t,e])}})),smallText:!0,flexRow:!0}),(0,l.jsx)("hr",{className:"my-6"}),(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-2 text-slate-600",children:"Databases Access"}),(0,l.jsx)("span",{className:"button outlined gray px-4 py-1 -mt-1 mb-1.5",onClick:e=>{y?(f.forEach(e=>{setTimeout(()=>{let t=document.getElementById(e.db_slug);(null==t?void 0:t.checked)&&t.click()},200)}),g(!1)):(f.forEach(e=>{setTimeout(()=>{let t=document.getElementById(e.db_slug);t.checked||t.click()},200)}),g(!0))},children:y?"Deselect All":"Select All"}),(0,l.jsx)(n.A,{checkBoxValues:f.map(e=>({title:e.db_name,name:e.db_slug,onChangeHandler:t=>{A.includes(e.db_slug)?w([...A.filter(t=>t!=e.db_slug)]):w(t=>[...t,e.db_slug]),A.length===f.length?g(!0):g(!1)},default:!!A.includes(e.db_slug)})),smallText:!0,flexRow:!0}),A&&A[0]&&(0,l.jsxs)(s.Fragment,{children:[(0,l.jsx)("hr",{className:"my-6"}),(0,l.jsx)("h3",{className:"m-0 text-lg font-semibold mb-2 text-slate-600",children:"Database Tables"}),(0,l.jsx)(r.A,{required:!0,selectOptions:f.filter(e=>A.includes(e.db_slug)).map(e=>({title:e.db_name,payload:e.db_slug})),name:"databases",onChangeHandler:e=>{N(e.target.value)}}),(0,l.jsx)("div",{className:"h-2"}),M&&M[0]&&(0,l.jsx)(n.A,{checkBoxValues:M.map(e=>({title:e.table_name,name:e.table_slug,onChangeHandler:t=>{E.includes("".concat(_,"-").concat(e.table_slug))?S([...E.filter(t=>t!="".concat(_,"-").concat(e.table_slug))]):S(t=>[...t,"".concat(_,"-").concat(e.table_slug)])},default:!!E.includes("".concat(_,"-").concat(e.table_slug))})),smallText:!0,flexRow:!0})]}),(0,l.jsx)("button",{className:"mt-4 w-full",children:"Update User Access"})]})]})})]})}},21458:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(74848);function s(e){let{name:t,checkBoxValues:a,setAlert:s,labelColor:c,flexRow:i,baseText:d,smallText:n,className:r}=e;return(0,l.jsx)("div",{className:"flex items-start gap-x-4"+(i?" flex-row flex-wrap gap-y-2 ":" flex-col gap-y-4 ")+(r||""),children:a.map((e,a)=>{let{payload:i,title:r,onChangeHandler:o,fixed:u,jsx:h}=e,m=e.name?"".concat(t,"-").concat(e.name):i?t+"-"+i:t;return(0,l.jsxs)("div",{className:"flex items-center"+(e.default&&u?" pointer-events-none":"")+(n?" gap-1 ":" gap-2 ")+((null==e?void 0:e.className)?e.className:""),children:[(0,l.jsx)("input",{className:"m-0"+(n?" w-4 h-4":" w-5 h-5"),type:"checkbox",defaultChecked:!!e.default,name:m,id:m,onChange:t=>{s&&s(null),o&&o(t,e)},value:i,style:{minWidth:"20px"},...e.props}),h||(0,l.jsx)("label",{htmlFor:m,className:"m-0 "+(c||"text-slate-800 dark:text-white/80")+(d||n?" text-base":" text-lg"),children:r})]},a+1)})})}a(96540)},41301:(e,t,a)=>{a.d(t,{A:()=>c});var l=a(74848),s=a(62027);function c(e){let{selectOptions:t,name:a,onChangeHandler:c,required:i,setAlert:d,title:n,defaultValue:r,info:o,id:u}=e;try{function h(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),a=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!a.classList.contains("hidden")){a.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&a.classList.contains("hidden"))){if(!t){a.classList.add("hidden");return}if(a.classList.contains("hidden")){a.classList.remove("hidden");return}a.classList.add("hidden")}}return(0,l.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(o?" pr-8":""),children:[n&&(0,l.jsxs)("label",{htmlFor:a,children:[n,i?"":" (optional)"]}),(0,l.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,l.jsx)("select",{name:a,id:u||a,className:"w-full bg-white",required:i,onChange:e=>{d&&d(null),e.target.classList.remove("warning"),c&&c(e)},defaultValue:r||void 0,children:t.map((e,t)=>{let{payload:a,title:s}=e;return(0,l.jsx)("option",{value:a,selected:!!e.default,children:s},t+1)})}),(0,l.jsx)(s.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),o&&(0,l.jsxs)("div",{className:"info-wrapper absolute -right-10 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:h,onMouseLeave:h,onClick:h,children:[(0,l.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,l.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,l.jsx)("span",{children:o})}),(0,l.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,l.jsx)("div",{children:"Form Select Error"})}}a(96540)},34181:(e,t,a)=>{var l=a(24994);t.A=void 0;var s=l(a(44888)),c=a(74848);t.A=(0,s.default)([(0,c.jsx)("path",{d:"M22 15c0-1.66-1.34-3-3-3h-1.5v-.5C17.5 8.46 15.04 6 12 6c-.77 0-1.49.17-2.16.46L20.79 17.4c.73-.55 1.21-1.41 1.21-2.4M2 14c0 2.21 1.79 4 4 4h9.73l-8-8H6c-2.21 0-4 1.79-4 4",opacity:".3"},"0"),(0,c.jsx)("path",{d:"M19.35 10.04C18.67 6.59 15.64 4 12 4c-1.33 0-2.57.36-3.65.97l1.49 1.49C10.51 6.17 11.23 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3 0 .99-.48 1.85-1.21 2.4l1.41 1.41c1.09-.92 1.8-2.27 1.8-3.81 0-2.64-2.05-4.78-4.65-4.96M3 5.27l2.77 2.77h-.42C2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h11.73l2 2 1.41-1.41L4.41 3.86zM7.73 10l8 8H6c-2.21 0-4-1.79-4-4s1.79-4 4-4z"},"1")],"CloudOffTwoTone")},45014:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20",key:"t4utmx"}],["path",{d:"M8 7h6",key:"1f0q6e"}],["path",{d:"M8 11h8",key:"vwpz6n"}]])},59140:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},2894:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]])},79508:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},79753:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]])},1915:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]])},87273:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},5922:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("ShieldEllipsis",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]])},76897:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(95737).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},49436:e=>{e.exports=JSON.parse('["Edit Tables","Update Entries","Create Table","Delete Entries","Delete Tables"]')}}]);