website refactor

This commit is contained in:
2026-01-16 01:00:03 +01:00
parent ce7be39155
commit a98e3e3166
286 changed files with 5522 additions and 5261 deletions

View File

@@ -2,47 +2,42 @@
import React from 'react';
import { useRouter, useSearchParams } from 'next/navigation';
import CreateLeagueWizard from '@/components/leagues/CreateLeagueWizard';
import { CreateLeagueWizard } from './CreateLeagueWizard';
import { Section } from '@/ui/Section';
import { Container } from '@/ui/Container';
import { SearchParamParser } from '@/lib/routing/search-params/SearchParamParser';
import { SearchParamBuilder } from '@/lib/routing/search-params/SearchParamBuilder';
type StepName = 'basics' | 'visibility' | 'structure' | 'schedule' | 'scoring' | 'stewarding' | 'review';
function normalizeStepName(raw: string | null): StepName {
switch (raw) {
case 'basics':
case 'visibility':
case 'structure':
case 'schedule':
case 'scoring':
case 'stewarding':
case 'review':
return raw;
default:
return 'basics';
}
}
export default function CreateLeaguePage() {
const router = useRouter();
const searchParams = useSearchParams();
const currentStepName = normalizeStepName(
searchParams && typeof searchParams.get === 'function'
? searchParams.get('step')
: null,
);
const wizardParams = SearchParamParser.parseWizard(searchParams as any).unwrap();
const rawStep = wizardParams.step;
let currentStepName: StepName = 'basics';
if (rawStep === 'basics' ||
rawStep === 'visibility' ||
rawStep === 'structure' ||
rawStep === 'schedule' ||
rawStep === 'scoring' ||
rawStep === 'stewarding' ||
rawStep === 'review') {
currentStepName = rawStep;
}
const handleStepChange = (stepName: StepName) => {
const params = new URLSearchParams(
searchParams && typeof searchParams.toString === 'function'
? searchParams.toString()
: '',
);
params.set('step', stepName);
const query = params.toString();
const href = query ? `/leagues/create?${query}` : '/leagues/create';
router.push(href);
const builder = new SearchParamBuilder();
// Copy existing params if needed, but here we just want to set the step
if (searchParams) {
searchParams.forEach((value, key) => {
if (key !== 'step') builder.set(key, value);
});
}
builder.step(stepName);
router.push(`/leagues/create${builder.build()}`);
};
return (