PageSourceSearch

https://www.growthconf.com.br/assets/FichaDoAviso-B2YVxhZN.js

js growthconf.com.br collected 2026-10-04 13:34:19 UTC 6,733 bytes, 1 lines download raw bytes

1import{k as D,i as I,b as R,r as x,j as e}from"./react-daO8XSXc.js";import{A as V,s as _,d as M,e as P}from"./avisoService-CQ7WoO2f.js";import{L as $}from"./avisos-8hAdm6rh.js";import{C as z,S as L}from"./Escolhas-BH21sbXZ.js";import{S as J,F as U,a as B,b as S,c as A,d as C,e as G,f as H}from"./Ficha-MR5k4piD.js";import{S as Y,B as g}from"./Button-8-UveMcL.js";import{F as u}from"./Field-3GimFoRS.js";import{T as Z,S as K,I as j}from"./Input-BWXNKslz.js";import{a as E}from"./Exibicao-BET41dMP.js";import{E as Q}from"./EmptyState-DyDBtv_o.js";import{u as W}from"./Avisos-DoJY8zcA.js";import{p as X,A as ee}from"./traducaoService-DuRCLS-G.js";import{F as ae}from"./TrashIcon-CSgk2SLQ.js";import"./index-B58ZFblL.js";import"./supabase-CWGMQrOR.js";import"./framer-CJI0BPWU.js";import"./lucide-DgiROqw5.js";import"./index-Bx8Owg57.js";import"./index-BSdpKbQ6.js";import"./index-Be0SzB96.js";import"./basicos-CJBwiWJx.js";import"./Dialog-pcGZL7JV.js";import"./index-BkA-a7YQ.js";import"./XMarkIcon-BbNpXEGa.js";import"./ChevronDownIcon-C1xiHESR.js";import"./InformationCircleIcon-BuxHKy4m.js";import"./ExclamationTriangleIcon-CYNpIWW5.js";const b=[{valor:"informacao",rotulo:"Informação",ajuda:"O recado comum."},{valor:"destaque",rotulo:"Destaque",ajuda:"O que você quer que não passe batido."},{valor:"atencao",rotulo:"Atenção",ajuda:"Mudança de última hora, problema, correção."}],y=i=>{if(!i)return"";const t=new Date(i);if(Number.isNaN(t.getTime()))return"";const n=l=>String(l).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`},O=i=>{if(!i)return null;const t=new Date(i);return Number.isNaN(t.getTime())?null:t.toISOString()};function Te(){const{avisos:i,carregando:t,recarregar:n}=D(),{id:l}=I(),f=R(),[d,r]=x.useState(!0),h=l===void 0,m=h?null:i.find(p=>p.id===l)||null,v=x.useCallback(()=>r(!1),[]);return x.useEffect(()=>{if(d)return;const p=setTimeout(()=>f("..",{replace:!0}),J);return()=>clearTimeout(p)},[d,f]),e.jsx(U,{open:d,onOpenChange:p=>!p&&r(!1),children:e.jsx(B,{children:!h&&!m&&t?e.jsxs(e.Fragment,{children:[e.jsx(S,{children:e.jsx(A,{children:"Carregando…"})}),e.jsx(C,{className:"flex items-center justify-center",children:e.jsx(Y,{className:"size-7 text-painel-texto-3"})})]}):!h&&!m?e.jsxs(e.Fragment,{children:[e.jsx(S,{children:e.jsx(A,{children:"Aviso não encontrado"})}),e.jsx(C,{children:e.jsx(Q,{titulo:"Esta ficha não existe",descricao:"O aviso pode ter sido excluído. Volte para a lista e escolha outro.",acao:e.jsx(g,{variant:"secondary",onClick:v,children:"Voltar para a lista"})})})]}):e.jsx(oe,{original:m,recarregar:n,fechar:v},m?m.id:"novo")})})}function oe({original:i,recarregar:t,fechar:n}){const{avisar:l,confirmar:f}=W(),d=i===null,[r,h]=x.useState(()=>i??{...V}),[m,v]=x.useState({}),[p,N]=x.useState(!1),F=x.useRef(null),c=(a,o)=>h(s=>({...s,[a]:o})),T=async a=>{if(a.preventDefault(),!r.texto.trim()){v({texto:"O texto é obrigatório."}),requestAnimationFrame(()=>{var k;const s=(k=F.current)==null?void 0:k.querySelector('[aria-invalid="true"]');s==null||s.scrollIntoView({block:"center"}),s==null||s.focus()});return}v({}),N(!0);const o=await _(r);if(N(!1),!o){l("Não conseguimos salvar. Tente de novo.","erro");return}X({aviso:o}).then(s=>{s||l(ee,"erro")}),await t(),l(M(r)?"Aviso salvo. Já está no Painel.":"Aviso salvo, fora do ar por enquanto.","sucesso"),n()},q=async()=>{if(!await f({titulo:"Excluir este aviso?",descricao:"Ele sai do Painel imediatamente. Não dá para desfazer.",confirmar:"Excluir",perigo:!0}))return;if(!await P(r.id)){l("Não conseguimos excluir. Tente de novo.","erro");return}await t(),l("Aviso excluído.","sucesso"),n()},w=b.find(a=>a.valor===r.tom)??b[0];return e.jsxs(e.Fragment,{children:[e.jsxs(S,{children:[e.jsx(A,{children:d?"Novo aviso":"Aviso"}),e.jsx(G,{children:"Aparece no Painel de quem se inscreveu, enquanto estiver publicado e dentro do prazo."})]}),e.jsxs("form",{ref:F,onSubmit:T,className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs(C,{className:"space-y-5",children:[e.jsx(u,{rotulo:"Texto",obrigatorio:!0,erro:m.texto,ajuda:"Uma ou duas linhas.",children:a=>e.jsx(Z,{...a,rows:3,value:r.texto,onChange:o=>c("texto",o.target.value),placeholder:"Ex.: a abertura começa às 9h30, com o Ronei."})}),e.jsx(u,{rotulo:"Tom",ajuda:w.ajuda,children:a=>e.jsx(K,{...a,value:r.tom,onChange:o=>c("tom",o.target.value),children:b.map(o=>e.jsx("option",{value:o.valor,children:o.rotulo},o.valor))})}),e.jsx(u,{rotulo:"Onde aparece",ajuda:"A faixa fixa fica no topo de todas as telas — use com parcimônia.",children:()=>e.jsxs("div",{className:"space-y-2.5",children:[$.map(a=>e.jsx(z,{checked:r.lugares.includes(a.id),onCheckedChange:o=>c("lugares",o===!0?[...r.lugares,a.id]:r.lugares.filter(s=>s!==a.id)),rotulo:e.jsxs("span",{children:[a.rotulo,e.jsx("span",{className:"block text-[11px] text-painel-texto-3",children:a.ajuda})]})},a.id)),r.lugares.length===0&&e.jsx("p",{className:"text-[11px] text-painel-aviso",children:"Sem nenhum lugar marcado, este aviso não aparece para ninguém — nem publicado."})]})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(u,{rotulo:"Link",ajuda:"Opcional.",children:a=>e.jsx(j,{...a,type:"url",placeholder:"https://",value:r.link,onChange:o=>c("link",o.target.value)})}),e.jsx(u,{rotulo:"Texto do link",ajuda:'Em branco, vira "Ver mais".',children:a=>e.jsx(j,{...a,value:r.linkRotulo,onChange:o=>c("linkRotulo",o.target.value),placeholder:"Ver mais"})})]}),e.jsx(E,{}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(u,{rotulo:"A partir de",ajuda:"Em branco: vale já.",children:a=>e.jsx(j,{...a,type:"datetime-local",value:y(r.inicio),onChange:o=>c("inicio",O(o.target.value))})}),e.jsx(u,{rotulo:"Até",ajuda:"Em branco: não vence.",children:a=>e.jsx(j,{...a,type:"datetime-local",value:y(r.fim),onChange:o=>c("fim",O(o.target.value))})})]}),e.jsx(u,{rotulo:"Ordem",ajuda:"Menor primeiro, quando houver mais de um no ar.",children:a=>e.jsx(j,{...a,type:"number",value:String(r.ordem),onChange:o=>c("ordem",Number(o.target.value)||0)})}),e.jsx(E,{}),e.jsx(L,{rotulo:"Publicado",ajuda:"Rascunho fica só aqui no painel; publicado entra no prazo que você marcou.",checked:r.publicado,onCheckedChange:a=>c("publicado",a)})]}
1),e.jsxs(H,{className:"sm:justify-between",children:[d?e.jsx("span",{}):e.jsxs(g,{type:"button",variant:"destructive",onClick:q,children:[e.jsx(ae,{"aria-hidden":!0}),"Excluir"]}),e.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[e.jsx(g,{type:"button",variant:"secondary",onClick:n,children:"Cancelar"}),e.jsx(g,{type:"submit",loading:p,children:d?"Cadastrar":"Salvar"})]})]})]})]})}export{Te 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.