PageSourceSearch

https://sunset-spike.up.railway.app/assets/TournamentAdminShell-Cr-RZZxh.js

js sunset-spike.up.railway.app collected 2026-10-03 12:16:18 UTC 17,600 bytes, 1 lines download raw bytes

1import{G as pe,u as I,a as Te,dP as be,dH as je,b5 as ve,j as e,b7 as Ce,dQ as ye,dR as Se,b8 as E,b9 as z,ba as q,bb as _,bc as W,bd as B,dS as Ne,bh as se,bi as ne,bj as re,bk as oe,bl as G,bn as we,B as F,d0 as me,cB as de,af as ue,dT as Pe,dU as Ae,dV as De,dW as ke,a4 as Ie,a6 as Ee,a7 as ze,a8 as qe,bL as _e,dX as fe,dj as Me,dY as ge,dZ as Z,aq as P,bv as X,d_ as Fe,d$ as Ue,dG as Be,e0 as Le,c0 as Y,e1 as Oe,m as Re,e2 as $e,e3 as Ke,e4 as Qe,e5 as Ve,e6 as We,e7 as C,dK as Ge,e8 as He,e9 as Xe,ea as Ye,bJ as Ze,h as Je,d7 as et,c1 as tt,b$ as at,I as st,dt as nt,cS as rt,cT as ot,cU as it,cW as lt,dL as ct,_ as xe,L as $,dO as mt,c as dt}from"./index-onZ-siV6.js";import{r as x}from"./sentry-CwTBLAGw.js";import{K,o as ut,ao as M,g as ft,s as L,a_ as gt,an as ie,l as xt,U as le,Q as ht}from"./utils-SJutkBrZ.js";import{I as pt}from"./ImageSection-ECMjbBdW.js";import{u as Tt}from"./useTournamentAdminAction-0dlDqpK3.js";import{E as bt}from"./ellipsis-CqZmNbLA.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"36665b27cc5c935a9a1384aae7c036cb424779c4"};var u=new n.Error().stack;u&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[u]="0dbf8678-73e6-4e58-acb3-f2b245212c80",n._sentryDebugIdIdentifier="sentry-dbid-0dbf8678-73e6-4e58-acb3-f2b245212c80")}catch{}})();const jt=[["path",{d:"M10 12h.01",key:"1kxr2c"}],["path",{d:"M18 20V6a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v14",key:"36qu9e"}],["path",{d:"M2 20h20",key:"owomy5"}]],vt=pe("door-closed",jt),k="text-xs font-medium text-muted-foreground",Ct=180;function yt({formId:n="tournament-form",onSubmit:u,defaultImageUrl:s=null,onImageChange:d,isReadOnly:i=!1,isEdit:c=!1,structureLocked:f=!1,defaultValues:T}){const{t:r}=I("tournaments",{keyPrefix:"admin"}),{t:y}=I("common",{keyPrefix:"imageUpload"}),{getDefaultEventPrice:S,getDefaultMemberPrice:h}=Te(),A=x.useMemo(()=>{const t=be(Ct);return{title:"",slug:null,description:"",location:"Praia de Carcavelos",locationInstructions:"Near the Pirate",...t,fromDate:K(t.fromDate,4),toDate:K(t.toDate,4),timezone:je,latitude:null,longitude:null,googleMapsUrl:"https://maps.app.goo.gl/fPo7K3Nt4AzxU6GD7",groupId:null,levelId:null,mainCoachId:null,secondaryCoachId:null,allowFirstTimePerk:!1,allowPack:!1,allowWaitlistWhenFull:!1,isPrivate:!1,capacity:null,defaultPricing:S(),memberPricing:h(),firstTimePerkPricing:null,teamSize:2,maxRosterSize:2,maxTeams:null,minTeam
1s:2,registrationClosesAt:"",requireTeamNames:!1,...T}},[]),D=x.useMemo(()=>ut({title:L().min(1,r("create.errors.required")),location:L().min(1,r("create.errors.required")),fromDate:ie(),toDate:ie(),fromTime:L().min(1,r("create.errors.required")),toTime:L().min(1,r("create.errors.required")),teamSize:M().refine(t=>t===2||t===4),maxRosterSize:M().int().min(2).max(6),maxTeams:gt(t=>t===""||t===void 0?null:t,M().int().min(2).nullable()),minTeams:M().int().min(2),registrationClosesAt:L().min(1,r("create.errors.required")),requireTeamNames:ft(),defaultPricing:M({message:r("create.errors.required")}).min(0),memberPricing:M({message:r("create.errors.required")}).min(0).nullable().optional()}).passthrough().refine(t=>t.maxTeams===null||t.minTeams<=t.maxTeams,{path:["minTeams"],message:r("create.errors.minTeams")}).refine(t=>t.maxRosterSize>=t.teamSize,{path:["maxRosterSize"],message:"Roster capacity cannot be below team size"}).refine(t=>{const[l,g]=t.fromTime.split(":").map(Number),b=new Date(t.fromDate);return b.setHours(l||0,g||0,0,0),new Date(t.registrationClosesAt)<=b},{path:["registrationClosesAt"],message:r("create.errors.deadline")}),[r]),m=xt({resolver:ve(D),defaultValues:A}),o=le({control:m.control,name:"fromDate"}),N=x.useRef(null);x.useEffect(()=>{if(i||!o)return;const t=N.current;if(N.current=o,!t)return;const l=ht(o,t);if(l===0)return;const g=m.getValues("toDate");m.setValue("toDate",g?K(g,l):o)},[o,i,m]);
1const p=le({control:m.control,name:"fromTime"});return x.useEffect(()=>{if(i||c||!o)return;const t=K(o,-1),l=t.getFullYear(),g=String(t.getMonth()+1).padStart(2,"0"),b=String(t.getDate()).padStart(2,"0"),j=(p??"").slice(0,5)||"00:00";m.setValue("registrationClosesAt",`${l}-${g}-${b}T${j}`)},[o,p,i,c,m]),e.jsx(Ce,{...m,children:e.jsxs("form",{id:n,onSubmit:m.handleSubmit(u),className:"space-y-8",children:[e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r("create.eventSection")}),e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start",children:[e.jsxs("div",{className:"w-40 shrink-0 space-y-1.5",children:[e.jsx("p",{className:k,children:y("label")}),e.jsx(pt,{defaultImageUrl:s,onImageChange:t=>d?.(t),disabled:i})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(ye,{hidePrivate:!0,disabled:i})})]}),e.jsx(Se,{disabled:i||f}),e.jsx(E,{control:m.control,name:"registrationClosesAt",render:({field:t})=>e.jsxs(z,{children:[e.jsx(q,{className:k,children:r("create.fields.registrationClosesAt")}),e.jsx(_,{children:e.jsx(W,{type:"datetime-local",disabled:i||f,...t})}),e.jsx(B,{})]})})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r("create.pricingSection")}),e.jsx(Ne,{disabled:i||f,tiersOnly:!0})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold",children:r("create.formatSection")}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(E,{control:m.control,name:"teamSize",render:({field:t})=>e.jsxs(z,{children:[e.jsx(q,{className:k,children:r("create.fields.teamSize")}),e.jsxs(se,{onValueChange:l=>t.onChange(Number(l)),value:String(t.value),disabled:i||c,children:[e.jsx(_,{children:e.jsx(ne,{children:e.jsx(re,{})})}),e.jsxs(oe,{children:[e.jsx(G,{value:"2",children:r("create.teamSizes.doubles")}),e.jsx(G,{value:"4",children:r("create.teamSizes.quads")})]})]}),e.jsx(B,{})]})}),e.jsx(E,{control:m.control,name:"maxRosterSize",render:({field:t})=>e.jsxs(z,{children:[e.jsx(q,{className:k,children:"Maximum roster"}),e.jsxs(se,{onValueChange:l=>t.onChange(Number(l)),value:String(t.value),disabled:i||c,children:[e.jsx(_,{children:e.jsx(ne,{children:e.jsx(re,{})})}),e.jsx(oe,{children:[2,3,4,5,6].map(l=>e.jsxs(G,{value:String(l),disabled:l<(m.getValues("teamSize")||2),children:[l," players"]},l))})]}),e.jsx(B,{})]})})]}),e.jsx(E,{control:m.control,name:"requireTeamNames",render:({field:t})=>e.jsxs(z,{className:"rounded-lg border border-input p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(q,{className:k,children:r("create.fields.requireTeamNames")}),e.jsx(_,{children:e.jsx(we,{checked:t.value??!1,onCheckedChange:t.onChange,disabled:i||c})})]}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:t.value?r("create.fields.requireTeamNamesOnHint"):r("create.fields.requireTeamNamesOffHint")})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(E,{control:m.control,name:"minTeams",render:({field:t})=>e.jsxs(z,{children:[e.jsx(q,{className:k,children:r("create.fields.minTeams")}),e.jsx(_,{children:e.jsx(W,{type:"number",min:2,step:"1",disabled:i||f,...t})}),e.jsx(B,{})]})}),e.jsx(E,{control:m.control,name:"maxTeams",render:({field:t})=>e.jsxs(z,{children:[e.jsx(q,{className:k,children:r("create.fields.maxTeams")}),e.jsx(_,{children:e.jsx(W,{type:"number",min:2,step:"1",placeholder:r("create.fields.maxTeamsUnlimited"),disabled:i||f,...t,value:t.value??"",onChange:l=>t.onChange(l.target.value===""?null:l.target.value)})}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:r("create.fields.maxTeamsHint")}),e.jsx(B,{})]})})]})]})]})})}function St({formId:n="tournament-form",isSubmitting:u=!1,isEdit:s=!1,onCancel:d}){const{t:i}=I("tournaments",{keyPrefix:"admin"}),c=s?"edit":"create";return e.jsxs("div",{className:"flex justify-end items-center border-t pt-6 mt-6 w-full gap-2",children:[e.jsx(F,{type:"button",variant:"outline",onClick:d,children:i("create.cancel")}),e.jsx(F,{type:"submit",form:n,disabled:u,children:i(u?`${c}.creating`:`${c}.submit`)})]})}const Nt=({eventId:n,file:u})=>{const s=new FormData;return s.append("file",u),de({url:`/api/v1/events/${n}/image`,method:"POST",headers:{"Content-Type":"multipart/form-data"},data:s})},wt=n=>me({mutationKey:["eventsUploadEventImage"],mutationFn:Nt,...n?.mutation}),Pt=({eventId:n})=>de({url:`/api/v1/events/${n}/image`,method:"DELETE"}),At=n=>me({mutationKey:["eventsDeleteEventImage"],mutationFn:Pt,...n?.mutation}),ce="tournament-form-sheet";function Dt({open:n,onOpenChange:u,onSuccess:s,tournament:d,event:i}){const{t:c}=I("tournaments",{keyPrefix:"admin"}),f=ue(),T=Pe(),r=Ae(),y=wt(),S=At(),h=!!(d&&i),[A,D]=x.useState(null),[m,o]=x.useState(!1),N=a=>{a||(D(null),o(!1)),u(a)},p=d&&i?{...ke(i),teamSize:d.teamSize,maxRosterSize:d.maxRosterSize??d.teamSize,maxTeams:d.maxTeams,minTeams:d.minTeams,requireTeamNames:d.requireTeamNames??!0,registrationClosesAt:De(d.registrationClosesAt)}:void 0,t=a=>({teamSize:a.teamSize,maxRosterSize:a.maxRosterSize,maxTeams:a.maxTeams,minTeams:a.minTeams,registrationClosesAt:Fe(a.registrationClosesAt),requireTeamNames:a.requireTeamNames}),l=a=>({...Be(a),type:"tournament",isPrivate:!1,allowFirstTimePerk:!1,firstTimePerkPr
1icing:null,allowPack:!1}),g=a=>({...Ue(a),isPrivate:!1,allowFirstTimePerk:!1,firstTimePerkPricing:null,allowPack:!1}),b=async a=>await T.mutateAsync({data:{event:l(a),tournament:t(a)}}),j=async a=>(await r.mutateAsync({tournamentId:d.id,data:{event:g(a),tournament:t(a)}}),d),w=async a=>{if(m)try{A?await y.mutateAsync({eventId:a,file:A}):i?.hasOwnImage&&await S.mutateAsync({eventId:a})}catch(v){P.error(X(v,c("create.imageError")))}},Q=async a=>{try{const v=h?await j(a):await b(a),R=v.id;await w(v.eventId),await Promise.all([f.invalidateQueries({queryKey:ge()}),f.invalidateQueries({queryKey:Z(R)}),f.invalidateQueries({queryKey:["api","v1","events"]})]),P.success(c(h?"edit.success":"create.success")),N(!1),s?.(R)}catch(v){P.error(X(v,c(h?"edit.error":"create.error")))}},O=T.isPending||r.isPending||y.isPending||S.isPending;return e.jsx(Ie,{open:n,onOpenChange:N,children:e.jsxs(Ee,{side:"right",className:"w-full sm:max-w-4xl overflow-y-auto",children:[e.jsxs(ze,{children:[e.jsx(qe,{children:c(h?"edit.title":"create.title")}),e.jsx(_e,{children:c(h?"edit.description":"create.description")})]}),e.jsxs("div",{className:"mt-6 flex flex-col gap-4",children:[e.jsx(yt,{formId:ce,onSubmit:Q,defaultImageUrl:i?.hasOwnImage?i.splashUrl??null:null,onImageChange:a=>{D(a),o(!0)},isEdit:h,structureLocked:fe(d?.status),defaultValues:p}),e.jsx(Me,{children:e.jsx(St,{formId:ce,isSubmitting:O,isEdit:h,onCancel:()=>N(!1)})})]})]})})}function kt({tournamentId:n,eventId:u,open:s,onOpenChange:d,onCancelled:i}){const{t:c}=I("tournaments",{keyPrefix:"admin"}),f=ue(),T=Le();async function r(){if(n)try{await T.mutateAsync({tournamentId:n}),await Promise.all([f.invalidateQueries({queryKey:ge()}),f.invalidateQueries({queryKey:Z(n)}),...u?[f.invalidateQueries({queryKey:Oe(u)})]:[]]),P.success(c("cancel.success")),d(!1),i?.()}catch(y){P.error(X(y,c("error")))}}return e.jsx(Y,{open:s,title:c("cancel.confirmTitle"),description:c("cancel.confirmMessage"),confirmLabel:c("cancel.confirmLabel"),destructive:!0,pending:T.isPending,onOpenChange:d,onConfirm:r})}const It={draft:"bg-muted text-muted-foreground border-border",registration_open:"bg-green-50 text-green-700 border-green-200 dark:bg-green-500/15 dark:text-green-300 dark:border-green-500/30",registration_closed:"bg-amber-50 text-amber-700 border-amber-200 dark:bg-amber-500/15 dark:text-amber-300 dark:border-amber-500/30",in_progress:"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-500/15 dark:text-blue-300 dark:border-blue-500/30",completed:"bg-violet-50 text-violet-700 border-violet-200 dark:bg-violet-500/15 dark:text-violet-300 dark:border-violet-500/30",cancelled:"bg-red-50 text-red-700 border-red-200 dark:bg-red-500/15 dark:text-red-300 dark:border-red-500/30"};function Et({status:n,className:u}){const{t:s}=I("tournaments",{keyPrefix:"admin"});return e.jsx(dt,{variant:"outline","data-testid":"tournament-status-chip",className:xe(It[n],u),children:s(`status.${n}`)})}const zt={[C.draft]:C.registration_open,[C.registration_open]:C.registration_closed,[C.registration_closed]:C.registration_open},H="inline-flex items-center border-b-2 border-transparent px-3 py-2 text-sm font-medium text-muted-foreground transition-colors hover:text-foreground data-[status=active]:border-primary data-[status=active]:text-foreground";function Lt({tournamentId:n,children:u}){const{t:s}=I("tournaments",{keyPrefix:"admin"}),{formatDistanceToNow:d,formatPrice:i}
1=Re(),[c,f]=x.useState(!1),[T,r]=x.useState(!1),[y,S]=x.useState(!1),[h,A]=x.useState(!1),[D,m]=x.useState(!1),{data:o,isLoading:N}=$e(n),{data:p}=Ke(o?.eventId??"",{query:{enabled:!!o?.eventId}}),t=Qe(),l=Ve(),g=We(),b=Tt(n,[Z(n)]),j=o?.status?zt[o.status]:void 0,w=j===C.registration_open,Q=Ge(o?.status),O=o?.status===C.registration_closed,{data:a}=He(n,{query:{enabled:O&&D}});async function v(){m(!1),await b(()=>g.mutateAsync({tournamentId:n}),ae=>ae.success?P.success(s("confirmTournament.captured",{count:ae.capturedCount})):P.error(s("confirmTournament.partialFailure")))}async function R(){S(!1),j&&await b(()=>j===C.registration_closed?l.mutateAsync({tournamentId:n}):t.mutateAsync({tournamentId:n,data:{status:j}}),()=>P.success(s("statusAction.updated")))}const V=o?.registrationClosesAt?new Date(o.registrationClosesAt):null,{deadlinePassed:U}=Xe(V),he=Ye({status:o?.status,deadlinePassed:U}),J=w&&U,ee=!!a&&a.confirmedTeams<a.minTeams,te=!!a&&(a.actionRequired>0||a.incompleteCheckouts>0);return e.jsxs(Ze,{children:[e.jsxs("div",{className:"w-full space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[N?e.jsx(Je,{className:"h-9 w-2/3"}):e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold",children:p?.title??s("header.title")}),e.jsxs("div",{className:"flex items-center flex-wrap gap-2",children:[o?.status&&e.jsx(Et,{status:o.status}),e.jsxs(F,{variant:"outline",size:"sm",disabled:!o?.eventId,onClick:()=>f(!0),children:[e.jsx(et,{className:"size-4"}),s("header.manageAnnouncements")]}),e.jsxs(F,{variant:"outline",size:"sm",disabled:!o||!p,onClick:()=>r(!0),children:[e.jsx(tt,{className:"size-4"}),s("header.edit")]}),j&&e.jsx(at,{size:"sm",variant:"default",icon:w?st:vt,tooltipContent:s(J?"statusAction.deadlinePassedTooltip":w?"statusAction.openRegistration":"statusAction.closeRegistration"),onClick:()=>J?r(!0):S(!0),disabled:t.isPending||l.isPending,children:s(w?"statusAction.openRegistration":"statusAction.closeRegistration")}),O&&e.jsxs(F,{size:"sm",onClick:()=>m(!0),disabled:g.isPending,children:[e.jsx(nt,{className:"size-4"}),s("confirmTournament.action")]}),Q&&e.jsxs(rt,{children:[e.jsx(ot,{asChild:!0,children:e.jsxs(F,{variant:"outline",size:"sm",className:"px-2",children:[e.jsx("span",{className:"sr-only",children:s("header.menu")}),e.jsx(bt,{className:"size-4"})]})}),e.jsx(it,{align:"end",children:e.jsxs(lt,{onClick:()=>A(!0),className:"text-destructive focus:text-destructive",children:[e.jsx(ct,{className:"size-4"}),s("cancel.action")]})})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[V&&(he||U&&!fe(o?.status))&&e.jsx("span",{className:xe(U?"text-destructive":"text-muted-foreground"),children:s(U?"header.deadlinePassed":"header.deadlineCountdown",{relative:d(V)})}),p?.slug&&e.jsx($,{to:"/events/$slug",params:{slug:p.slug},className:"text-muted-foreground underline underline-offset-4 hover:text-foreground",children:s("header.viewPublicPage")})]})]}),e.jsxs("nav",{className:"flex gap-1 border-b overflow-x-auto",children:[e.jsx($,{to:"/manage/tournaments/$tournamentId",params:{tournamentId:n},activeOptions:{exact:!0},className:H,children:s("tabs.overview")}),e.jsx($,{to:"/manage/tournaments/$tournamentId/pool",params:{tournamentId:n},className:H,children:s("tabs.pool")}),e.jsx($,{to:"/manage/tournaments/$tournamentId/waitlist",params:{tournamentId:n},className:H,children:s("tabs.waitlist")})]}),u]}),o?.eventId&&e.jsx(mt,{eventId:o.eventId,open:c,onClose:()=>f(!1)}),e.jsx(Y,{open:y,title:s(w?"statusAction.openConfirmTitle":"statusAction.closeConfirmTitle"),description:s(w?"statusAction.openConfirmMessage":"statusAction.closeConfirmMessage"),onOpenChange:S,onConfirm:R}),e.jsx(Y,{open:D,title:s("confirmTournament.title"),description:a?ee?s("confirmTournament.belowMinimum",{confirmed:a.confirmedTeams,min:a.minTeams}):[s("confirmTournament.message",{count:a.holdsToCapture,amount:i(a.amountToCapture/100),released:a.holdsToRelease}),a.scheduledToCharge>
10&&s("confirmTournament.scheduled",{count:a.scheduledToCharge,amount:i(a.scheduledAmount/100)}),a.scheduledToCancel>0&&s("confirmTournament.scheduledCancel",{count:a.scheduledToCancel}),a.alreadyCaptured>0&&s("confirmTournament.alreadyCaptured",{count:a.alreadyCaptured}),te&&s("confirmTournament.blocked",{action:a.actionRequired,incomplete:a.incompleteCheckouts}),a.teamsToWithdraw>0&&s("confirmTournament.willWithdraw",{count:a.teamsToWithdraw})].filter(Boolean).join(" "):s("confirmTournament.loading"),confirmLabel:s("confirmTournament.action"),confirmDisabled:ee||te,pending:g.isPending,onOpenChange:m,onConfirm:v}),e.jsx(kt,{tournamentId:n,eventId:o?.eventId,open:h,onOpenChange:A}),o&&p&&e.jsx(Dt,{open:T,onOpenChange:r,tournament:o,event:p})]})}export{kt as C,Et as T,Dt as a,Lt as b};

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.