import{_ as S}from"./DUQr9DrG.js";import{_ as U}from"./R8MN9BFv.js";import{_ as C}from"./G7u0egV4.js";import{d as I,p as T,O as q,P as A,J as B,z as e,b as j,w as N,g as c,o as O,f as p,e as b,n as x,m as R,i as V}from"./JQJBiNWj.js";import D from"./D42GNhrT.js";import{h as F}from"./CH1bAkoS.js";import"./BwwR4PPN.js";import"./B6O9xiO5.js";import"./HM4z-iuB.js";import"./DqVYbxj5.js";import"./CxkaGOlL.js";import"./BgAkS4D_.js";import"./DKM0wLqG.js";import"./4FMzYxPj.js";import"./CeGk6Fsr.js";import"./D1rKqwCM.js";import"./CeWG_dyW.js";import"./CDSORL4U.js";import"./BWs0r_ue.js";import"./D8TjaAl-.js";import"./ClVEEBFD.js";import"./BoTzJngr.js";import"./qAEGbaa4.js";import"./BnQEpK3N.js";import"./CJYlvWEf.js";import"./Dc_YXEFz.js";import"./BBDFeM-T.js";import"./BuR5k2Xw.js";import"./2JTb7YQn.js";import"./Dk4pWsnS.js";import"./BSHuRY0P.js";import"./3oa0FK2h.js";import"./F98GHXdS.js";import"./yKVtex9U.js";import"./CbtPaznW.js";import"./DmwTwIPt.js";import"./B-La3K3C.js";import"./DvBDpJyt.js";import"./FcRkkR--.js";const z={class:"flex -mx-4 -mb-4 p-4 sm:sticky sm:bottom-0 bg-white border-t"},G={class:"flex flex-wrap gap-3 justify-end items-center w-full"},To=I({__name:"nova",async setup(H){let s,u;const _=T(),E=q(),v=([s,u]=A(()=>E.getEmpresaSelecionada()),s=await s,u(),s),f=B({idEmpresa:v.id,idUsuario:void 0,assunto:void 0,dataInteracao:void 0,declaracao:void 0,idArea:void 0,idEntidade:void 0,local:void 0,inicio:void 0,termino:void 0,status:void 0,observacao:void 0,complementoTxt:void 0,complementoHtml:void 0,participantes:[]});function h(t){var r,n,l,g;if(!t.valid)return;const a={idEmpresa:v.id};Object.keys(t.states).forEach(o=>{const i=t.states[o].value;if(i!==void 0)if(o==="declaracao")a[o]=i?1:0;else if(o==="dataInteracao"||o==="inicio"||o==="termino")a[o]=i instanceof Date?i.toISOString().split("T")[0]:i;else if(o==="idArea"||o==="idEntidade"||o==="idUsuario")a[o]=(i==null?void 0:i.id)||i;else{if(["cargo","email"].includes(o))return;a[o]=i}});const m=R(),d={nome:(r=m.data.value)==null?void 0:r.nomeUsuario,cargo:(n=t.states.cargo)==null?void 0:n.value,email:(l=t.states.email)==null?void 0:l.value,idUsuario:(g=m.data.value)==null?void 0:g.refId,tipo:"C"};a.participantes=[d],V.relacoesInstitucionais.saveReuniao(a).then(()=>{_.add({severity:"success",summary:"Sucesso",detail:"Reunião criada com sucesso!",life:5e3}),x("consultar")}).catch(o=>{var i;_.add({severity:"error",life:1e4,summary:"Erro",detail:((i=o.data)==null?void 0:i.message)||o.message})})}const w=F(e.object({idEmpresa:e.number({required_error:"Empresa é obrigatória"}),idUsuario:e.number({required_error:"Usuário é obrigatório"}),assunto:e.string({required_error:"Assunto é obrigatório"}),dataInteracao:e.coerce.date({required_error:"Data interação é obrigatória"}),email:e.string({required_error:"Email é obrigatório"}).email("E-mail inválido"),declaracao:e.boolean().refine(t=>t===!0,{message:"Você precisa aceitar a declaração"})}));return(t,a)=>{const m=S,d=U,r=C,n=D;return O(),j(n,{class:"space-y-8","initial-values":c(f),resolver:c(w),onSubmit:h},{default:N(()=>[p(m,{title:"Nova reunião"}),p(d,{reuniao:c(f)},null,8,["reuniao"]),b("div",z,[b("div",G,[p(r,{mode:"cancel",class:"max-sm:w-full",onClick:a[0]||(a[0]=l=>("navigateTo"in t?t.navigateTo:c(x))("./consultar"))}),p(r,{mode:"save",class:"max-sm:w-full",type:"submit"})])])]),_:1},8,["initial-values","resolver"])}}});export{To as default};
