1 line
6.1 KiB
JavaScript
1 line
6.1 KiB
JavaScript
"use strict";exports.id=4312,exports.ids=[4312],exports.modules={84312:(e,s,t)=>{t.d(s,{A:()=>u});var l=t(8732),a=t(82015),n=t.n(a),i=t(63715),r=t(55158),d=t(32415),c=t(58403),o=t(51548);function u({targetUser:e,user:s,setTargetUser:a}){let u=t(49436);if(!e)return null;let[m,h]=n().useState(!0),[x,p]=n().useState([]),[b,f]=n().useState(!1),[g,j]=n().useState(e?e.user_priviledge?.split("|"):[]),[v,w]=n().useState(e?.database_access?e.database_access.split("|"):[]),[_,N]=n().useState(e?e.database_access?.split("|")[0]:null),[y,A]=n().useState([]),[k,S]=n().useState([]);return(0,l.jsxs)(r.Ay,{title:"target-user-popup",closePopupDispatch:()=>{a(null)},children:[m&&(0,l.jsx)(d.A,{position:"relative"}),!m&&e&&(0,l.jsx)(n().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 ",e.first_name," ",e.last_name,"'s Access"]}),(0,l.jsx)("hr",{}),(0,l.jsxs)("form",{className:"flex flex-col items-start w-full",onSubmit:s=>{s.preventDefault(),h(!0),(0,i.A)("/api/updateAdminUserAccess",{method:"post",body:{userObject:e,user_priviledge:g.join("|"),database_access:v?.join("|"),db_tables:v&&v[0]?k.join("|"):"",inv_user_id:e.invited_user_id}},!0).then(e=>{window.location.reload(),setTimeout(()=>{h(!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)(c.A,{checkBoxValues:u.map(e=>({title:e,name:e,default:!!g.includes(e),onChangeHandler:s=>{g.includes(e)?j([...g.filter(s=>s!=e)]):j(s=>[...s,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=>{b?(x.forEach(e=>{setTimeout(()=>{let s=document.getElementById(e.db_slug);s?.checked&&s.click()},200)}),f(!1)):(x.forEach(e=>{setTimeout(()=>{let s=document.getElementById(e.db_slug);s.checked||s.click()},200)}),f(!0))},children:b?"Deselect All":"Select All"}),(0,l.jsx)(c.A,{checkBoxValues:x.map(e=>({title:e.db_name,name:e.db_slug,onChangeHandler:s=>{v.includes(e.db_slug)?w([...v.filter(s=>s!=e.db_slug)]):w(s=>[...s,e.db_slug]),v.length===x.length?f(!0):f(!1)},default:!!v.includes(e.db_slug)})),smallText:!0,flexRow:!0}),v&&v[0]&&(0,l.jsxs)(n().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)(o.A,{required:!0,selectOptions:x.filter(e=>v.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"}),y&&y[0]&&(0,l.jsx)(c.A,{checkBoxValues:y.map(e=>({title:e.table_name,name:e.table_slug,onChangeHandler:s=>{k.includes(`${_}-${e.table_slug}`)?S([...k.filter(s=>s!=`${_}-${e.table_slug}`)]):S(s=>[...s,`${_}-${e.table_slug}`])},default:!!k.includes(`${_}-${e.table_slug}`)})),smallText:!0,flexRow:!0})]}),(0,l.jsx)("button",{className:"mt-4 w-full",children:"Update User Access"})]})]})})]})}},58403:(e,s,t)=>{t.d(s,{A:()=>a});var l=t(8732);function a({name:e,checkBoxValues:s,setAlert:t,labelColor:a,flexRow:n,baseText:i,smallText:r,className:d}){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 ")+(d||""),children:s.map((s,n)=>{let{payload:d,title:c,onChangeHandler:o,fixed:u,jsx:m}=s,h=s.name?`${e}-${s.name}`:d?e+"-"+d:e;return(0,l.jsxs)("div",{className:"flex items-center"+(s.default&&u?" pointer-events-none":"")+(r?" gap-1 ":" gap-2 ")+(s?.className?s.className:""),children:[(0,l.jsx)("input",{className:"m-0"+(r?" w-4 h-4":" w-5 h-5"),type:"checkbox",defaultChecked:!!s.default,name:h,id:h,onChange:e=>{t&&t(null),o&&o(e,s)},value:d,style:{minWidth:"20px"},...s.props}),m||(0,l.jsx)("label",{htmlFor:h,className:"m-0 "+(a||"text-slate-800 dark:text-white/80")+(i||r?" text-base":" text-lg"),children:c})]},n+1)})})}t(82015)},51548:(e,s,t)=>{t.d(s,{A:()=>n});var l=t(8732),a=t(58526);function n({selectOptions:e,name:s,onChangeHandler:t,required:n,setAlert:i,title:r,defaultValue:d,info:c,id:o}){try{function u(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let s=e.target.closest(".info-wrapper"),t=s.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!t.classList.contains("hidden")){t.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&t.classList.contains("hidden"))){if(!s){t.classList.add("hidden");return}if(t.classList.contains("hidden")){t.classList.remove("hidden");return}t.classList.add("hidden")}}return(0,l.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(c?" pr-8":""),children:[r&&(0,l.jsxs)("label",{htmlFor:s,children:[r,n?"":" (optional)"]}),(0,l.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,l.jsx)("select",{name:s,id:o||s,className:"w-full bg-white",required:n,onChange:e=>{i&&i(null),e.target.classList.remove("warning"),t&&t(e)},defaultValue:d||void 0,children:e.map((e,s)=>{let{payload:t,title:a}=e;return(0,l.jsx)("option",{value:t,selected:!!e.default,children:a},s+1)})}),(0,l.jsx)(a.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),c&&(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:u,onMouseLeave:u,onClick:u,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:c})}),(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"})}}t(82015)},49436:e=>{e.exports=JSON.parse('["Edit Tables","Update Entries","Create Table","Delete Entries","Delete Tables"]')}}; |