PageSourceSearch

https://flyzone.ai/assets/SeriesRegistration-CxRJsoD7.js

js flyzone.ai collected 2026-10-05 14:02:26 UTC 12,006 bytes, 1 lines download raw bytes

1import{j as e}from"./query-vendor-kxTUL8xS.js";import{r as c,j as L,u as k}from"./react-vendor-khT9Z53Y.js";import{s as u,V as C,aI as R,C as B,a2 as A,a3 as U,a4 as z,w as M,X as H,I as O,l as V,p as S,B as P}from"./index-BbOD_7nn.js";import{c as K}from"./stripeSeriesPayment-HAM9mKb7.js";import{Footer as Q}from"./Footer-d_lOnYxp.js";import{k as W,a as T,q as X,g as Y,aQ as G,az as J,C as Z}from"./icons-BiI5kjMG.js";import"./supabase-vendor-C5ZKNp5m.js";import"./three-vendor-BtPU5qJZ.js";import"./ui-vendor-CKjFZaXr.js";import"./charts-BgRsSA2X.js";import"./date-sYG5kfAo.js";import"./animation-UXgLsWqg.js";import"./maps-BturGVvf.js";import"./form-D94rrrgd.js";import"./i18n-CVQZWYkC.js";const ee=()=>{const[f,h]=c.useState(!1),{toast:l}=C();return{loading:f,createSeriesRegistration:async a=>{h(!0);try{const{data:{user:i}}=await u.auth.getUser();if(!i)return l({title:"Authentication Required",description:"Please sign in to register for the series",variant:"destructive"}),null;const{data:p,error:r}=await u.from("series_registrations").insert({series_id:a.seriesId,user_id:i.id,team_name:a.teamName,discount_percentage:a.discountPercentage,total_amount:a.totalAmount,registration_status:"pending",payment_status:"pending"}).select().single();if(r)return console.error("Error creating series registration:",r),l({title:"Registration Failed",description:"Failed to create series registration",variant:"destructive"}),null;const{data:o}=await u.from("profiles").select("first_name, last_name, email, phone_number, address, zip_code").eq("id",i.id).single();if(!o)return l({title:"Profile Required",description:"Please complete your profile before registering",variant:"destructive"}),null;const d=a.tournamentIds.map(g=>({tournament_id:g,user_id:i.id,first_name:o.first_name||"",last_name:o.last_name||"",email:o.email||i.email||"",phone:o.phone_number||"",address:o.address||"",zip_code:o.zip_code||"",boat_option:a.selectedBoats[g]?"charter":"own",selected_boat_id:a.selectedBoats[g],boat_price:0,registration_fee:0,total_amount:0,series_registration_id:p.id,payment_status:"pending"})),{error:v}=await u.from("registrations").insert(d);return v?(console.error("Error creating tournament registrations:",v),await u.from("series_registrations").delete().eq("id",p.id),l({title:"Registration Failed",description:"Failed to create tournament registrations",variant:"destructive"}),null):(l({title:"Registration Created",description:"Series registration created successfully. Proceeding to payment..."}),p)}catch(i){return console.error("Error in createSeriesRegistration:",i),l({title:"Error",description:"An unexpected error occurred",variant:"destructive"}),null}finally{h(!1)}},updateSeriesRegistrationPayment:async(a,i,p)=>{try{const{error:r}=await u.from("series_registrations").update({payment_intent_id:i,stripe_session_id:p,payment_status:"completed",registration_status:"confirmed"}).eq("id",a);return r?(console.error("Error updating payment status:",r),!1):(await u.from("registrations").update({payment_status:"completed"}).eq("series_registration_id",a),!0)}catch(r){return console.error("Error in updateSeriesRegistrationPayment:",r),!1}}}},se=f=>{const[h,l]=c.useState(!0),[b,t]=c.useState(null),[a,i]=c.useState(null);return c.useEffect(()=>{(async()=>{if(f)try{l(!0);const{data:r,error:o}=await u.from("tournaments").select("series_discount_percentage, series_discount_type").eq("id",f).single();if(o)throw o;const{data:d,error:v}=await u.from("tournaments").select("id, name, entry_fee").eq("series_id",f).order("start_date",{ascending:!0});if(v)throw v;if(!d||d.length===0){t(null);return}const g=d.reduce((x,n)=>x+(n.entry_fee||0),0),w=(r==null?void 0:r.series_discount_percentage)||15;let N;(r==null?void 0:r.series_discount_type)==="fixed_amount"?N=Math.max(0,g-w):N=g*(1-w/100);const _=g-N;t({tournaments:d,individualTotal:g,seriesTotal:N,savings:_,discountPercentage:w})}catch(r){console.error("Error fetching pricing:",r),i(r instanceof Error?r.message:"Failed to fetch pricing")}finally{l(!1)}})()},[f]),{loading:h,pricingData:b,error:a}},re=()=>{const[f]=L();k();const{toast:h}=C(),{loading:l,createSeriesRegistration:b}=ee(),[t,a]=c.useState(1),[i,p]=c.useState(null),[r,o]=c.useState([]),[d,v]=c.useState(""),[g,w]=c.useState({}),[N,_]=c.useState(!1),x=f.get("eventId"),{pricingData:n,loading:D}=se(x);c.useEffect(()=>{(async()=>
1{if(x)try{const{data:m,error:j}=await u.from("tournaments").select("*").eq("id",x).single();if(j)throw j;p(m);const{data:y,error:E}=await u.from("tournaments").select("id, name, start_date, end_date, location_formatted_address, venue_name").eq("series_id",x).order("start_date",{ascending:!0});if(E)throw E;o(y||[])}catch(m){console.error("Error fetching series data:",m),h({title:"Error",description:"Failed to load series information",variant:"destructive"})}})()},[x,h]);const I=()=>{if(t===1&&!d.trim()){h({title:"Team Name Required",description:"Please enter your team name",variant:"destructive"});return}a(s=>Math.min(s+1,3))},$=()=>{a(s=>Math.max(s-1,1))},q=async()=>{if(!(!x||!n)){_(!0);try{const s={seriesId:x,teamName:d,tournamentIds:r.map(y=>y.id),selectedBoats:g,discountPercentage:n.discountPercentage,totalAmount:n.seriesTotal},m=await b(s);if(!m){_(!1);return}const{url:j}=await K({seriesRegistrationId:m.id,seriesName:i.name,totalAmount:n.seriesTotal,tournamentIds:r.map(y=>y.id),successUrl:`${window.location.origin}/series-registration/success?session_id={CHECKOUT_SESSION_ID}&seriesRegistrationId=${m.id}`,cancelUrl:`${window.location.origin}/series-registration?eventId=${x}`});j&&(window.location.href=j)}catch(s){console.error("Error processing payment:",s),h({title:"Payment Error",description:"Failed to process payment. Please try again.",variant:"destructive"}),_(!1)}}},F=(s,m)=>{if(!s)return"TBD";const j=new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric"});if(!m||m===s)return j;const y=new Date(m).toLocaleDateString("en-US",{month:"short",day:"numeric"});return`${j} - ${y}`};return!i||D?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(R,{}),e.jsx("div",{className:"page-content-with-header flex items-center justify-center",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary"})})]}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(R,{}),e.jsx("div",{className:"page-content-with-header pb-16",children:e.jsxs("div",{className:"container mx-auto px-4 max-w-4xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(W,{className:"h-8 w-8 text-primary"}),e.jsx("h1",{className:"text-3xl font-bold",children:"Series Registration"})]}),e.jsxs("p",{className:"text-muted-foreground",children:["Register for the complete ",i.name,n&&` - Save ${n.discountPercentage}%!`]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(s=>e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsx("div",{className:`flex items-center justify-center w-10 h-10 rounded-full border-2 ${t>=s?"bg-primary border-primary text-primary-foreground":"border-muted-foreground text-muted-foreground"}`,children:t>s?e.jsx(T,{className:"h-5 w-5"}):s}),s<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 ${t>s?"bg-primary":"bg-muted"}`})]},s))}),e.jsxs("div",{className:"flex justify-between mt-2",children:[e.jsx("span",{className:"text-sm",children:"Team Info"}),e.jsx("span",{className:"text-sm",children:"Tournaments"}),e.jsx("span",{className:"text-sm",children:"Review"})]})]}),e.jsxs(B,{children:[e.jsxs(A,{children:[e.jsxs(U,{children:[t===1&&"Team Information",t===2&&"Tournament Selection",t===3&&"Review & Confirm"]}),e.jsxs(z,{children:[t===1&&"Enter your team details for all tournaments",t===2&&"View tournaments included in this series",t===3&&"Review your registration before proceeding"]})]}),e.jsxs(M,{className:"space-y-6",children:[t===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(H,{htmlFor:"teamName",children:"Team Name *"}),e.jsx(O,{id:"teamName",value:d,onChange:s=>v(s.target.value),placeholder:"Enter your team name",className:"mt-2"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"This name will be used for all tournaments in the series"})]})}),t===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-4 mb-4",children:e.jsxs("p",{className:"text-sm font-semibold text-primary",children:["All ",r.length," tournaments are included in your series registration"]})}),r.map(s=>e.jsx("div",{className:"border rounded-lg p-4 hover:border-primary/50 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold mb-2",children:s.name}),e.jsxs("div",{className:"flex flex-col gap-1 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx("span",{children:F(s.start_date,s.end_date)})]}),(s.location_formatted_address||s.venue_name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),e.jsx("span",{className:"line-clamp-1",children:s.venue_name||s.location_formatted_address})]})]})]}),e.jsx(V,{variant:"secondary",children:"Included"})]})},s.id))]}),t===3&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Team Information"}),e.jsxs("p",{className:"text-muted-foreground",children:["Team Name: ",d]})]}),e.jsx(S,{}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-2",children:["Tournaments (",r.length,")"]}),e.jsx("ul",{className:"space-y-1",children:r.map(s=>e.jsxs("li",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(T,{className:"h-4 w-4 text-primary"}),s.name]},s.id))})]}),e.jsx(S,{}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Individual Total"}),e.jsxs("span",{className:"line-through text-muted-foreground",children:["$",n.individualTotal.toLocaleStr
1ing()]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Series Discount (",n.discountPercentage,"%)"]}),e.jsxs("span",{className:"text-green-600 font-semibold",children:["-$",n.savings.toLocaleString()]})]}),e.jsx(S,{}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-lg font-semibold",children:"Total Amount"}),e.jsxs("span",{className:"text-2xl font-bold text-primary",children:["$",n.seriesTotal.toLocaleString()]})]})]}),e.jsxs("div",{className:"bg-primary/5 border border-primary/20 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(G,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-semibold",children:"Series Savings"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You're saving $",n.savings.toLocaleString()," by registering for the complete series!"]})]})]})]}),e.jsxs("div",{className:"flex justify-between pt-6",children:[e.jsxs(P,{variant:"outline",onClick:$,disabled:t===1,children:[e.jsx(J,{className:"h-4 w-4 mr-2"}),"Back"]}),t<3?e.jsxs(P,{onClick:I,children:["Next",e.jsx(Z,{className:"h-4 w-4 ml-2"})]}):e.jsx(P,{onClick:q,disabled:l||N,className:"bg-gradient-to-r from-primary to-blue-600 hover:from-primary/90 hover:to-blue-700",children:N?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Processing..."]}):e.jsx(e.Fragment,{children:"Proceed to Payment"})})]})]})]})]})}),e.jsx(Q,{})]})};function je(){return e.jsx(re,{})}export{je 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.