1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8875],{85778:function(e,r,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/administrativo/perfis",function(){return t(50583)}])},24475:function(e,r,t){"use strict";t.d(r,{Z:function(){return s}});var i=t(67294);function s(e){let[r,t]=(0,i.useState)(!0),[s,a]=(0,i.useState)(!1),[o,n]=(0,i.useState)([]);(0,i.useEffect)(()=>{let e=!0,r=async()=>{try{let r=await fetch("/api/admin/acessos/me");if(!r.ok)throw Error("sem acesso");let t=await r.json();if(!e)return;a(!!t.isAdminMaster),n(Array.isArray(t.modulos)?t.modulos:[])}catch(r){if(!e)return;a(!1),n([])}finally{e&&t(!1)}};return r(),()=>{e=!1}},[]);let l=(0,i.useCallback)(e=>o.includes(e),[o]),c=Array.isArray(e)?e:[e].filter(Boolean),d=c.length?c.some(e=>o.includes(e)):o.length>0;return{loading:r,isAdminMaster:s,modulos:o,pode:l,autorizado:d}}},50583:function(e,r,t){"use strict";t.r(r),t.d(r,{default:function(){return T}});var i=t(85893),s=t(67294),a=t(25593),o=t(13573),n=t(9361),l=t(18922),c=t(68872),d=t(23345),x=t(40411),u=t(66309),m=t(83062),h=t(83622),p=t(86738),f=t(71230),g=t(15746),y=t(4393),j=t(53531),Z=t(25278),v=t(59157),S=t(17788),w=t(96074),b=t(11163),P=t(24475),k=t(89583);let{Title:C,Text:E}=a.Z,{Option:_}=o.Z;function T(){let e=(0,b.useRouter)(),{token:r}=n.Z.useToken(),{loading:t,autorizado:a}
1=(0,P.Z)("administrativo"),[T,I]=(0,s.useState)(!1),[B,R]=(0,s.useState)([]),[z,N]=(0,s.useState)({page:1,limit:20,total:0}),[A,U]=(0,s.useState)(""),[D,F]=(0,s.useState)(0),[O,L]=(0,s.useState)("active"),[W,$]=(0,s.useState)(!1),[H,q]=(0,s.useState)(!1),[M]=l.Z.useForm(),[V,G]=(0,s.useState)(!1),[K,X]=(0,s.useState)(null),[Y,J]=(0,s.useState)(!1),[Q,ee]=(0,s.useState)([]),[er,et]=(0,s.useState)({page:1,limit:10,total:0});(0,s.useEffect)(()=>{t||a||e.push("/")},[t,a,e]),(0,s.useEffect)(()=>{a&&ei()},[a,z.page,O,D]);let ei=async()=>{I(!0);try{let e=new URLSearchParams({page:z.page,limit:z.limit,status:O});A&&e.append("search",A);let r=await fetch("/api/admin/profiles?".concat(e)),t=await r.json();r.ok?(R(t.data),N(e=>({...e,total:t.pagination.total}))):c.ZP.error(t.message||"Erro ao carregar perfis")}catch(e){c.ZP.error("Erro ao carregar perfis")}finally{I(!1)}},es=async e=>{q(!0);try{let r=await fetch("/api/admin/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),t=await r.json();r.ok?(c.ZP.success("Perfil criado com sucesso"),$(!1),M.resetFields(),ei()):c.ZP.error(t.message||"Erro ao criar perfil")}catch(e){c.ZP.error("Erro ao criar perfil")}finally{q(!1)}},ea=async e=>{try{let r=await fetch("/api/admin/profiles/".concat(e),{method:"DELETE"}),t=await r.json();r.ok?(c.ZP.success("Perfil inativado com sucesso"),ei()):c.ZP.error(t.message||"Erro ao inativar perfil")}catch(e){c.ZP.error("Erro ao inativar perfil")}},eo=async function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;X(e),G(!0),J(!0);try{let t=new URLSearchParams({page:r,limit:er.limit}),i=await fetch("/api/admin/profiles/".concat(e.id,"/funcionarios?").concat(t)),s=await i.json();i.ok?(ee(s.data),et(e=>({...e,page:s.pagination.page,total:s.pagination.total}))):c.ZP.error(s.message||"Erro ao carregar funcionarios")}catch(e){c.ZP.error("Erro ao carregar funcionarios")}finally{J(!1)}},en=B.filter(e=>e.is_active).length,el=B.reduce((e,r)=>e+(r.regras_count||0),0),ec=B.reduce((e,r)=>e+(r.funcionarios_count||0),0),ed=[{title:"Perfil",key:"name",render:(e,r)=>(0,i.jsxs)("div",{children:[(0,i.jsx)(E,{strong:!0,style:{fontSize:14,display:"block"},children:r.name}),(0,i.jsx)(E,{type:"secondary",style:{fontSize:12},children:r.description||"Sem descri\xe7\xe3o"})]}),sorter:(e,r)=>e.name.localeCompare(r.name)},{title:(0,i.jsxs)(d.Z,{children:[(0,i.jsx)(k.ZUW,{style:{color:"#1890ff"}}),(0,i.jsx)("span",{children:"M\xf3dulos"})]}),dataIndex:"regras_count",key:"regras_count",align:"center",width:120,render:e=>(0,i.jsx)(x.Z,{count:e,showZero:!0,style:{backgroundColor:e>0?"#1890ff":"#d9d9d9"}})},{title:"Usu\xe1rios",dataIndex:"funcionarios_count",key:"funcionarios_count",align:"center",width:100,render:e=>e||0},{title:"Status",key:"status",align:"center",width:100,render:(e,r)=>r.is_active?(0,i.jsx)(u.Z,{color:"success",icon:(0,i.jsx)(k.l_A,{style:{marginRight:4}}),children:"Ativo"}):(0,i.jsx)(u.Z,{color:"error",icon:(0,i.jsx)(k.YS4,{style:{marginRight:4}}),children:"Inativo"})},{title:"A\xe7\xf5es",key:"actions",align:"center",width:150,render:(r,t)=>(0,i.jsxs)(d.Z,{size:"small",children:[(0,i.jsx)(m.Z,{title:"Ver usu\xe1rios",children:(0,i.jsx)(h.ZP,{type:"text",icon:(0,i.jsx)(k.I$,{style:{color:t.funcionarios_count>0?"#52c41a":void 0}}),onClick:()=>eo(t),disabled:0===t.funcionarios_count})}),(0,i.jsx)(m.Z,{title:"Configurar permiss\xf5es",children:(0,i.jsx)(h.ZP,{type:"primary",ghost:!0,size:"small",icon:(0,i.jsx)(k.p4t,{}),onClick:()=>e.push("/admin/administrativo/perfis/".concat(encodeURIComponent(t.name)))})}),t.is_active&&(0,i.jsx)(p.Z,{title:"Inativar perfil",description:"Tem certeza que deseja inativar este perfil?",onConfirm:()=>ea(t.id),okText:"Sim",cancelText:"N\xe3o",okButtonProps:{danger:!0},children:(0,i.jsx)(m.Z,{title:"Inativar",children:(0,i.jsx)(h.ZP,{type:"text",danger:!0,size:"small",icon:(0,i.jsx)(k.YS4,{})})})})]})}];return a?(0,i.jsxs)("section",{className:"container",style:{minHeight:"100vh",background:r.colorBgLayout,padding:"24px"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24,padding:"16px 24px",background:r.colorBg
1Container,borderRadius:12,boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},children:[(0,i.jsx)(h.ZP,{type:"text",icon:(0,i.jsx)(k.x_l,{}),onClick:()=>e.push("/admin/administrativo"),style:{fontSize:18}}),(0,i.jsx)("div",{style:{flex:1},children:(0,i.jsxs)(d.Z,{align:"center",children:[(0,i.jsx)(k.bri,{style:{fontSize:28,color:r.colorPrimary}}),(0,i.jsxs)("div",{children:[(0,i.jsx)(C,{level:3,style:{margin:0,color:r.colorText},children:"Gerenciar Perfis"}),(0,i.jsx)(E,{type:"secondary",children:"Configure permiss\xf5es e regras de acesso"})]})]})}),(0,i.jsx)(h.ZP,{type:"primary",icon:(0,i.jsx)(k.wEH,{}),size:"large",onClick:()=>$(!0),children:"Novo Perfil"})]}),(0,i.jsxs)(f.Z,{gutter:[16,16],style:{marginBottom:24},children:[(0,i.jsx)(g.Z,{xs:24,sm:8,children:(0,i.jsx)(y.Z,{style:{background:r.colorBgContainer,borderRadius:12},children:(0,i.jsx)(j.Z,{title:(0,i.jsx)(E,{type:"secondary",children:"Perfis Ativos"}),value:en,formatter:e=>new Intl.NumberFormat("pt-BR").format(e),prefix:(0,i.jsx)(k.bri,{style:{color:r.colorPrimary,marginRight:8}}),valueStyle:{color:r.colorPrimary}})})}),(0,i.jsx)(g.Z,{xs:24,sm:8,children:(0,i.jsx)(y.Z,{style:{background:r.colorBgContainer,borderRadius:12},children:(0,i.jsx)(j.Z,{title:(0,i.jsx)(E,{type:"secondary",children:"Total de M\xf3dulos"}),value:el,formatter:e=>new Intl.NumberFormat("pt-BR").format(e),prefix:(0,i.jsx)(k.ZUW,{style:{color:"#1890ff",marginRight:8}}),valueStyle:{color:"#1890ff"}})})}),(0,i.jsx)(g.Z,{xs:24,sm:8,children:(0,i.jsx)(y.Z,{style:{background:r.colorBgContainer,borderRadius:12},children:(0,i.jsx)(j.Z,{title:(0,i.jsx)(E,{type:"secondary",children:"Usu\xe1rios Vinculados"}),value:ec,formatter:e=>new Intl.NumberFormat("pt-BR").format(e),prefix:(0,i.jsx)(k.I$,{style:{color:"#52c41a",marginRight:8}}),valueStyle:{color:"#52c41a"}})})})]}),(0,i.jsxs)(y.Z,{style:{background:r.colorBgContainer,borderRadius:12},children:[(0,i.jsxs)("div",{style:{marginBottom:24,display:"flex",gap:16,flexWrap:"wrap",alignItems:"flex-end",padding:"16px",background:r.colorBgLayout,borderRadius:8},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:250},children:[(0,i.jsx)(E,{strong:!0,style:{display:"block",marginBottom:8,color:r.colorText},children:"Buscar"}),(0,i.jsx)(Z.Z,{placeholder:"Buscar por nome do perfil...",value:A,onChange:e=>U(e.target.value),onPressEnter:()=>{N(e=>({...e,page:1})),F(e=>e+1)},prefix:(0,i.jsx)(k.U41,{style:{color:r.colorTextDisabled}})})]}),(0,i.jsxs)("div",{style:{minWidth:180},children:[(0,i.jsx)(E,{strong:!0,style:{display:"block",marginBottom:8,color:r.colorText},children:"Status"}),(0,i.jsxs)(o.Z,{value:O,onChange:e=>{L(e),N(e=>({...e,page:1}))},style:{width:"100%"},children:[(0,i.jsx)(_,{value:"active",children:"Ativos"}),(0,i.jsx)(_,{value:"inactive",children:"Inativos"}),(0,i.jsx)(_,{value:"all",children:"Todos"})]})]})]}),(0,i.jsx)(v.Z,{columns:ed,dataSource:B,rowKey:"id",loading:T,pagination:{current:z.page,pageSize:z.limit,total:z.total,showSizeChanger:!1,showTotal:e=>"".concat(e," perfil(is)"),onChange:e=>N(r=>({...r,page:e}))}})]}),(0,i.jsxs)(S.Z,{title:(0,i.jsxs)(d.Z,{children:[(0,i.jsx)(k.wEH,{style:{color:r.colorPrimary}}),(0,i.jsx)("span",{children:"Novo Perfil"})]}),open:W,onCancel:()=>{$(!1),M.resetFields()},footer:null,width:480,children:[(0,i.jsx)(w.Z,{style:{margin:"12px 0 24px"}}),(0,i.jsxs)(l.Z,{form:M,layout:"vertical",onFinish:es,children:[(0,i.jsx)(l.Z.Item,{name:"name",label:"Nome do Perfil",rules:[{required:!0,message:"Informe o nome do perfil"},{pattern:/^[A-Z_]+$/,message:"Use apenas letras mai\xfasculas e underscore"}],children:(0,i.jsx)(Z.Z,{placeholder:"Ex: GERENTE, COORDENADOR, ATENDENTE...",size:"large",prefix:(0,i.jsx)(k.bri,{style:{color:r.colorTextDisabled}})})}),(0,i.jsx)(l.Z.Item,{name:"description",label:"Descri\xe7\xe3o",children:(0,i.jsx)(Z.Z.TextArea,{rows:3,placeholder:"Descreva as responsabilidades deste perfil..."})}),(0,i.jsx)(w.Z,{style:{margin:"16px 0"}}),(0,i.jsx)(l.Z.Item,{style:{marginBottom:0},children:(0,i.jsxs)(d.Z,{style:{width:"100%",justifyContent:"flex-end"},children:[(0,i.jsx)(h.ZP,{size:"large",onClick:()=>{$(!1),M.resetFields()},children:"Cancelar"}),(0,i.jsx)(h.ZP,{type:"primary",htmlType:"submit",loading:H,size:"large",icon:(0,i.jsx)(k.wEH,{}),children:"Criar Perfil"})]})})]})]}),(0,i.jsxs)(S.Z,{title:(0,i.jsxs)(d.Z,{children:[(0,i.jsx)(k.I$,{style:{color:"#52c41a"}}),(0,i.jsx)("span",{children:"Usu\xe1rios do Perfil"}),K&&(0,i.jsx)(u.Z,{color:"blue",children:K.name})]}),open:V,onCancel:()=>{G(!1),X(null),ee([]),et(e=>({...e,page:1,total:0}))},footer:null,width:800,children:[(0,i.jsx)(w.Z,{style:{margin:"12px 0 24px"}}),(0,i.jsx)(v.Z,{columns:[{title:"Usu\xe1rio",key:"nome",render:(e,r)=>(0,i.jsxs)("div",{children:[(0,i.jsx)(E,{strong:!0,children:r.nome}),(0,i.jsx)("br",{}),(0,i.jsx)(E,{type:"secondary",style:{fontSize:12},children:r.email||"Sem email"})]})},{title:"Unidade",dataIndex:"unidade",key:"unidade",render:e=>(0,i.jsx)(u.Z,{color:"blue",children:e||"-"})},{title:"A\xe7\xf5es",key:"actions",align:"center",width:100,render:(r,t)=>(0,i.jsx)(m.Z,{title:"Ver detalhes",children:(0,i.jsx)(h.ZP,{type:"primary",ghost:!0,size:"small",icon:(0,i.jsx)(k.dSq,{}),onClick:()=>{sessionStorage.setItem("funcionario_id",t.id),e.push("/rh/funcionarios/detalhes")}})})}],dataSource:Q,rowKey:"id",loading:Y,pagination:{current:er.page,pageSize:er.limit,total:er.total,showSizeChanger:!1,showTotal:e=>"".concat(e," usu\xe1rio(s)"),onChange:e=>eo(K,e)},locale:{emptyText:(0,i.jsxs)("div",{style:{padding:40,textAlign:"center"},children:[(0,i.jsx)(k.I$,{style:{fontSize:40,color:r.colorTextDisabled,marginBottom:16}}),(0,i.jsx)(C,{level:5,style:{color:r.colorTextSecondary},children:"Nenhum usu\xe1rio vinculado"}),(0,i.jsx)(E,{type:"secondary",children:"Este perfil ainda n\xe3o possui usu\xe1rios associados"})]})}})]})]}):null}}},function(e){e.O(0,[80640,5282,59157,40411,72367,49774,92888,40179],function(){return e(e.s=85778)}),_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.