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.191.178.145
Current Path : /var/www/qpms/assets/ |
| Current File : /var/www/qpms/assets/AssignUserMenus-BA31VzK9.js |
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-DyNbFNdv.js";import{g as C}from"./Usertype-CIuAoMdr.js";import{S as D}from"./index-DSj5wDp5.js";import{R as I}from"./StopOutlined-DE1ceCdI.js";import{R as v}from"./SaveOutlined-C0pDaVKH.js";import{R as w}from"./HomeOutlined-Ds3oKS9p.js";import{R as h,C as S}from"./row-D_ucBIJf.js";import{C as j}from"./index-DlAFQ05A.js";import"./responsiveObserver-DzO8y4F6.js";import"./index-CoKLT7W5.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:[]}),console.log(n)}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};
|