diff --git a/web/src/app/(app)/championships/[id]/page.tsx b/web/src/app/(app)/championships/[id]/page.tsx index d746995..e6c6ad5 100644 --- a/web/src/app/(app)/championships/[id]/page.tsx +++ b/web/src/app/(app)/championships/[id]/page.tsx @@ -1,9 +1,9 @@ "use client"; import { use } from "react"; -import { useChampionship } from "@/hooks/useChampionship"; -import { useMyRegistrations } from "@/hooks/useMyRegistrations"; -import { useRegisterForChampionship } from "@/hooks/useRegisterForChampionship"; +import { useChampionship } from "@/hooks/useChampionships"; +import { useMyRegistrations } from "@/hooks/useRegistrations"; +import { useRegisterForChampionship } from "@/hooks/useRegistrations"; import { useAuth } from "@/hooks/useAuth"; import { RegistrationTimeline } from "@/components/RegistrationTimeline"; import { StatusBadge } from "@/components/StatusBadge"; diff --git a/web/src/app/(app)/registrations/page.tsx b/web/src/app/(app)/registrations/page.tsx index f8b057c..c68ecaf 100644 --- a/web/src/app/(app)/registrations/page.tsx +++ b/web/src/app/(app)/registrations/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useMyRegistrations } from "@/hooks/useMyRegistrations"; +import { useMyRegistrations } from "@/hooks/useRegistrations"; import { RegistrationCard } from "@/components/RegistrationCard"; export default function RegistrationsPage() { diff --git a/web/src/app/(auth)/login/page.tsx b/web/src/app/(auth)/login/page.tsx index 1eb89da..62fe7d7 100644 --- a/web/src/app/(auth)/login/page.tsx +++ b/web/src/app/(auth)/login/page.tsx @@ -1,7 +1,7 @@ "use client"; import Link from "next/link"; -import { useLoginForm } from "@/hooks/useLoginForm"; +import { useLoginForm } from "@/hooks/useAuthForms"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; diff --git a/web/src/app/(auth)/register/page.tsx b/web/src/app/(auth)/register/page.tsx index 887ddc9..328185a 100644 --- a/web/src/app/(auth)/register/page.tsx +++ b/web/src/app/(auth)/register/page.tsx @@ -1,7 +1,7 @@ "use client"; import Link from "next/link"; -import { useRegisterForm } from "@/hooks/useRegisterForm"; +import { useRegisterForm } from "@/hooks/useAuthForms"; import { MemberFields } from "@/components/auth/MemberFields"; import { OrganizerFields } from "@/components/auth/OrganizerFields"; import { Button } from "@/components/ui/button"; diff --git a/web/src/hooks/useRegisterForm.ts b/web/src/hooks/useAuthForms.ts similarity index 68% rename from web/src/hooks/useRegisterForm.ts rename to web/src/hooks/useAuthForms.ts index 36b1baa..afc546b 100644 --- a/web/src/hooks/useRegisterForm.ts +++ b/web/src/hooks/useAuthForms.ts @@ -4,6 +4,29 @@ import { useState } from "react"; import { useRouter } from "next/navigation"; import { useAuth } from "@/hooks/useAuth"; +export function useLoginForm() { + const router = useRouter(); + const login = useAuth((s) => s.login); + const isLoading = useAuth((s) => s.isLoading); + + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + + async function submit(e: React.SyntheticEvent) { + e.preventDefault(); + setError(""); + try { + await login(email, password); + router.push("/championships"); + } catch { + setError("Invalid email or password"); + } + } + + return { email, setEmail, password, setPassword, error, isLoading, submit }; +} + export function useRegisterForm() { const router = useRouter(); const register = useAuth((s) => s.register); diff --git a/web/src/hooks/useChampionship.ts b/web/src/hooks/useChampionship.ts deleted file mode 100644 index 76439d1..0000000 --- a/web/src/hooks/useChampionship.ts +++ /dev/null @@ -1,12 +0,0 @@ -"use client"; - -import { useQuery } from "@tanstack/react-query"; -import { championshipsApi } from "@/lib/api/championships"; - -export function useChampionship(id: string) { - return useQuery({ - queryKey: ["championship", id], - queryFn: () => championshipsApi.get(id), - enabled: !!id, - }); -} diff --git a/web/src/hooks/useChampionships.ts b/web/src/hooks/useChampionships.ts index 852bc13..f9f063e 100644 --- a/web/src/hooks/useChampionships.ts +++ b/web/src/hooks/useChampionships.ts @@ -9,3 +9,11 @@ export function useChampionships() { queryFn: () => championshipsApi.list(), }); } + +export function useChampionship(id: string) { + return useQuery({ + queryKey: ["championship", id], + queryFn: () => championshipsApi.get(id), + enabled: !!id, + }); +} diff --git a/web/src/hooks/useLoginForm.ts b/web/src/hooks/useLoginForm.ts deleted file mode 100644 index 5a35f7b..0000000 --- a/web/src/hooks/useLoginForm.ts +++ /dev/null @@ -1,28 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { useRouter } from "next/navigation"; -import { useAuth } from "@/hooks/useAuth"; - -export function useLoginForm() { - const router = useRouter(); - const login = useAuth((s) => s.login); - const isLoading = useAuth((s) => s.isLoading); - - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); - const [error, setError] = useState(""); - - async function submit(e: React.SyntheticEvent) { - e.preventDefault(); - setError(""); - try { - await login(email, password); - router.push("/championships"); - } catch { - setError("Invalid email or password"); - } - } - - return { email, setEmail, password, setPassword, error, isLoading, submit }; -} diff --git a/web/src/hooks/useMyRegistrations.ts b/web/src/hooks/useMyRegistrations.ts deleted file mode 100644 index c62367c..0000000 --- a/web/src/hooks/useMyRegistrations.ts +++ /dev/null @@ -1,11 +0,0 @@ -"use client"; - -import { useQuery } from "@tanstack/react-query"; -import { registrationsApi } from "@/lib/api/registrations"; - -export function useMyRegistrations() { - return useQuery({ - queryKey: ["registrations", "my"], - queryFn: () => registrationsApi.my(), - }); -} diff --git a/web/src/hooks/useRegisterForChampionship.ts b/web/src/hooks/useRegistrations.ts similarity index 64% rename from web/src/hooks/useRegisterForChampionship.ts rename to web/src/hooks/useRegistrations.ts index 4d4f892..f8ecb63 100644 --- a/web/src/hooks/useRegisterForChampionship.ts +++ b/web/src/hooks/useRegistrations.ts @@ -1,8 +1,15 @@ "use client"; -import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import { registrationsApi } from "@/lib/api/registrations"; +export function useMyRegistrations() { + return useQuery({ + queryKey: ["registrations", "my"], + queryFn: () => registrationsApi.my(), + }); +} + export function useRegisterForChampionship(championshipId: string) { const queryClient = useQueryClient();