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