import{_ as g}from"./DDV-HLQE.js";import{_ as y}from"./C23xqETz.js";import{_ as T}from"./Brk5FU9k.js";import{d as h,O as w,P as x,p as C,K as j,z as r,a as q,f as a,w as F,g as n,F as S,o as k,e as D,n as l,i as E}from"./dVzHJMF1.js";import A from"./iZ-xiGRB.js";import{h as B}from"./CH1bAkoS.js";import"./DhLu8RVk.js";import"./CWHHmK0V.js";import"./yXj_05M0.js";import"./Bhud8mbC.js";import"./tESAK1vk.js";import"./B79Hoqpc.js";import"./CX2DUt_P.js";import"./DW2OqR52.js";import"./5WXaDlrT.js";import"./DiwqsPB4.js";import"./KcBrPYTF.js";import"./C9L2ikqF.js";import"./B3dHCiEQ.js";import"./BZjcnCH7.js";import"./B7Hqpkvs.js";import"./C5Oc2f2M.js";import"./CBbadgK0.js";import"./a1m94JqE.js";import"./CM8mMzv6.js";import"./DP0doleY.js";import"./BAtzogEJ.js";import"./r1Y5hC84.js";import"./BSLzRQpY.js";import"./BNYh59m7.js";import"./Bpf-t_rp.js";import"./yHxjwlra.js";import"./KG16xCEZ.js";const O={class:"flex gap-3 -mx-4 -mb-4 p-4 bg-white sticky bottom-0 border-t items-center flex-wrap justify-end"},be=h({__name:"adicionar",async setup(I){let s,d;const u=w(),_=([s,d]=x(()=>u.getEmpresaSelecionada()),s=await s,d(),s),p=C(),c=j({titulo:void 0,idTipo:void 0,idObjetivo:void 0,idCidade:void 0,idTrecho:void 0,kmInicial:void 0,kmFinal:void 0,faixa:void 0,status:void 0,tiposAnexos:[],responsaveis:[]}),v=B(r.object({titulo:r.string({required_error:"Título é obrigatório"}),idCidade:r.number({required_error:"Cidade é obrigatória"}),kmInicial:r.number({required_error:"KM Inicial é obrigatório"}),kmFinal:r.number({required_error:"KM Final é obrigatório"}),idTrecho:r.number({required_error:"Trecho é obrigatório"}),idTipo:r.number({required_error:"Tipo é obrigatório"}),idObjetivo:r.number({required_error:"Objetivo é obrigatório"})}));function b(t){if(!t.valid)return;const i={idEmpresa:_.id};Object.keys(t.states).forEach(o=>{const e=t.states[o].value;e!==void 0&&(typeof e=="object"&&e!==null?Array.isArray(e)?i[o]=e.map(m=>m.id):i[o]=e.id:i[o]=e)}),E.demandas.createDemanda(i).then(()=>{p.add({severity:"success",summary:"Sucesso",detail:"Demanda criada com sucesso!",life:5e3}),l("consultar")}).catch(o=>{var e;p.add({severity:"error",life:1e4,summary:"Erro",detail:((e=o.data)==null?void 0:e.message)||o.message})})}return(t,i)=>{const o=g,e=y,m=T,f=A;return k(),q(S,null,[a(o,{title:"Demandas - Adicionar"}),a(f,{class:"space-y-8","initial-values":n(c),resolver:n(v),onSubmit:b},{default:F(()=>[a(e,{demanda:n(c)},null,8,["demanda"]),D("div",O,[a(m,{mode:"cancel",class:"w-full sm:w-auto",onClick:i[0]||(i[0]=K=>("navigateTo"in t?t.navigateTo:n(l))("./consultar"))}),a(m,{mode:"save",class:"w-full sm:w-auto",type:"submit"})])]),_:1},8,["initial-values","resolver"])],64)}}});export{be as default};
