"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3857],{443:(e,t,a)=>{a.d(t,{A:()=>o});var l=a(4848),s=a(6540),i=a(3698),n=a(5165),c=a(620),d=a(1458),r=a(1301);function o(e){var t,o;let{targetUser:u,user:h,setTargetUser:m}=e,p=a(9436);if(!u)return null;let[x,b]=s.useState(!0),[f,y]=s.useState([]),[v,g]=s.useState(!1),[k,A]=s.useState(u?null===(t=u.user_priviledge)||void 0===t?void 0:t.split("|"):[]),[j,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,E]=s.useState([]),[S,C]=s.useState([]);return s.useEffect(()=>{(0,i.A)("/api/getUserDatabases").then(e=>{e.success&&y(e.databases)})},[]),s.useEffect(()=>{if(u){if(_)(0,i.A)("/api/getDatabaseTables?dbSlug=".concat(_,"&dbOwnerId=").concat(h.id,"&delegatedUserId=").concat(u.invited_user_id)).then(e=>{e.success&&(E(null),setTimeout(()=>{E([...e.tables])},200)),e.accessed_tables&&e.accessed_tables[0]&&!S[0]&&C(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;A((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==j?void 0:j[0])||null)},[j]),(0,l.jsxs)(n.Ay,{title:"target-user-popup",closePopupDispatch:()=>{m(null)},children:[x&&(0,l.jsx)(c.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,i.A)("/api/updateAdminUserAccess",{method:"post",body:{userObject:u,user_priviledge:k.join("|"),database_access:null==j?void 0:j.join("|"),db_tables:j&&j[0]?S.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)(d.A,{checkBoxValues:p.map(e=>({title:e,name:e,default:!!k.includes(e),onChangeHandler:t=>{k.includes(e)?A([...k.filter(t=>t!=e)]):A(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=>{v?(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:v?"Deselect All":"Select All"}),(0,l.jsx)(d.A,{checkBoxValues:f.map(e=>({title:e.db_name,name:e.db_slug,onChangeHandler:t=>{j.includes(e.db_slug)?w([...j.filter(t=>t!=e.db_slug)]):w(t=>[...t,e.db_slug]),j.length===f.length?g(!0):g(!1)},default:!!j.includes(e.db_slug)})),smallText:!0,flexRow:!0}),j&&j[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=>j.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)(d.A,{checkBoxValues:M.map(e=>({title:e.table_name,name:e.table_slug,onChangeHandler:t=>{S.includes("".concat(_,"-").concat(e.table_slug))?C([...S.filter(t=>t!="".concat(_,"-").concat(e.table_slug))]):C(t=>[...t,"".concat(_,"-").concat(e.table_slug)])},default:!!S.includes("".concat(_,"-").concat(e.table_slug))})),smallText:!0,flexRow:!0})]}),(0,l.jsx)("button",{className:"mt-4 w-full",children:"Update User Access"})]})]})})]})}},1458:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(4848);function s(e){let{name:t,checkBoxValues:a,setAlert:s,labelColor:i,flexRow:n,baseText:c,smallText:d,className:r}=e;return(0,l.jsx)("div",{className:"flex items-start gap-x-4"+(n?" flex-row flex-wrap gap-y-2 ":" flex-col gap-y-4 ")+(r||""),children:a.map((e,a)=>{let{payload:n,title:r,onChangeHandler:o,fixed:u,jsx:h}=e,m=e.name?"".concat(t,"-").concat(e.name):n?t+"-"+n:t;return(0,l.jsxs)("div",{className:"flex items-center"+(e.default&&u?" pointer-events-none":"")+(d?" gap-1 ":" gap-2 ")+((null==e?void 0:e.className)?e.className:""),children:[(0,l.jsx)("input",{className:"m-0"+(d?" 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:n,style:{minWidth:"20px"},...e.props}),h||(0,l.jsx)("label",{htmlFor:m,className:"m-0 "+(i||"text-slate-800 dark:text-white/80")+(c||d?" text-base":" text-lg"),children:r})]},a+1)})})}a(6540)},1301:(e,t,a)=>{a.d(t,{A:()=>i});var l=a(4848),s=a(2027);function i(e){let{selectOptions:t,name:a,onChangeHandler:i,required:n,setAlert:c,title:d,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:[d&&(0,l.jsxs)("label",{htmlFor:a,children:[d,n?"":" (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:n,onChange:e=>{c&&c(null),e.target.classList.remove("warning"),i&&i(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(6540)},7216:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(5737).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},5014:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(5737).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"}]])},9140:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(5737).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(5737).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"}]])},9508:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(5737).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"}]])},9753:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(5737).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(5737).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"}]])},7273:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(5737).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(5737).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"}]])},6897:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(5737).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},9436:e=>{e.exports=JSON.parse('["Edit Tables","Update Entries","Create Table","Delete Entries","Delete Tables"]')}}]);