PageSourceSearch

https://timeout-lead-generator.lovable.app/assets/GalleryManagement-DxO_aRss.js

js timeout-lead-generator.lovable.app collected 2026-10-03 03:50:58 UTC 10,304 bytes, 6 lines download raw bytes

1import{c as P,x as z,$ as H,r as u,j as e,s as x}from"./index-B7DbhkgB.js";import{u as B}from"./useQuery-DP7jHolT.js";import{u as w}from"./useMutation-K0_miVXo.js";import{A as W,I as D}from"./AdminLayout-OC1j5U9q.js";import{B as p}from"./button-BU4-mqBf.js";import{I as S,L as T}from"./input-B2ZJJM4K.js";import{L as g}from"./label-DThxe-a-.js";import{C as J,a as X,b as Y,d as Z}from"./card-CnEUtixb.js";import{S as ee}from"./switch-D3Xv9onm.js";import{D as ae,d as se,a as te,b as re,c as ie}from"./dialog-B8brT6hV.js";import{S as le,a as oe,b as ne,c as ce,d as q}from"./select-Swoal9jq.js";import{A as de,a as me,b as ue,c as xe,d as he,e as pe,f as ge,g as fe,h as je}from"./alert-dialog-CCcy-3Ks.js";import{a as ye,b as F,D as ve,c as be,S as Ne,v as we,u as Se,C as Ce,G as _e,s as De,K as Ee,P as Ae,d as Ie}from"./sortable.esm-BPhkaRP_.js";import{E as Te}from"./eye-BkH2Wo43.js";import{P as qe}from"./plus-D5aWkWbS.js";import{U as k}from"./upload-C5x_Yc-8.js";import{T as Fe}from"./trash-2-e5IazA_j.js";import"./use-mobile-DJ2ClU-u.js";import"./index-BXIjWHHc.js";import"./index-BT_i-wVq.js";import"./logo-timeout-horizontal-black-DkF39ZP1.js";import"./users-Cf8d_JKJ.js";import"./building-2--ua1dlPW.js";import"./store-BbDfeQ5X.js";import"./ticket-DziRcsOL.js";import"./user-check-Eft--jfG.js";import"./circle-check-ffUn0Cej.js";import"./index-CNzhP8PW.js";import"./index-C0zlKoxO.js";import"./check-D5b_86Ga.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ke=P("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),Le=({item:r,onToggleActive:d,onDelete:C})=>{const{attributes:f,listeners:j,setNodeRef:y,transform:v,transition:b,isDragging:l}=Se({id:r.id}),o={transform:Ce.Transform.toString(v),transition:b,opacity:l?.5:1};return e.jsxs("div",{ref:y,style:o,className:"flex items-center gap-4 p-4 bg-card border border-border rounded-lg",children:[e.jsx("button",{className:"cursor-grab active:cursor-grabbing text-muted-foreground hover:text-foreground",...f,...j,children:e.jsx(_e,{className:"h-5 w-5"})}),e.jsx("div",{className:"w-24 h-16 rounded overflow-hidden bg-muted flex-shrink-0",children:r.type==="video"?e.jsx("video",{src:r.media_url,className:"w-full h-full object-cover",muted:!0}):e.jsx("img",{src:r.media_url,alt:r.alt_text||"Gallery item",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.type==="video"?e.jsx(ke,{className:"h-4 w-4 text-primary"}):e.jsx(D,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm capitalize",children:r.type==="video"?"Vídeo":"Imagem"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r.alt_text||"Sem descrição"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{htmlFor:`active-${r.id}`,className:"text-sm text-muted-foreground",children:"Ativo"}),e.jsx(ee,{id:`active-${r.id}`,checked:r.is_active,onCheckedChange:n=>d(r.id,n)})]}),e.jsxs(de,{children:[e.jsx(me,{asChild:!0,children:e.jsx(p,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:e.jsx(Fe,{className:"h-4 w-4"})})}),e.jsxs(ue,{children:[e.jsxs(xe,{children:[e.jsx(he,{children:"Excluir item"}),e.jsx(pe,{children:"Tem certeza que deseja excluir este item da galeria? Esta ação não pode ser desfeita."})]}),e.jsxs(ge,{children:[e.jsx(fe,{children:"Cancelar"}),e.jsx(je,{onClick:()=>C(r.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Excluir"})]})]})]})]})]})},ua=()=>{const{toast:r}=z(),d=H(),[C,f]=u.useState(!1),[j,y]=u.useState(!1),v=u.useRef(null),b=u.useRef(null),[l,o]=u.useState({type:"image",media_url:"",thumbnail_url:"",alt_text:""}),[n,E]=u.useState(null),[N,A]=u.useState(null),L=ye(F(Ae),F(Ee,{coordinateGetter:De})),{data:c=[],isLoading:G}=B({queryKey:["gallery-items"],queryFn:async()=>{const{data:a,error:s}=await x.from("gallery_items").select("*").order("display_order",{ascending:!0});if(s)throw s;return a}}),I=async(a,s)=>{const t=a.name.split(".").pop(),i=`${s}/${Date.now()}-${Math.random().toString(36).substring(7)}.${t}`,{error:m}=await x.storage.from("media").upload(i,a);if(m)throw m;const{data:{publicUrl:h}}=x.storage.from("media").getPublicUrl(i);return h},M=w({mutationFn:async a=>{y(!0);let s=a.media_url,t=a.thumbnail_url;n&&(s=await I(n,"gallery")),N&&(t=await I(N,"gallery/thumbnails"));const i=c.length>0?Math.max(...c.map(h=>h.display_order)):0,{error:m}=await x.from("gallery_items").insert({type:a.type,media_url:s,thumbnail_url:t||null,alt_text:a.alt_text||null,display_order:i+1});if(m)throw m},onSuccess:()=>{d.invalidateQueries({queryKey:["gallery-items"]}),f(!1),o({type:"image",media_url:"",thumbnail_url:"",alt_text:""}),E(null),A(null),r({title:"Item adicionado com sucesso!"})},onError:a=>{r({title:"Erro ao adicionar item",description:a.message,variant:"destructive"})},onSettled:()=>{y(!1)}}),U=w({mutationFn:async({id:a,isActive:s})=>{const{error:t}=await x.from("gallery_items").update({is_active:s}).eq("id",a);if(t)throw t},onSuccess:()=>{d.invalidateQueries({queryKey:["gallery-items"]})},onError:a=>{r({title:"Erro ao atualizar",description:a.message,variant:"destructive"})}}),V=w({mutationFn:async a=>{const{error:s}=await x.from("gallery_items").delete().eq("id",a);if(s)throw s},onSuccess:()=>{d.invalidateQueries({queryKey:["gallery-items"]}
6),r({title:"Item excluído com sucesso!"})},onError:a=>{r({title:"Erro ao excluir",description:a.message,variant:"destructive"})}}),K=w({mutationFn:async a=>{const s=a.map((t,i)=>({id:t.id,display_order:i+1}));for(const t of s){const{error:i}=await x.from("gallery_items").update({display_order:t.display_order}).eq("id",t.id);if(i)throw i}},onSuccess:()=>{d.invalidateQueries({queryKey:["gallery-items"]})},onError:a=>{r({title:"Erro ao reordenar",description:a.message,variant:"destructive"})}}),R=a=>{const{active:s,over:t}=a;if(t&&s.id!==t.id){const i=c.findIndex(_=>_.id===s.id),m=c.findIndex(_=>_.id===t.id),h=Ie(c,i,m);d.setQueryData(["gallery-items"],h),K.mutate(h)}},Q=a=>{var t;const s=(t=a.target.files)==null?void 0:t[0];s&&(E(s),s.type.startsWith("video/")?o(i=>({...i,type:"video"})):o(i=>({...i,type:"image"})))},$=a=>{var t;const s=(t=a.target.files)==null?void 0:t[0];s&&A(s)},O=a=>{if(a.preventDefault(),!n&&!l.media_url){r({title:"Selecione um arquivo ou insira uma URL",variant:"destructive"});return}M.mutate(l)};return e.jsx(W,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Galeria de Eventos"}),e.jsx("p",{className:"text-muted-foreground",children:"Gerencie fotos e vídeos das edições anteriores"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(p,{variant:"outline",onClick:()=>window.open("/#galeria","_blank"),children:[e.jsx(Te,{className:"h-4 w-4 mr-2"}),"Ver no Site"]}),e.jsxs(ae,{open:C,onOpenChange:f,children:[e.jsx(se,{asChild:!0,children:e.jsxs(p,{children:[e.jsx(qe,{className:"h-4 w-4 mr-2"}),"Adicionar Item"]})}),e.jsxs(te,{className:"max-w-md",children:[e.jsx(re,{children:e.jsx(ie,{children:"Adicionar à Galeria"})}),e.jsxs("form",{onSubmit:O,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{children:"Tipo"}),e.jsxs(le,{value:l.type,onValueChange:a=>o({...l,type:a}),children:[e.jsx(oe,{children:e.jsx(ne,{})}),e.jsxs(ce,{children:[e.jsx(q,{value:"image",children:"Imagem"}),e.jsx(q,{value:"video",children:"Vídeo"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{children:"Arquivo de Mídia"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{type:"file",ref:v,onChange:Q,accept:l.type==="video"?"video/*":"image/*",className:"hidden"}),e.jsxs(p,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{var a;return(a=v.current)==null?void 0:a.click()},children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),n?n.name:"Escolher arquivo"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ou insira uma URL abaixo"}),e.jsx(S,{placeholder:"https://exemplo.com/media.jpg",value:l.media_url,onChange:a=>o({...l,media_url:a.target.value}),disabled:!!n})]}),l.type==="video"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{children:"Thumbnail (opcional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{type:"file",ref:b,onChange:$,accept:"image/*",className:"hidden"}),e.jsxs(p,{type:"button",variant:"outline",className:"flex-1",onClick:()=>{var a;return(a=b.current)==null?void 0:a.click()},children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),N?N.name:"Escolher thumbnail"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{children:"Descrição (Alt Text)"}),e.jsx(S,{placeholder:"Descreva a imagem ou vídeo",value:l.alt_text,onChange:a=>o({...l,alt_text:a.target.value})})]}),e.jsx(p,{type:"submit",className:"w-full",disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-4 w-4 mr-2 animate-spin"}),"Enviando..."]}):"Adicionar"})]})]})]})]})]}),e.jsxs(J,{children:[e.jsx(X,{children:e.jsxs(Y,{className:"text-lg flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5"}),"Itens da Galeria"]})}),e.jsx(Z,{children:G?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(T,{className:"h-8 w-8 animate-spin text-primary"})}):c.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(D,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"Nenhum item na galeria"}),e.jsx("p",{className:"text-sm",children:"Adicione fotos e vídeos para exibir no site"})]}):e.jsx(ve,{sensors:L,collisionDetection:be,onDragEnd:R,children:e.jsx(Ne,{items:c.map(a=>a.id),strategy:we,children:e.jsx("div",{className:"space-y-2",children:c.map(a=>e.jsx(Le,{item:a,onToggleActive:(s,t)=>U.mutate({id:s,isActive:t}),onDelete:s=>V.mutate(s)},a.id))})})})})]})]})})};export{ua 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.