import{_ as S}from"./DDV-HLQE.js";import{_ as U}from"./Cj-HWR5w.js";import{_ as C}from"./Brk5FU9k.js";import{d as I,p as T,O as q,P as A,K 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"./dVzHJMF1.js";import D from"./iZ-xiGRB.js";import{h as F}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"./BuQ9u7Je.js";import"./BW5cYMVL.js";import"./DiwqsPB4.js";import"./KcBrPYTF.js";import"./5WXaDlrT.js";import"./CELWndHG.js";import"./a1m94JqE.js";import"./Bc99g-CG.js";import"./BSe03gVj.js";import"./BGFPOxrp.js";import"./B7Hqpkvs.js";import"./BSLzRQpY.js";import"./C5Oc2f2M.js";import"./CBbadgK0.js";import"./CM8mMzv6.js";import"./DP0doleY.js";import"./BAtzogEJ.js";import"./r1Y5hC84.js";import"./yHxjwlra.js";import"./CL2jyiz8.js";import"./B-d7gz-d.js";import"./CNJ8Vm0G.js";import"./Bpf-t_rp.js";import"./KG16xCEZ.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};
