PageSourceSearch

https://www.visitecamposdojordao.org.br/assets/ConselhoAdmin-DgGIz2Vb.js

js visitecamposdojordao.org.br collected 2026-09-25 09:01:26 UTC 18,491 bytes, 1 lines download raw bytes

1import{r as g,j as a}from"./vendor-react-CoH7wDUq.js";import{E as se,p as te}from"./index-co-p2Yz-.js";import{ay as oe,az as H,aA as le,aB as re,aC as ie,aD as me,aE as ne,aF as de,aG as ce,aH as ge}from"./AdminApp-DooYmww9.js";import{A as J,a as A,b as W,c as M}from"./AdminCard-TGEFBssE.js";import{C as k,b as Q,c as p,a as t,d as E,e as U,f as Y,g as L}from"./councilMemberAvatarStyle-CcADIoZ5.js";import"./vendor-pdf-DNjb9-t8.js";const R=[{v:"PRESIDENTE",l:"Presidente"},{v:"VICE_PRESIDENTE",l:"Vice-presidente"},{v:"DELIBERATIVO",l:"Conselho deliberativo"},{v:"DELIBERATIVO_SUPLENTE",l:"Suplente deliberativo"},{v:"FISCAL",l:"Conselho fiscal"},{v:"FISCAL_SUPLENTE",l:"Suplente fiscal"}];function v(m){const S=(m||"").trim();if(!S)return null;const Z=se(S)??S;return/^https?:\/\//i.test(Z)?Z:te(Z.replace(/^\//,""))}function ve(){const[m,S]=g.useState(null),[Z,F]=g.useState(!0),[O,r]=g.useState(""),[$,C]=g.useState(""),[N,j]=g.useState(!1),[T,G]=g.useState(!1),[q,_]=g.useState(!1),[y,I]=g.useState({trienio:"",chapa:"",dataEleicao:"",textoDestaque:""}),[o,u]=g.useState({tipo:"DELIBERATIVO",nome:"",empresa:"",imagemUrl:"",ordem:0,imagemPosX:50,imagemPosY:50,imagemZoom:k}),[P,D]=g.useState(null),[l,h]=g.useState({imagemUrl:"",legenda:"",ordem:0,imagemPosX:50,imagemPosY:50,imagemZoom:100}),[w,X]=g.useState(null),f=g.useCallback(async()=>{F(!0),r("");try{const e=await oe();S(e);const s=e.config;s&&I({trienio:s.trienio??"",chapa:s.chapa??"",dataEleicao:s.dataEleicao??"",textoDestaque:s.textoDestaque??""})}catch(e){r(e instanceof Error?e.message:"Erro ao carregar")}finally{F(!1)}},[]);g.useEffect(()=>{f()},[f]);const K=async e=>{e.preventDefault(),j(!0),r(""),C("");try{await ne({trienio:y.trienio.trim(),chapa:y.chapa.trim(),dataEleicao:y.dataEleicao.trim()||null,textoDestaque:y.textoDestaque.trim()||null}),await f(),C("Configuração salva com sucesso.")}catch(s){r(s instanceof Error?s.message:"Erro ao guardar")}finally{j(!1)}},ee=async e=>{e.preventDefault(),j(!0),r(""),C("");try{const s={tipo:o.tipo,nome:o.nome.trim(),empresa:o.empresa.trim()||null,imagemUrl:o.imagemUrl.trim()||null,ordem:Number(o.ordem)||0,imagemPosX:t(o.imagemPosX),imagemPosY:t(o.imagemPosY),imagemZoom:p(o.imagemZoom)};P?await H(String(P.id),s):await de(s),D(null),u({tipo:"DELIBERATIVO",nome:"",empresa:"",imagemUrl:"",ordem:0,imagemPosX:50,imagemPosY:50,imagemZoom:k}),await f(),C(P?"Membro atualizado e salvo.":"Membro adicionado e salvo.")}catch(s){r(s instanceof Error?s.message:"Erro")}finally{j(!1)}},ae=async e=>{e.preventDefault(),j(!0),r(""),C("");try{const s={imagemUrl:l.imagemUrl.trim(),legenda:l.legenda.trim()||null,ordem:Number(l.ordem)||0,imagemPosX:t(l.imagemPosX),imagemPosY:t(l.imagemPosY),imagemZoom:p(l.imagemZoom)};if(!s.imagemUrl)throw new Error("URL da imagem é obrigatória.");w?await ce(String(w.id),s):await ge(s),X(null),h({imagemUrl:"",legenda:"",ordem:0,imagemPosX:50,imagemPosY:50,imagemZoom:100}),await f(),C(w?"Imagem da galeria atualizada e salva.":"Imagem da galeria adicionada e salva.")}catch(s){r(s instanceof Error?s.message:"Erro")}finally{j(!1)}},z=m!=null&&m.membros?[...m.membros].sort((e,s)=>{const n=x=>R.findIndex(b=>b.v===x),i=n(e.tipo),d=n(s.tipo);return i!==d?i-d:e.ordem-s.ordem||e.id-s.id}):[],B=g.useCallback(async(e,s)=>{var b;if(!((b=m==null?void 0:m.membros)!=null&&b.length))return;const n=[...m.membros].filter(c=>c.tipo===e.tipo).sort((c,V)=>c.ordem-V.ordem||c.id-V.id),i=n.findIndex(c=>c.id===e.id),d=i+s;if(i<0||d<0||d>=n.length)return;const x=[...n];[x[i],x[d]]=[x[d],x[i]],j(!0),r("");try{for(let c=0;c<x.length;c++)x[c].ordem!==c&&await H(String(x[c].id),{ordem:c});await f()}catch(c){r(c instanceof Error?c.message:"Erro ao reordenar")}finally{j(!1)}},[m==null?void 0:m.membros,f]);return a.jsxs("div",{className:"max-w-4xl space-y-10",children:[a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl md:text-2xl font-bold text-slate-800",style:{fontFamily:"'Poppins', sans-serif"},children:"Conselho (CJRC&VB)"}),a.jsx("p",{className:"text-sm text-slate-500 mt-1",children:"Textos da chapa, membros (foto por URL ou ficheiro em uploads/conselho/membros/) e galeria (URL ou ficheiro em uploads/conselho/galeria/) no separador Conselho em Quem somos."})]}),O&&a.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",children:O}),$&&a.jsx("div",{className:"p-3 bg-emerald-50 border border-emerald-200 rounded-lg text-emerald-700 text-sm",children:$}),Z?a.jsx("p",{className:"text-slate-500",children:"Carregando…"}):a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"p-4 bg-white rounded-xl border border-slate-200 space-y-3",children:[a.jsx("h2",{className:"font-semibold text-slate-800",children:"Configuração geral"}),a.jsxs("form",{onSubmit:K,className:"space-y-3 max-w-xl",children:[a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg",placeholder:"Triênio (ex.: 2025-2028)",value:y.trienio,onChange:e=>I(s=>({...s,trienio:e.target.value})),required:!0}),a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg",placeholder:"Nome da chapa",value:y.chapa,onChange:e=>I(s=>({...s,chapa:e.target.value})),required:!0}),a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg",placeholder:"Data da eleição / assembleia (texto livre)",value:y.dataEleicao,onChange:e=>I(s=>({...s,dataEleicao:e.target.value}))}),a.jsx("textarea",{className:"w-full px-3 py-2 border rounded-lg",rows:4,placeholder:"Texto em destaque (citação abaixo dos conselhos)",value:y.textoDestaque,onChange:e=>I(s=>({...s,textoDestaque:e.target.value}))}),a.jsx("button",{type:"submit",disabled:N,className:"px-4 py-2 bg-blue-600 text-white rounded-lg disabled:opacity-50",children:N?"A guardar…":"Guardar configuração"})]})]}),a.jsxs("section",{className:"p-4 bg-white rounded-xl border border-slate-200 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"font-semibold text-slate-800",children:"Membros"}),a.jsxs("p",{className:"text-xs text-slate-500 mt-1",children:["Use ",a.jsx("strong",{className:"font-medium text-slate-600",children:"Subir"})," e"," ",a.jsx("strong",{className:"font-medium text-slate-600",children:"Descer"})," para alterar a ordem dentro do mesmo cargo (presidente, vice, deliberativo, suplentes ou fiscal). A ordem no site público segue estes valores."]})]}),a.jsxs("form",{onSubmit:ee,className:"space-y-2 p-3 bg-slate-50 rounded-lg border border-slate-100",children:[a.jsx("p",{className:"text-xs text-slate-500",children:P?"Editar membro":"Novo membro"}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx("select",{className:"px-3 py-2 border rounded-lg text-sm",value:o.tipo,onChange:e=>u(s=>({...s,tipo:e.target.value})),children:R.map(e=>a.jsx("option",{value:e.v,children:e.l},e.v))}),a.jsx("input",{type:"number",className:"w-24 px-2 py-2 border rounded-lg",placeholder:"Ordem",value:o.ordem,onChange:e=>u(s=>({...s,ordem:Number(e.target.value)}))})]}),a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg",placeholder:"Nome completo *",value:o.nome,onChange:e=>u(s=>({...s,nome:e.target.value})),required:!0}),a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg",placeholder:"Empresa / estabelecimento",value:o.empresa,onChange:e=>u(s=>({...s,empresa:e.target.value}))}),a.jsx("label",{className:"block text-xs font-medium text-slate-600",children:"Foto (URL ou ficheiro)"}),a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"URL da foto (opcional se carregar ficheiro abaixo)",value:o.imagemUrl,onChange:e=>u(s=>({...s,imagemUrl:e.target.value}))}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700 cursor-pointer",children:[a.jsx("span",{className:"px-3 py-2 bg-slate-200 rounded-lg hover:bg-slate-300",children:T?"A enviar…":"Carregar imagem do computador"}),a.jsx("input",{type:"file",accept:"image/*",className:"sr-only",disabled:N||T,onChange:async e=>{var i;const s=(i=e.target.files)==null?void 0:i[0];if(e.target.value="",!s)return;const n=o.nome.trim();if(!n){r("Preencha o nome completo antes de carregar a foto (o ficheiro fica com um nome baseado na pessoa).");return}r(""),G(!0);try{const{url:d}=await le(s,n);u(x=>({...x,imagemUrl:d}))}catch(d){r(d instanceof Error?d.message:"Erro no upload")}finally{G(!1)}}})]}),a.jsx("span",{className:"text-xs text-slate-500",children:"JPG, PNG, WebP ou GIF · máx. 6 MB"})]}),v(o.imagemUrl)?a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-slate-600",children:"Enquadramento da foto"}),a.jsx("p",{className:"text-xs text-slate-500",children:"Horizontal e vertical aceitam valores fora do intervalo 0–100% para puxar o enquadramento para as laterais, acima ou abaixo. Zoom mínimo afasta a imagem; zoom máximo aproxima."}),a.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[a.jsx("div",{className:"h-28 w-28 shrink-0 rounded-full overflow-hidden border-2 border-slate-200 shadow-sm bg-slate-100",children:a.jsx("img",{src:v(o.imagemUrl),alt:"",className:"h-full w-full object-cover",style:Q(`${t(o.imagemPosX)}% ${t(o.imagemPosY)}%`,p(o.imagemZoom))})}),a.jsxs("div",{className:"flex-1 min-w-[200px] space-y-3",children:[a.jsxs("label",{className:"block text-xs text-slate-600",children:["Horizontal: ",t(o.imagemPosX),"% (",E," esquerda ·"," ",U," direita)",a.jsx("input",{type:"range",min:E,max:U,step:1,value:t(o.imagemPosX),onChange:e=>u(s=>({...s,imagemPosX:Number(e.target.value)})),className:"block w-full mt-1"})]}),a.jsxs("label",{className:"block text-xs text-slate-600",children:["Vertical: ",t(o.imagemPosY),"% (",E," acima · ",U," ","abaixo)",a.jsx("input",{type:"range",min:E,max:U,step:1,value:t(o.imagemPosY),onChange:e=>u(s=>({...s,imagemPosY:Number(e.target.value)})),className:"block w-full mt-1"})]}),a.jsxs("label",{className:"block text-xs text-slate-600",children:["Zoom: ",p(o.imagemZoom),"% (",Y,"% afastar · ",L,"% aproximar)",a.jsx("input",{type:"range",min:Y,max:L,step:1,value:p(o.imagemZoom),onChange:e=>u(s=>({...s,imagemZoom:Number(e.target.value)})),className:"block w-full mt-1"})]}),a.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:[a.jsx("button",{type:"button",className:"text-xs text-blue-600 hover:underline",onClick:()=>u(e=>({...e,imagemPosX:50,imagemPosY:50})),children:"Repor posição (centro)"}),a.jsxs("button",{type:"button",className:"text-xs text-blue-600 hover:underline",onClick:()=>u(e=>({...e,imagemZoom:k})),children:["Repor zoom (",k,"%)"]})]})]})]})]}):null,a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"submit",disabled:N,className:"px-4 py-2 bg-blue-600 text-white rounded-lg text-sm",children:P?"Atualizar":"Adicionar"}),P&&a.jsx("button",{type:"button",className:"px-4 py-2 bg-slate-200 rounded-lg text-sm",onClick:()=>{D(null),u({tipo:"DELIBERATIVO",nome:"",empresa:"",imagemUrl:"",ordem:0,imagemPosX:50,imagemPosY:50,imagemZoom:k})},children:"Cancelar edição"})]})]}),a.jsx("div",{className:"grid gap-3",children:z.map(e=>{var x;const s=z.filter(b=>b.tipo===e.tipo),n=s.findIndex(b=>b.id===e.id),i=n>0,d=n>=0&&n<s.length-1;return a.jsx(J,{title:`${e.nome} — ${((x=R.find(b=>b.v===e.tipo))==null?void 0:x.l)??e.tipo}`,status:"active",preview:a.jsxs("div",{className:"flex gap-3 items-start",children:[v(e.imagemUrl)?a.jsx("div",{className:"h-16 w-16 shrink-0 rounded-full overflow-hidden border border-slate-200 bg-slate-100",children:a.jsx("img",{src:v(e.imagemUrl),alt:"",className:"h-full w-full object-cover",style:Q(`${t(e.imagemPosX)}% ${t(e.imagemPosY)}%`,p(e.imagemZoom))})}):null,a.jsx("span",{className:"text-slate-600",children:e.empresa||"—"})]}),details:a.jsxs("div",{className:"space-y-1 text-sm",children:[a.jsx(M,{label:"Ordem:",value:String(e.ordem)}),e.imagemUrl?a.jsxs("p",{className:"text-xs break-all text-slate-500",children:[a.jsx("span",{className:"font-semibold",children:"Foto:"})," ",e.imagemUrl]}):null]}),actions:a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:A,disabled:N||!i,title:"Subir na ordem (mesmo cargo)",onClick:()=>B(e,-1),children:"Subir"}),a.jsx("button",{type:"button",className:A,disabled:N||!d,title:"Descer na ordem (mesmo cargo)",onClick:()=>B(e,1),children:"Descer"}),a.jsx("button",{type:"button",className:A,onClick:()=>{D(e),u({tipo:e.tipo,nome:e.nome,empresa:e.empresa??"",imagemUrl:e.imagemUrl??"",ordem:e.ordem,imagemPosX:t(e.imagemPosX),imagemPosY:t(e.imagemPosY),imagemZoom:p(e.imagemZoom)})},children:"Editar"}),a.jsx("button",{type:"button",className:W,onClick:async()=>
1{if(confirm("Remover este membro?"))try{await re(String(e.id)),await f()}catch(b){r(b instanceof Error?b.message:"Erro")}},children:"Remover"})]})},e.id)})})]}),a.jsxs("section",{className:"p-4 bg-white rounded-xl border border-slate-200 space-y-4",children:[a.jsx("h2",{className:"font-semibold text-slate-800",children:"Galeria de fotos"}),a.jsxs("form",{onSubmit:ae,className:"space-y-2 p-3 bg-slate-50 rounded-lg border border-slate-100",children:[a.jsx("p",{className:"text-xs text-slate-500",children:w?"Editar imagem":"Nova imagem"}),a.jsx("label",{className:"block text-xs font-medium text-slate-600",children:"Imagem (URL ou ficheiro)"}),a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"URL da imagem (ou use o botão abaixo)",value:l.imagemUrl,onChange:e=>h(s=>({...s,imagemUrl:e.target.value}))}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("label",{className:"inline-flex items-center gap-2 text-sm text-slate-700 cursor-pointer",children:[a.jsx("span",{className:"px-3 py-2 bg-slate-200 rounded-lg hover:bg-slate-300",children:q?"A enviar…":"Carregar imagem do computador"}),a.jsx("input",{type:"file",accept:"image/*",className:"sr-only",disabled:N||q,onChange:async e=>{var n;const s=(n=e.target.files)==null?void 0:n[0];if(e.target.value="",!!s){r(""),_(!0);try{const{url:i}=await ie(s,l.legenda);h(d=>({...d,imagemUrl:i}))}catch(i){r(i instanceof Error?i.message:"Erro no upload")}finally{_(!1)}}}})]}),a.jsx("span",{className:"text-xs text-slate-500",children:"O prefixo do ficheiro usa a legenda se já estiver preenchida; senão usa “galeria”."})]}),a.jsx("input",{className:"w-full px-3 py-2 border rounded-lg text-sm",placeholder:"Legenda (opcional)",value:l.legenda,onChange:e=>h(s=>({...s,legenda:e.target.value}))}),a.jsx("input",{type:"number",className:"w-32 px-3 py-2 border rounded-lg",placeholder:"Ordem",value:l.ordem,onChange:e=>h(s=>({...s,ordem:Number(e.target.value)}))}),v(l.imagemUrl)?a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-xs font-medium text-slate-600",children:"Ajuste de imagem da galeria"}),a.jsxs("p",{className:"text-xs text-slate-500",children:["Ajuste usando os sliders e clique em ",a.jsx("strong",{children:"Atualizar"})," para guardar. O preview abaixo mostra desktop e mobile sem corte (proporções diferentes)."]}),a.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[a.jsxs("div",{className:"overflow-hidden rounded-lg border border-slate-200 bg-slate-100",children:[a.jsx("div",{className:"border-b border-slate-200 px-2 py-1 text-[11px] font-medium text-slate-500",children:"Desktop (4:3)"}),a.jsx("div",{className:"aspect-[4/3] bg-slate-950",children:a.jsx("img",{src:v(l.imagemUrl),alt:"",className:"h-full w-full object-contain",style:{objectPosition:`${t(l.imagemPosX)}% ${t(l.imagemPosY)}%`,transform:`scale(${p(l.imagemZoom)/100})`}})})]}),a.jsxs("div",{className:"overflow-hidden rounded-lg border border-slate-200 bg-slate-100",children:[a.jsx("div",{className:"border-b border-slate-200 px-2 py-1 text-[11px] font-medium text-slate-500",children:"Mobile (9:16)"}),a.jsx("div",{className:"mx-auto aspect-[9/16] max-h-56 w-[58%] rounded-b-lg bg-slate-950",children:a.jsx("img",{src:v(l.imagemUrl),alt:"",className:"h-full w-full object-contain",style:{objectPosition:`${t(l.imagemPosX)}% ${t(l.imagemPosY)}%`,transform:`scale(${p(l.imagemZoom)/100})`}})})]})]}),a.jsxs("label",{className:"block text-xs text-slate-600",children:["Horizontal: ",t(l.imagemPosX),"%",a.jsx("input",{type:"range",min:E,max:U,step:1,value:t(l.imagemPosX),onChange:e=>h(s=>({...s,imagemPosX:Number(e.target.value)})),className:"block w-full mt-1"})]}),a.jsxs("label",{className:"block text-xs text-slate-600",children:["Vertical: ",t(l.imagemPosY),"%",a.jsx("input",{type:"range",min:E,max:U,step:1,value:t(l.imagemPosY),onChange:e=>h(s=>({...s,imagemPosY:Number(e.target.value)})),className:"block w-full mt-1"})]}),a.jsxs("label",{className:"block text-xs text-slate-600",children:["Zoom: ",p(l.imagemZoom),"%",a.jsx("input",{type:"range",min:Y,max:L,step:1,value:p(l.imagemZoom),onChange:e=>h(s=>({...s,imagemZoom:Number(e.target.value)})),className:"block w-full mt-1"})]})]}):null,a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{type:"submit",disabled:N,className:"px-4 py-2 bg-blue-600 text-white rounded-lg text-sm",children:w?"Atualizar":"Adicionar"}),w&&a.jsx("button",{type:"button",className:"px-4 py-2 bg-slate-200 rounded-lg text-sm",onClick:()=>{X(null),h({imagemUrl:"",legenda:"",ordem:0,imagemPosX:50,imagemPosY:50,imagemZoom:100})},children:"Cancelar"})]})]}),a.jsx("div",{className:"grid sm:grid-cols-2 gap-3",children:((m==null?void 0:m.galeria)??[]).slice().sort((e,s)=>e.ordem-s.ordem||e.id-s.id).map(e=>a.jsx(J,{title:e.legenda||`Imagem #${e.id}`,status:"active",preview:v(e.imagemUrl)?a.jsx("div",{className:"h-24 w-full overflow-hidden rounded-lg",children:a.jsx("img",{src:v(e.imagemUrl),alt:"",className:"h-full w-full object-cover",style:{objectPosition:`${t(e.imagemPosX)}% ${t(e.imagemPosY)}%`,transform:`scale(${p(e.imagemZoom)/100})`}})}):"—",details:a.jsxs("div",{className:"space-y-1 text-sm",children:[a.jsx(M,{label:"Ordem:",value:String(e.ordem)}),a.jsx(M,{label:"Ajuste:",value:`X ${t(e.imagemPosX)}% · Y ${t(e.imagemPosY)}% · Zoom ${p(e.imagemZoom)}%`})]}),actions:a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:A,onClick:()=>{X(e),h({imagemUrl:e.imagemUrl,legenda:e.legenda??"",ordem:e.ordem,imagemPosX:t(e.imagemPosX),imagemPosY:t(e.imagemPosY),imagemZoom:p(e.imagemZoom)})},children:"Editar"}),a.jsx("button",{type:"button",className:W,onClick:async()=>
1{if(confirm("Remover esta imagem da galeria?"))try{await me(String(e.id)),await f()}catch(s){r(s instanceof Error?s.message:"Erro")}},children:"Remover"})]})},e.id))})]})]})]})}export{ve 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.