PageSourceSearch

https://faf.co.ao/assets/TicketDetail-C5OVQvCj.js

js faf.co.ao collected 2026-10-02 19:11:06 UTC 8,450 bytes, 1 lines download raw bytes

1import{y as D,s as I,r as b,z as Q,b as S,j as e,L as q}from"./vendor-react-core-_0sZDOLQ.js";import{c as y,B as l,b as c}from"./index-j07E1qHv.js";import{C as m,a as x,b as f,c as N}from"./card-DHmBnTdH.js";import{B as v}from"./badge-BXqwvh8U.js";import{I as w}from"./input-rti45mgP.js";import{L as o}from"./label-7HT5__eZ.js";import{R as $,a as K}from"./radio-group-Cr2lmstz.js";import{t as h}from"./index-CDqomOa1.js";import{h as E}from"./vendor-utils-BRu4i-LD.js";import{T as G,_ as O,Z as U,aN as V,aO as Y}from"./vendor-lucide-Ddz0eB7N.js";import"./vendor-radix-CFmJ1img.js";import"./vendor-supabase-Ca6cp8v2.js";import"./vendor-framer-motion-C1oRD-X5.js";const p={vip:{name:"VIP",color:"bg-yellow-100 text-yellow-800"},bancada:{name:"Bancada",color:"bg-blue-100 text-blue-800"},geral:{name:"Geral",color:"bg-gray-100 text-gray-800"}};function oe(){const B=D(),T=I(),r=new URLSearchParams(window.location.search).get("matchId"),[a,_]=b.useState(null),[i,d]=b.useState(1),[C,k]=b.useState(!1),{register:j,handleSubmit:z,formState:{errors:u}}=Q(),{data:s,isLoading:F}=S({queryKey:["match",r],queryFn:async()=>(await c.entities.Match.filter({id:r}))[0],enabled:!!r}),{data:L,isLoading:M}=S({queryKey:["match-tickets",r],queryFn:()=>c.entities.Ticket.filter({match_id:r}),initialData:[],enabled:!!r}),P=async t=>{if(!a){h.error("Selecione um tipo de bilhete");return}k(!0);try{const n=`FAF-${Date.now()}-${Math.random().toString(36).substr(2,9).toUpperCase()}`,g=await c.entities.TicketPurchase.create({ticket_code:n,match_id:r,match_details:{home_team:s.home_team,away_team:s.away_team,match_date:s.match_date,venue:s.venue,competition:s.competition},ticket_type:a.ticket_type,sector:a.sector,price:a.price,quantity:i,buyer_name:t.name,buyer_email:t.email,buyer_phone:t.phone,status:"pending"}),A=await c.functions.invoke("multicaixaGenerateReference",{type:"ticket",entityId:g.id,amount:a.price*i,description:`Bilhete ${s.home_team} vs ${s.away_team}`});await c.entities.Ticket.update(a.id,{quantity_available:a.quantity_available-i}
1),T.invalidateQueries(["match-tickets",r]),A.data.success?h.success("Bilhete reservado! Referência de pagamento gerada."):h.warning("Bilhete reservado, mas falha ao gerar referência"),B(y("MyTickets"))}catch(n){h.error("Erro ao comprar bilhete"),console.error(n)}finally{k(!1)}};if(F||M)return e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 border-4 border-red-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"A carregar bilhetes..."})]})});if(!s)return e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(G,{className:"w-20 h-20 text-gray-300 mx-auto mb-4"}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Jogo não encontrado"}),e.jsx(q,{to:y("Ticketing"),children:e.jsx(l,{children:"Voltar à Bilheteira"})})]})});const R=a?a.price*i:0;return e.jsx("main",{className:"min-h-screen bg-gray-50 py-12",children:e.jsxs("div",{className:"container mx-auto px-4",children:[e.jsx(q,{to:y("Ticketing"),children:e.jsxs(l,{variant:"ghost",className:"mb-6",children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Voltar à Bilheteira"]})}),e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx(m,{className:"mb-8",children:e.jsxs(x,{className:"p-8",children:[e.jsx(v,{className:"mb-4 bg-red-100 text-red-700",children:s.competition}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[s.home_logo&&e.jsx("img",{src:s.home_logo,alt:s.home_team,loading:"lazy",decoding:"async",className:"w-16 h-16 object-contain"}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:s.home_team})]}),e.jsx("span",{className:"text-3xl font-bold text-gray-400",children:"vs"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:s.away_team}),s.away_logo&&e.jsx("img",{src:s.away_logo,alt:s.away_team,loading:"lazy",decoding:"async",className:"w-16 h-16 object-contain"})]})]}),e.jsxs("div",{className:"flex gap-6 text-gray-600",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"w-5 h-5"}),E(s.match_date).format("DD/MM/YYYY HH:mm")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"w-5 h-5"}),s.venue]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(m,{children:[e.jsx(f,{children:e.jsx(N,{children:"Selecione o Tipo de Bilhete"})}),e.jsx(x,{className:"space-y-4",children:e.jsx($,{value:a==null?void 0:a.id,onValueChange:t=>{const n=L.find(g=>g.id===t);_(n),d(1)},children:L.map(t=>e.jsxs("div",{className:`flex items-center space-x-3 border rounded-lg p-4 cursor-pointer hover:border-red-600 transition ${(a==null?void 0:a.id)===t.id?"border-red-600 bg-red-50":""}`,onClick:()=>{_(t),d(1)},children:[e.jsx(K,{value:t.id,id:t.id}),e.jsx(o,{htmlFor:t.id,className:"flex-1 cursor-pointer",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(v,{className:`${p[t.ticket_type].color} mb-2`,children:p[t.ticket_type].name}),e.jsx("p",{className:"font-semibold text-gray-900",children:t.sector}),e.jsxs("p",{className:"text-sm text-gray-600",children:["Disponíveis: ",t.quantity_available]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("p",{className:"text-2xl font-bold text-red-600",children:[t.price.toLocaleString("pt-AO")," Kz"]})})]})})]},t.id))})})]}),a&&e.jsxs(m,{children:[e.jsx(f,{children:e.jsx(N,{children:"Dados do Comprador"})}),e.jsx(x,{children:e.jsxs("form",{onSubmit:z(P),className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"name",children:"Nome Completo *"}),e.jsx(w,{id:"name",...j("name",{required:!0}),className:u.name?"border-red-500":""})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"email",children:"Email *"}),e.jsx(w,{id:"email",type:"email",...j("email",{required:!0}),className:u.email?"border-red-500":""})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"phone",children:"Telefone *"}),e.jsx(w,{id:"phone",...j("phone",{required:!0}),className:u.phone?"border-red-500":""})]})]}),e.jsx(l,{type:"submit",disabled:C,className:"w-full bg-red-600 hover:bg-red-700",size:"lg",children:C?"A processar...":"Confirmar Compra"})]})})]})]}),a&&e.jsx("div",{children:e.jsxs(m,{className:"sticky top-24",children:[e.jsx(f,{children:e.jsx(N,{children:"Resumo"})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Quantidade"}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsx(l,{type:"button",variant:"outline",size:"icon",onClick:()=>d(Math.max(1,i-1)),children:"-"}),e.jsx("span",{className:"text-xl font-bold w-12 text-center",children:i}),e.jsx(l,{type:"button",variant:"outline",size:"icon",onClick:()=>d(Math.min(a.quantity_available,i+1)),children:"+"})]})]}),e.jsxs("div",{className:"border-t pt-4 space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Tipo de Bilhete"}),e.jsx(v,{className:p[a.ticket_type].color,children:p[a.ticket_type].name})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Preç
1o Unitário"}),e.jsxs("span",{children:[a.price.toLocaleString("pt-AO")," Kz"]})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:"Quantidade"}),e.jsx("span",{children:i})]}),e.jsxs("div",{className:"flex justify-between text-lg font-bold pt-2 border-t",children:[e.jsx("span",{children:"Total"}),e.jsxs("span",{className:"text-red-600",children:[R.toLocaleString("pt-AO")," Kz"]})]})]}),e.jsxs("div",{className:"bg-blue-50 p-4 rounded-lg text-sm text-blue-900",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Y,{className:"w-4 h-4"}),e.jsx("span",{className:"font-semibold",children:"Pagamento Multicaixa"})]}),e.jsx("p",{className:"text-xs",children:"Após a confirmação, receberá a referência de pagamento por email"})]})]})]})})]})]})]})})}export{oe 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.