PageSourceSearch

https://centerresearchdev.com.np/assets/RolePermission-Cp8OYGVh.js

js centerresearchdev.com.np collected 2026-10-02 02:03:12 UTC 4,313 bytes, 1 lines download raw bytes

1import{m as g,a as o,f as j,j as a}from"./react-vendor-DxUv0b-E.js";import{B as u}from"./Button-1bSnDcAR.js";import{T as y}from"./Table-D2t-bner.js";import{a as N,d as m}from"./index-D3IHbOo4.js";import"./dnd-kit-BIJQslpj.js";import"./react-icons-fi-KLKPHWnU.js";import"./react-icons-lib-DGihIP_I.js";import"./ConfirmModal-CluuWdme.js";import"./Modal-RsvGX5N8.js";import"./react-icons-fa-DS0WGntn.js";import"./useIsMobile-B4lU4tS-.js";import"./toast-CYWZkW3Q.js";import"./http-DhXgJQ-f.js";import"./crypto-54sHe70Q.js";import"./tanstack-DdulLlji.js";import"./framer-motion-CQVjGQci.js";import"./vendor-CY5ep9EN.js";import"./lucide-DWuOA0uJ.js";const F=()=>{const{id:n}=g(),{setLoading:l}=N(),[d,r]=o.useState([]),h=j(),p=async()=>{try{l(!0);const e=await m.get(`/roles/modules/${n}`,{showToast:!1});r(e.data?.data??[])}catch(e){console.error("Failed to fetch permissions",e)}finally{l(!1)}};o.useEffect(()=>{n&&p()},[n]);const c=(e,t)=>{r(s=>s.map(i=>i.id===e?{...i,[t]:!i[t]}:i))},x=e=>{r(t=>t.map(s=>s.id===e?{...s,canRead:!(s.canRead&&s.canWrite&&s.canUpdate&&s.canDelete),canWrite:!(s.canRead&&s.canWrite&&s.canUpdate&&s.canDelete),canUpdate:!(s.canRead&&s.canWrite&&s.canUpdate&&s.canDelete),canDelete:!(s.canRead&&s.canWrite&&s.canUpdate&&s.canDelete)}:s))},f=async()=>{try{l(!0),await m.put(`/roles/modules/${n}`,d),h("/roles")}catch(e){console.error("Failed to update permissions",e)}finally{l(!1)}},b=o.useMemo(()=>[{header:"Module",accessor:"name"},{header:"Select All",accessor:e=>{const t=e.canRead&&e.canWrite&&e.canUpdate&&e.canDelete;return a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t,onChange:()=>x(e.id),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-gray-300 rounded-full peer-checked:${COLORS.primary} transition-all"}),a.jsx("div",{className:"absolute left-0.5 top-0.5 bg-white w-5 h-5 rounded-full transition-transform peer-checked:translate-x-full"})]})}},{header:"Read",accessor:e=>a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e.canRead,onChange:()=>c(e.id,"canRead"),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-gray-300 rounded-full peer-checked:bg-yellow-500 transition-all"}),a.jsx("div",{className:"absolute left-0.5 top-0.5 bg-white w-5 h-5 rounded-full transition-transform peer-checked:translate-x-full"})]})},{header:"Write",accessor:e=>a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e.canWrite,onChange:()=>c(e.id,"canWrite"),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-gray-300 rounded-full peer-checked:bg-green-600 transition-all"}),a.jsx("div",{className:"absolute left-0.5 top-0.5 bg-white w-5 h-5 rounded-full transition-transform peer-checked:translate-x-full"})]})},{header:"Update",accessor:e=>a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e.canUpdate,onChange:()=>c(e.id,"canUpdate"),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-gray-300 rounded-full peer-checked:bg-blue-600 transition-all"}),a.jsx("div",{className:"absolute left-0.5 top-0.5 bg-white w-5 h-5 rounded-full transition-transform peer-checked:translate-x-full"})]})},{header:"Delete",accessor:e=>a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:e.canDelete,onChange:()=>c(e.id,"canDelete"),className:"sr-only peer"}),a.jsx("div",{className:"w-11 h-6 bg-gray-300 rounded-full peer-checked:bg-red-600 transition-all"}),a.jsx("div",{className:"absolute left-0.5 top-0.5 bg-white w-5 h-5 rounded-full transition-transform peer-checked:translate-x-full"})]})}],[]);return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h1",{className:"text-2xl font-semibold text-primary-500",children:"Manage Permissions"}),a.jsx(u,{onAction:()=>h("/roles"),variant:"destructive",size:"sm",children:"Back"})]}),a.jsx(y,{data:d,columns:b}),a.jsx("div",{className:"flex justify-end",children:a.jsx(u,{size:"sm",onAction:f,children:"Save Permissions"})})]})};export{F as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.