PageSourceSearch

https://asmod.pro/_next/static/chunks/pages/admin/roles-1a0240c7e5d09415.js

js asmod.pro collected 2026-10-09 21:52:43 UTC 3,639 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4739],{8395:(e,s,l)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/roles",function(){return l(29303)}])},29303:(e,s,l)=>{"use strict";l.r(s),l.d(s,{default:()=>i});var a=l(85485),n=l(64476),t=l(5776),d=l(85964),r=l(92995);function i(){var[e,s]=(0,t.useState)([]),[l,i]=(0,t.useState)(!0),[c,u]=(0,t.useState)(null),[o,h]=(0,t.useState)(""),[m,x]=(0,t.useState)(""),[p,b]=(0,t.useState)(!1);function j(){return(0,a._)(function*(){i(!0),u(null);try{var e,l,a=yield(0,r.RQ)("/api/v1/admin/roles");s(Array.isArray(a)?a:[])}catch(s){u((null==s||null==(l=s.response)||null==(e=l.data)?void 0:e.message)||s.message||"Ошибка загрузки")}finally{i(!1)}})()}return(0,t.useEffect)(()=>{j()},[]),(0,n.jsxs)(d.A,{title:"Роли",children:[(0,n.jsx)("h1",{className:"text-2xl font-bold mb-4",children:"Роли"}),(0,n.jsxs)("p",{className:"text-sm text-gray-600 mb-6",children:["Текущая версия проекта предполагает использование одной роли ",(0,n.jsx)("b",{children:"admin"}),". Раздел оставлен для расширения (RBAC) в будущем."]}),c?(0,n.jsx)("div",{className:"mb-4 text-red-600",children:c}):null,(0,n.jsxs)("div",{className:"bg-white border rounded p-4 mb-8",children:[(0,n.jsx)("h2",{className:"font-semibold mb-3",children:"Создать роль"}),(0,n.jsxs)("form",{onSubmit:function(e){return(0,a._)(function*(){e.preventDefault(),b(!0),u(null);try{yield(0,r.RQ)("/api/v1/admin/roles",{method:"POST",data:{key:o,name:m}}),h(""),x(""),yield j()}catch(e){var s,l;u((null==e||null==(l=e.response)||null==(s=l.data)?void 0:s.message)||e.message||"Ошибка сохранения")}finally{b(!1)}})()},className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,n.jsx)("input",{className:"border p-2 rounded",placeholder:"key (например: manager)",value:o,onChange:e=>h(e.target.value)}),(0,n.jsx)("input",{className:"border p-2 rounded",placeholder:"Название",value:m,onChange:e=>x(e.target.value)}),(0,n.jsx)("button",{className:"bg-blue-600 text-white rounded px-4 py-2 disabled:opacity-50",disabled:p||!o||!m,children:"Создать"})]})]}),l?(0,n.jsx)("p",{children:"Загрузка..."}):(0,n.jsx)("div",{className:"bg-white border rounded",children:(0,n.jsxs)("table",{className:"w-full text-sm",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-left border-b",children:[(0,n.jsx)("th",{className:"p-3",children:"ID"}),(0,n.jsx)("th",{className:"p-3",children:"key"}),(0,n.jsx)("th",{className:"p-3",children:"Название"}),(0,n.jsx)("th",{className:"p-3"})]})}),(0,n.jsxs)("tbody",{children:[e.map(e=>(0,n.jsxs)("tr",{className:"border-b",children:[(0,n.jsx)("td",{className:"p-3",children:e.id}),(0,n.jsx)("td",{className:"p-3",children:e.key}),(0,n.jsx)("td",{className:"p-3",children:e.name}),(0,n.jsx)("td",{className:"p-3 text-right",children:(0,n.jsx)("button",{className:"text-red-600 hover:underline disabled:opacity-50",onClick:()=>{var s;return s=e.id,(0,a._)(function*(){if(confirm("Удалить роль?")){b(!0),u(null);try{yield(0,r.RQ)("/api/v1/admin/roles/".concat(s),{method:"DELETE"}),yield j()}catch(s){var e,l;u((null==s||null==(l=s.response)||null==(e=l.data)?void 0:e.message)||s.message||"Ошибка удаления")}finally{b(!1)}}})()},disabled:p,children:"Удалить"})})]},e.id)),0===e.length?(0,n.jsx)("tr",{children:(0,n.jsx)("td",{className:"p-3",colSpan:4,children:"Нет ролей"})}):null]})]})})]})}}},e=>{e.O(0,[7972,2480,5964,636,6593,8792],()=>e(e.s=8395)),_N_E=e.O()}]);

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.