1import{h as C,u as U,D,T as H,r as s,y as t,j as o,L as c,z as $}from"./index-DCigE2mo.js";import{c as g,a as b,e as G,E as Q}from"./evento-form-BmSItBGF.js";import{c as h}from"./CircleNotch.es-fKlRAnoT.js";import{o as R}from"./CurrencyDollar.es-Dfowx2Ph.js";import{p as q}from"./FloppyDisk.es-DW4-O-VM.js";import{c as E}from"./Lock.es-kKzELm94.js";import{r as V}from"./Trash.es-TkRlxO0x.js";import{P as B}from"./PrivateHeader-KazUAWbO.js";import{b as j,a as M,f as O,e as _,d as J}from"./use-eventos-CRgLKH64.js";import{u as K}from"./use-membros-admin-DiSTqtZy.js";import{u as W}from"./use-secoes-admin-DtlLQqsm.js";import{g as X}from"./relatorio-pdf-B2aEtt_0.js";import{r as Y}from"./rich-text-7RwMdNfG.js";import"./CreditCard.es-CqgOZYSB.js";import"./RichTextEditor-2Cx0z7Qy.js";import"./Info.es-BvwOgx8g.js";import"./Paperclip.es-DGBW-bB2.js";import"./Plus.es-HHywPpWv.js";import"./MultiSelect-HeEPdqYh.js";import"./react-select.esm-DSd4OMs_.js";import"./defineProperty-BAgxAJIZ.js";import"./slicedToArray-Dby63wcm.js";import"./validar-arquivo-DGNrIfpZ.js";import"./jspdf.es.min-Bw41sy35.js";import"./purify.es-CEBYger9.js";const Aa=()=>{const{id:r}=C(),n=U(),z=D(a=>a.user),d=H(a=>a.confirm),{secoes:y,carregando:A}=W(),{membros:N}=K(),[e,l]=s.useState(g),[T,w]=s.useState(!0),[m,p]=s.useState(!1),[u,x]=s.useState(!1),[f,v]=s.useState(!1);s.useEffect(()=>{r&&j(r).then(a=>{if(!a){t.error("Evento não encontrado."),n("/p/escotistas/eventos");return}l({...g(),titulo:a.titulo,descricao:a.descricao,secoes:a.secoes??[],local:a.local,dataInicio:a.dataInicio,horaInicio:a.horaInicio,dataFim:a.dataFim,horaFim:a.horaFim,anexoUrlAtual:a.anexoUrl,capaUrlAtual:a.capaUrl,oQueLevar:a.oQueLevar??[],observacoes:a.observacoes??[],pagamentoHabilitado:a.pagamentoHabilitado??!0,grupoApoiaPagamento:a.grupoApoiaPagamento??!1,porcentagemGrupo:a.porcentagemGrupo??0,linkPagamentoAtividade:a.linkPagamentoAtividade||"",linkPagamentoTransporte:a.linkPagamentoTransporte||"",valorAtividade:a.valorAtividade||0,valorTransporte:a.valorTransporte||0,valorTotal:a.valorTotal||0,finalizado:a.finalizado??!1}),w(!1)})},[r,n]),s.useEffect(()=>l(a=>({...a,valorTotal:b(a)})),[e.valorAtividade,e.valorTransporte]);const F=async a=>{if(a.preventDefault(),!(!z||!r)){if(!Y(e.descricao)){t.error("A descrição do evento é obrigatória.");return}p(!0);try{await _(r,{titulo:e.titulo,descricao:e.descricao,secoes:e.secoes,local:e.local,dataInicio:e.dataInicio,horaInicio:e.horaInicio,dataFim:e.dataFim,horaFim:e.horaFim,oQueLevar:e.oQueLevar,observacoes:e.observacoes,pagamentoHabilitado:e.pagamentoHabilitado,grupoApoiaPagamento:e.grupoApoiaPagamento,porcentagemGrupo:e.grupoApoiaPagamento?Number(e.porcentagemGrupo):0,linkPagamentoAtividade:e.linkPagamentoAtividade,linkPagamentoTransporte:e.linkPagamentoTransporte,valorAtividade:Number(e.valorAtividade),valorTransporte:Number(e.valorTransporte),valorTotal:b(e),anexoUrl:e.anexoUrlAtual,ativo:!0},e.anexo,e.capa),t.success("Evento atualizado com sucesso!"),n("/p/escotistas/eventos")}catch(i){console.error("Erro ao atualizar evento:",i),t.error("Erro ao atualizar evento. Tente novamente.")}finally{p(!1)}}},P=async()=>{if(!r)return;const a=await j(r);if(!(!a||!await d({title:"Finalizar Evento",message:"Ao finalizar o evento, não será mais possÃvel editá-lo ou alterar dados financeiros. Um relatório PDF será gerado e arquivado automaticamente. Deseja continuar?",confirmLabel:"Finalizar",variant:"primary"}))){v(!0);try{const i=X(a,a.financeiro||{},a.gastos||[],N,{valorAtividade:a.valorAtividade||0,valorTransporte:a.valorTransporte||0}),{url:I}=await M(r,i,a.titulo);await O(r,I),l(L=>({...L,finalizado:!0})),t.success("Evento finalizado com sucesso!")}catch(i){console.error("Erro ao finalizar evento:",i),t.error("Erro ao finalizar evento.")}finally{v(!1)}}},k=async()=>{if(!(!r||!await d({title:"Excluir Evento",message:"Tem certeza que deseja excluir este evento? Esta ação não pode ser desfeita.",confirmLabel:"Excluir",variant:"danger"}))){x(!0);try{await J(r),t.success("Evento excluÃdo com sucesso!"),n("/p/escotistas/eventos")}catch(a){console.error("Erro ao excluir evento:",a),t.error("Erro ao excluir evento.")}finally{x(!1)}}},S=y.filter(a=>a.ativo).map(a=>({value:a.nome,label:`${a.nome} (${a.ramo})`}));return T?o.jsxs("div",{className:"p-16 flex justify-center gap-3 text-gray-500",children:[o.jsx(h,{size:24,className:"animate-spin"}),"Carregando evento..."]}):o.jsxs("div",{className:"p-4 md:p-8 max-w-4xl mx-auto",children:[o.jsxs("div",{className:"mb-3.5 flex gap-2 text-sm text-gray-500",children:[o.jsx(c,{to:"/p/escotistas/eventos",className:"hover:text-primary",children:"Escotista / Eventos"}),o.jsx("span",{children:"/"}),o.jsx("strong",{className:"text-gray-900 dark:text-white",children:"Editar Evento"})]}),o.jsxs(c,{to:"/p/escotistas/eventos",className:"inline-flex items-center gap-2 text-sm font-bold text-gray-500 hover:text-primary mb-3.5",children:[o.jsx($,{size:16}),"Voltar para Eventos"]}),o.jsxs("div",{className:"flex flex-col sm:flex-row justify-between gap-4 mb-3.5",children:[o.jsx(B,{title:"Editar Evento",icon:o.jsx(G,{size:28,weight:"duotone"})}),o.jsxs("div",{className:"flex flex-wrap gap-3",children:[!e.finalizado&&o.jsxs("button",{onClick:P,disabled:f,className:"flex items-center gap-2 px-5 h-11 rounded-xl bg-amber-500 text-white text-sm font-bold disabled:opacity-60",children:[f?o.jsx(h,{size:20,className:"animate-spin"}):o.jsx(E,{size:20}),"Finalizar Evento"]}),o.jsxs(c,{to:`/p/escotistas/eventos/${r}/financeiro`,className:"flex items-center gap-2 px-5 h-11 rounded-xl bg-green-500 text-white text-sm font-bold",children:[o.jsx(R,{size:20}),"Controle Financeiro"]})]})]}),o.jsxs("form",{onSubmit:F,className:"bg-white dark:bg-[#111128] rounded-2xl shadow-sm border border-gray-100 dark:border-white/5 p-8",children:[o.jsx(Q,{form:e,setForm:l,secoesOptions:S,carregandoSecoes:A}),o.jsxs("div",{className:"flex items-center justify-between mt-8 pt-6 border-t border-gray-100 dark:border-white/5",children:[o.jsxs("button",{type:"button",onClick:k,disabled:u||e.finalizado,className:"h-12 px-6 flex items-center gap-2 text-sm font-bold text-red-500 disabled:opacity-60",children:[o.jsx(V,{size:18}),u?"Excluindo...":"Excluir Evento"]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(c,{to:"/p/escotistas/eventos",className:"h-12 px-6 flex items-center text-sm font-bold text-gray-500",children:"Cancelar"}),e.finalizado?o.jsxs("div",{className:"flex items-center gap-2 px-6 py-3 rounded-xl bg-red-50 text-red-500 font-bold text-sm",children:[o.jsx(E,{size:20}),"Evento Finalizado"]}):o.jsxs("button",{type:"submit",disabled:m,className:"h-12 px-8 flex items-center gap-2 rounded-xl bg-primary text-white text-sm font-bold disabled:opacity-60",children:[o.jsx(q,{size:20}),m?"Salvando...":"Salvar Alterações"]})]})]})]})]})};export{Aa 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.