PageSourceSearch

https://redeindica.go.gov.br/build/assets/Editar-26ddcc60.js

js redeindica.go.gov.br collected 2026-10-02 00:27:52 UTC 10,667 bytes, 1 lines download raw bytes

1import{r as w,v as Z,N as c,a as y,b as B,o as m,c as g,w as x,d as l,f as i,i as A,u as s,g as b,e as V,j as I,k as $}from"./app-5fc1912d.js";import{C as P}from"./Card-511e1ef8.js";import{_ as D}from"./AdminLayout-c73cece3.js";import{_ as k}from"./InputLabel-cab2995d.js";import{I as h}from"./iconify-03d69e80.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ApplicationLogo-e0d31125.js";import"./Footer-af4780d1.js";import"./icon-df62cc88.js";import"./validacaoNome-49cf0a9d.js";const F={class:"tw-py-12"},G={class:"tw-max-w-7xl tw-mx-auto sm:tw-px-6 tw-px-8 md:tw-px-0"},M={class:"tw-flex tw-flex-col md:tw-flex-row tw-flex-1 tw-gap-6"},T={class:"tw-flex tw-justify-between"},H=l("h5",{class:"tw-font-bold"},"Editar Usuário",-1),J={class:"tw-flex"},K=["onClick"],Q=l("span",{class:"tw-ml-2 tw-mr-2"},"Salvar",-1),R={class:"tw-grid tw-w-full tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-4"},W={class:"tw-col-span-2"},X={class:"tw-col-span-2"},Y={class:"tw-col-span-2 md:tw-col-span-1"},ee=l("p",{className:"tw-text-xs tw-text-gray-700 tw-mt-1"},[$(" Sua senha deve ter no mínimo 8 caracters. "),l("br"),$(" Sua senha deve conter letras e números, e pode conter caractere especial. ")],-1),ae={class:"tw-col-span-2 md:tw-col-span-1"},te={class:"tw-col-span-2"},oe=l("span",{class:"tw-text-base tw-leading-3 tw-font-black tw-text-gray-700"},"Selecione o perfil de acesso",-1),se={key:0,class:"tw-col-span-2 tw-mb-2"},le=l("span",{class:"tw-text-base tw-leading-3 tw-font-black tw-text-gray-700"},"Limitação de acesso",-1),ie={class:"tw-mt-4 tw-flex tw-gap-6 tw-items-center"},ne={key:1,class:"tw-col-span-2 tw-mb-2"},re=l("span",{class:"tw-text-base tw-leading-3 tw-font-black tw-text-gray-700"},"Limitação de acesso",-1),de={class:"tw-mt-4 tw-flex tw-gap-6 tw-items-center"},ue={key:2,class:"tw-col-span-2"},ce=l("span",{class:"tw-text-base tw-leading-4 tw-font-black tw-text-gray-700"},"Selecione as cidades que o usuário terá acesso:",-1),me={key:3,class:"tw-col-span-2"},pe=l("span",{class:"tw-text-base tw-leading-4 tw-font-black tw-text-gray-700"},"Selecione as unidades que o usuário terá acesso:",-1),ve={class:"tw-flex tw-justify-end"},we=["onClick"],qe={__name:"Editar",props:{usuario:{type:Object},perfis:{type:Array},unidades:{type:Array}},setup(N){const d=N,r=w(!0),u=w(!1),C=w([]),q=w([]),n=w(d.usuario.unidades.length||d.usuario.cidades.length?"1":"0"),z=d.unidades.map(o=>({value:o.id,label:`${o.nome} - ${o.cidade} - ${o.uf}`})),S=w([]),e=Z({id:d.usuario.id,name:d.usuario.name,email:d.usuario.email,senha:"",confirmacao_senha:"",perfil:d.usuario.profile.name,cidades:d.usuario.cidades.map(o=>o.nome),unidades:d.usuario.unidades.map(o=>({value:o.id,label:`${o.nome} - ${o.cidade} - ${o.uf}`}))});e.unidades.length==1&&(e.unidades=e.unidades[0]),axios.get("https://servicodados.ibge.gov.br/api/v1/localidades/estados/GO/municipios").then(o=>{C.value=o.data.map(a=>({value:a.nome,label:a.nome})),q.value=C.value}).catch(o=>{c.create({position:"top-right",message:"Não foi possivel carregar as cidades, atualize a página!",color:"negative"})});function E(o,a,f){a(()=>{const p=o.toLowerCase();q.value=C.value.filter(v=>v.label.toLowerCase().indexOf(p)>-1)})}function L(o,a,f){a(()=>{const p=o.toLowerCase();S.value=z.filter(v=>v.label.toLowerCase().indexOf(p)>-1)})}async function U(){await O()?u.value=!1:(e.unidades.length&&e.unidades[0].value&&(e.unidades=e.unidades.map(o=>o.value)),e.patch(route("admin.usuarios.update"),{preserveScroll:!0,onSuccess:o=>{c.create({position:"top-right",message:"Usuário atualizado com sucesso",color:"primary"})},onError:o=>{console.log(o),c.create({position:"top-right",message:"Não foi possível atualizar o usuário no momento.",color:"negative"})}}))}async function O(){u.value=!1;const o=[{field:"name",message:"O campo Nome é obrigatório."},{field:"email",message:"O campo E-mail é obrigatório."}];for(const{field:a,message:f}of o)e[a]||(c.create({type:"negative",color:"negative",position:"top-right",message:f}),u.value=!0);if(e.senha&&((e.senha.length<8||!/^(?=.*[A-Za-z]{1,})(?=.*\d{1,})(?=.*[@$!%*?&])?[A-Za-z\d@$#!%*;,.?\(\)&]{8,}$/.test(e.senha))&&(c.create({type:"negative",color:"negative",position:"top-right",message:"O campo Senha deve ter no mínimo 8 caracteres, com letras e números. Caracteres especiais são opcionais.",duration:4e3}),u.value=!0),(!/[a-zA-Z]/.test(e.senha)||!/\d/.test(e.senha))&&(c.create({type:"negative",color:"negative",position:"top-right",message:"A senha deve conter pelo menos uma letra e um número."}),u.value=!0),e.senha!=e.confirmacao_senha&&(c.create({type:"negative",color:"negative",position:"top-right",message:"Suas senhas não coincidem, verifique e tente novamente."}),u.value=!0)),e.email!=d.usuario.email){const a=await axios.get(route("check.email"),{params:{email:e.email}});a.data||(c.create({type:"negative",color:"negative",position:"top-right",message:"Não foi possível verificar o email informado, tente novamente."}),u.value=!0),a.data.exists&&(c.create({type:"negative",color:"negative",position:"top-right",message:"E-mail em uso. Verifique e tente novamente"}),u.value=!0)}return n.value=="1"&&e.perfil=="moderador"&&(e.cidades==null||e.cidades.length==0)&&(c.create({type:"negative",color:"negative",position:"top-right",message:"Você marcou a opção de acesso limitado, deve indicar ao menos uma cidade."}),u.value=!0),n.value=="1"&&e.perfil=="adial"&&(e.unidades==null||e.unidades.length==0)&&(c.create({type:"negative",color:"negative",position:"top-right",message:"Você marcou a opção de acesso Adial, deve indicar ao menos uma unidade."}),u.value=!0),["0"].includes(n.value)&&(e.cidades=[],e.unidades=[]),u.value}return(o,a)=>{const f=y("q-btn"),p=y("q-input"),v=y("q-select"),_=y("q-radio"),j=B("close-popup");return m(),g(D,null,{default:x(()=>[l("div",F,[l("div",G,[l("div",M,[i(P,null,{default:x(()=>[l("div",T,[i(f,{flat:"",icon:"arrow_back",class:"tw-my-btn tw-shadow-none tw-remove-shadow",href:o.route("admin.usuarios")},null,8,["href"]),H,l("div",J,[l("button",{onClick:A(U,["prevent"]),flat:"",class:"tw-flex tw-items-center tw-justify-center tw-bg-primary tw-px-4 tw-py-2 tw-rounded-full tw-text-white"},[i(s(h),{icon:"material-symbols:add-circle"}),Q],8,K)])]),l("div",R,[l("div",W,[i(k,{for:"name",required:"",value:"Nome Completo"}),i(p,{outlined:"",id:"name",type:"text",class:"tw-block tw-w-full",modelValue:s(e).name,"onUpdate:modelValue":a[0]||(a[0]=t=>s(e).name=t),required:"",label:"Seu nome",autocomplete:"name",rules:[t=>!!t||"Por favor, insira o seu nome"]},null,8,["modelValue","rules"])]),l("div",X,[i(k,{for:"email",class:"",required:"",value:"E-mail"}),i(p,{outlined:"",id:"email",type:"email",class:"tw-block tw-w-full",label:"[email protected]",modelValue:s(e).email,"onUpdate:modelValue":a[1]||(a[1]=t=>s(e).email=t),rules:[t=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)||"E-mail inválido"]},null,8,["modelValue","rules"])]),l("div",Y,[i(k,{for:"senha",required:"",value:"Senha"}),i(p,{outlined:"",id:"senha",class:"tw-mt-1 tw-block tw-w-full",modelValue:s(e).senha,"onUpdate:modelValue":a[4]||(a[4]=t=>s(e).senha=t),required:"",autocomplete:"new-password",label:"Crie uma senha",type:r.value?"password":"text","lazy-rules":"",rules:[t=>t&&!!t||"Por favor, digite a sua senha",t=>/^(?=.*[A-Za-z]{1,})(?=.*\d{1,})(?=.*[@$!%*?&])?[A-Za-z\d@$#!%*;,.?\(\)&]{8,}$/.test(t)||"Senha não atende um ou mais requisitos"]},{append:x(()=>
1[r.value?(m(),g(s(h),{key:0,icon:"material-symbols:visibility-outline",class:"cursor-pointer",onClick:a[2]||(a[2]=t=>r.value=!r.value)})):(m(),g(s(h),{key:1,icon:"ic:twotone-visibility-off",class:"cursor-pointer",onClick:a[3]||(a[3]=t=>r.value=!r.value)}))]),_:1},8,["modelValue","type","rules"]),ee]),l("div",ae,[i(k,{for:"confirmacao_senha",required:"",value:"Confirme a Senha"}),i(p,{outlined:"",id:"confirmacao_senha",class:"tw-mt-1 tw-block tw-w-full",modelValue:s(e).confirmacao_senha,"onUpdate:modelValue":a[7]||(a[7]=t=>s(e).confirmacao_senha=t),required:"",label:"Confirme a sua senha",autocomplete:"new-password","lazy-rules":"",type:r.value?"password":"text",rules:[t=>!!t||"Por favor, confirme a sua senha",t=>t===s(e).senha||"As senhas não correspondem"]},{append:x(()=>[r.value?(m(),g(s(h),{key:0,icon:"material-symbols:visibility-outline",class:"cursor-pointer",onClick:a[5]||(a[5]=t=>r.value=!r.value)})):(m(),g(s(h),{key:1,icon:"ic:twotone-visibility-off",class:"cursor-pointer",onClick:a[6]||(a[6]=t=>r.value=!r.value)}))]),_:1},8,["modelValue","type","rules"])]),l("div",te,[oe,i(v,{outlined:"",required:"",label:"Selecione o tipo de perfil de acesso",modelValue:s(e).perfil,"onUpdate:modelValue":a[8]||(a[8]=t=>s(e).perfil=t),"emit-value":"","map-options":"",options:d.perfis.map(t=>({label:t.name.toUpperCase(),value:t.name}))},null,8,["modelValue","options"])]),s(e).perfil=="moderador"?(m(),b("div",se,[le,l("div",ie,[i(_,{modelValue:n.value,"onUpdate:modelValue":a[9]||(a[9]=t=>n.value=t),label:"Acesso Ilimitado",val:"0",dense:""},null,8,["modelValue"]),i(_,{modelValue:n.value,"onUpdate:modelValue":a[10]||(a[10]=t=>n.value=t),label:"Acesso Limitado por cidade(s)",val:"1",dense:""},null,8,["modelValue"])])])):V("",!0),s(e).perfil=="adial"?(m(),b("div",ne,[re,l("div",de,[i(_,{modelValue:n.value,"onUpdate:modelValue":a[11]||(a[11]=t=>n.value=t),label:"Acesso Ilimitado",val:"0",dense:""},null,8,["modelValue"]),i(_,{modelValue:n.value,"onUpdate:modelValue":a[12]||(a[12]=t=>n.value=t),label:"Acesso Limitado por unidade(s)",val:"1",dense:""},null,8,["modelValue"])])])):V("",!0),s(e).perfil=="moderador"&&n.value=="1"?(m(),b("div",ue,[ce,i(v,{outlined:"",class:"tw-mt-5",label:"Selecione uma ou mais cidades",multiple:"",clearable:"","use-input":"","input-debounce":"0",onFilter:E,options:q.value,"map-value":"","emit-value":"",modelValue:s(e).cidades,"onUpdate:modelValue":a[13]||(a[13]=t=>s(e).cidades=t)},null,8,["options","modelValue"])])):V("",!0),s(e).perfil=="adial"&&n.value=="1"?(m(),b("div",me,[pe,i(v,{outlined:"",class:"tw-mt-5",label:"Selecione uma unidade",clearable:"","use-input":"","input-debounce":"0",onFilter:L,options:S.value,"emit-value":"","map-options":"",modelValue:s(e).unidades,"onUpdate:modelValue":a[14]||(a[14]=t=>s(e).unidades=t)},null,8,["options","modelValue"])])):V("",!0)]),l("div",ve,[I((m(),b("button",{clickable:"",onClick:A(U,["prevent"]),class:"tw-text-[14px] tw-h-10 tw-items-center tw-bg-primary tw-rounded-full tw-w-full tw-px-4 tw-py-2 tw-border tw-border-transparent tw-font-semibold tw-text-xs tw-text-white tw-tracking-widest hover:tw-transition-colors hover:tw-bg-blue-800 hover:tw-ease-in-out"},[$(" Salvar ")],8,we)),[[j]])])]),_:1})])])])]),_:1})}}};export{qe 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.