PageSourceSearch

https://eventosfidelidade.lovable.app/assets/Collaborator-CMasXuLh.js

js eventosfidelidade.lovable.app collected 2026-10-03 03:30:50 UTC 3,979 bytes, 1 lines download raw bytes

1import{r,s as l,j as e,S as y,N as f,B as i,L as w,M as C,h}from"./index-D9XUPvtJ.js";import{u as _}from"./useAuth-BJH9T3e-.js";import{B as k}from"./badge-RlcGX9Kx.js";import{a as E,f as S}from"./format-c2UCPg_n.js";import{H as p}from"./heart-dzbqCrPM.js";import{L as B}from"./log-out-zPPqg2t_.js";import{C as z}from"./circle-check-vNglAmwq.js";function R(){const{user:n,isAdmin:j,isCollaborator:v,loading:g}=_(),[c,N]=r.useState([]),[t,m]=r.useState(null),[u,x]=r.useState([]);if(r.useEffect(()=>{n&&l.from("event_collaborators").select("event_id, events(id, title, starts_at)").eq("user_id",n.id).then(({data:s})=>{const a=(s||[]).map(d=>d.events).filter(Boolean);N(a),a.length&&m(a[0].id)})},[n]),r.useEffect(()=>{t&&l.from("registrations").select("*, events(title)").eq("event_id",t).order("created_at",{ascending:!1}).then(({data:s})=>x(s||[]))},[t]),g)return e.jsx("div",{className:"p-8",children:e.jsx(y,{className:"h-8 w-64"})});if(!n)return e.jsx(f,{to:"/auth",replace:!0});if(j)return e.jsx(f,{to:"/admin",replace:!0});if(!v)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center p-8 text-center gap-4",children:[e.jsx(p,{className:"h-12 w-12 text-primary"}),e.jsx("h1",{className:"font-serif text-2xl",children:"Acesso restrito"}),e.jsx(i,{asChild:!0,variant:"outline",children:e.jsx(w,{to:"/",children:"Voltar"})})]});async function b(s){const{error:a}=await l.from("registrations").update({payment_status:"confirmada"}).eq("id",s);if(a)return h.error("Erro ao confirmar");h.success("Confirmado"),x(d=>d.map(o=>o.id===s?{...o,payment_status:"confirmada"}:o))}return e.jsxs("div",{className:"min-h-screen bg-secondary/30",children:[e.jsx("header",{className:"border-b border-border bg-background/80 backdrop-blur-xl",children:e.jsxs("div",{className:"container flex items-center justify-between py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-9 w-9 rounded-full gradient-primary flex items-center justify-center",children:e.jsx(p,{className:"h-4 w-4 text-primary-foreground",fill:"currentColor"})}),e.jsx("span",{className:"font-serif text-lg",children:"Área do Colaborador"})]}),e.jsxs(i,{variant:"ghost",size:"sm",onClick:()=>l.auth.signOut(),children:[e.jsx(B,{className:"h-4 w-4 mr-1"})," Sair"]})]})}),e.jsx("main",{className:"container py-8 space-y-6",children:c.length===0?e.jsx("div",{className:"text-center py-16 text-muted-foreground",children:"Nenhum evento atribuído ainda."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:c.map(s=>e.jsx(i,{variant:t===s.id?"default":"outline",size:"sm",onClick:()=>m(s.id),className:t===s.id?"gradient-primary border-0":"",children:s.title},s.id))}),e.jsx("div",{className:"rounded-2xl bg-card border border-border/50 shadow-soft overflow-hidden",children:u.length===0?e.jsx("div",{className:"p-10 text-center text-muted-foreground",children:"Nenhuma inscrição."}):e.jsx("div",{className:"divide-y divide-border/50",children:u.map(s=>e.jsxs("div",{className:"p-4 flex flex-col md:flex-row md:items-center gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium",children:s.full_name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[E(s.created_at)," • ",S(s.amount_cents)]})]}),e.jsx(k,{variant:"secondary",children:s.payment_status}),e.jsxs("div",{className:"flex gap-2",children:[s.whatsapp&&e.jsx(i,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs("a",{href:`https://wa.me/55${s.whatsapp.replace(/\D/g,"")}`,target:"_blank",rel:"noopener",children:[e.jsx(C,{className:"h-3.5 w-3.5 mr-1"})," WhatsApp"]})}),s.payment_status!=="confirmada"&&s.payment_status!=="gratuita"&&e.jsxs(i,{size:"sm",variant:"outline",onClick:()=>b(s.id),children:[e.jsx(z,{className:"h-3.5 w-3.5 mr-1"})," Confirmar"]})]})]},s.id))})})]})})]})}export{R 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.