Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.226.34.148
import{v as U,E as p,x as T,r as d,t as e,D as k,B as g,L as M,G as _}from"./index-D91i0Taj.js";import{g as C}from"./Usertype-DbWwb-bh.js";import{S as D}from"./index-D6UqdOPV.js";import{R as I}from"./StopOutlined-PKxWs7xm.js";import{R as v}from"./SaveOutlined-BTVxBu3f.js";import{R as w}from"./HomeOutlined-spX06zJ_.js";import{R as h,C as S}from"./row-CNxfkkwo.js";import{C as j}from"./index-DkAH2Jx9.js";import"./responsiveObserver-D2HThzTQ.js";import"./index-DdVV4GJm.js";const N=t=>async(r,l)=>{try{r({type:"SET_LOADER"});const a=l();let i=localStorage.getItem("dbname");const n=await U.get("app.php?a=qpAssignUserMenu&db="+i+"&usertype="+t+"&user="+a.loginfo.userData.fusertypedesc);r({type:"UNSET_LOADER"}),n.data.error_code===0?r({type:"GET_ASSIGN_USER_MENUS",payload:n.data.data}):r({type:"GET_ASSIGN_USER_MENUS",payload:[]})}catch(a){p("error",a.message)}},L=t=>async(r,l)=>{try{r({type:"SET_LOADER"});const a=l();let i=localStorage.getItem("dbname");const n=await U.post("app.php?a=saveQpAssignUserRight&db="+i,t);r({type:"UNSET_LOADER"}),n.data.error_code===0?p("success",n.data.data.msg):p("info",n.data.data.msg)}catch(a){p("error",a.message)}},G=t=>{const[r,l]=d.useState([]),[a,i]=d.useState(""),[n,E]=d.useState(!1);d.useEffect(()=>{t.getUsertypeData()},[]),d.useEffect(()=>{l(t.menuItems)},[t.menuItems]);const b=()=>{if(a===""){p("info","select usertype");return}t.getAssignUserMenus(a),E(!0)},y=(s,o,c,u,f)=>{const m=r;f==="submenu"?(m[s].submenu[o].fstatus=u.target.checked?"T":"F",m[s].fstatus="T"):(m[s].fstatus=u.target.checked?"T":"F",m[s].submenu.map((x,B)=>(u.target.checked?x.fstatus="T":x.fstatus="F",x))),l([...m])},R=()=>{const s=new FormData;s.append("fuser",a),s.append("data",JSON.stringify(r)),t.saveAssignUserMenus(s)},A=t.usertype.map((s,o)=>({key:o,value:s.fusertype,label:s.fdescpn}));return e.jsxs(k,{style:{margin:"6rem 10px 10px"},title:e.jsx("h6",{children:"Assign User Menus"}),extra:e.jsxs(D,{children:[e.jsxs(g,{style:{background:"black",color:"white"},onClick:()=>window.location.reload(),children:[e.jsx(I,{})," Clear"]}),e.jsxs(g,{type:"primary",onClick:()=>R(),children:[e.jsx(v,{})," Save"]}),e.jsx(M,{to:"/",children:e.jsxs(g,{type:"primary",danger:!0,children:[e.jsx(w,{})," Exit"]})})]}),children:[e.jsx(h,{children:e.jsxs(S,{xs:24,sm:24,md:12,lg:6,xl:6,xxl:6,children:[e.jsx("label",{children:"Select User Type"}),e.jsx(_,{disabled:n,style:{width:"100%",marginBottom:"10px"},value:a,options:A,onChange:s=>i(s)})]})}),e.jsx(h,{children:e.jsx(S,{xs:24,sm:24,md:12,lg:6,xl:6,xxl:6,children:e.jsx(g,{type:"primary",style:{marginBottom:"10px"},onClick:()=>b(),children:"Submit"})})}),n&&e.jsxs("div",{children:[e.jsx("h6",{children:"Menus"}),r.map((s,o)=>e.jsxs("details",{children:[e.jsxs("summary",{children:[e.jsx(j,{style:{marginRight:"10px"},checked:s.fstatus==="T",onChange:c=>y(o,"",s,c,"mainmenu")}),s.title]}),e.jsx("ul",{style:{listStyle:"none"},children:s.submenu.map((c,u)=>e.jsxs("li",{children:[e.jsx(j,{checked:c.fstatus==="T",style:{marginRight:"10px"},onChange:f=>y(o,u,c,f,"submenu")}),c.title]},u+o.toString()))})]},o.toString()))]})]})},O=t=>({menuItems:t.getAssignUserMenus,usertype:t.getUsertypedata}),W=T(O,{getUsertypeData:C,getAssignUserMenus:N,saveAssignUserMenus:L})(G);export{W as default};
|