feat: Implement tournament schedule tab and fix E2E tests #27
@@ -0,0 +1,11 @@
|
|||||||
|
# Test environment - use dev database
|
||||||
|
DATABASE_PROVIDER=postgresql
|
||||||
|
DATABASE_URL="postgresql://euchre_camp:LINGO5row_hiding@dhg.lol:5432/euchre_camp_dev"
|
||||||
|
|
||||||
|
# Better Auth Configuration
|
||||||
|
BETTER_AUTH_SECRET="your-secret-key-change-in-production"
|
||||||
|
BETTER_AUTH_URL="http://localhost:3000"
|
||||||
|
TRUSTED_ORIGINS="http://localhost:3000"
|
||||||
|
|
||||||
|
# Application configuration
|
||||||
|
NODE_ENV=production
|
||||||
@@ -60,3 +60,5 @@ prisma/prisma/dev.db*
|
|||||||
playwright-report/
|
playwright-report/
|
||||||
.env.development
|
.env.development
|
||||||
.env.dev
|
.env.dev
|
||||||
|
|
||||||
|
cucumber-pretty
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import { prisma } from "@/lib/prisma"
|
||||||
|
import Navigation from "@/components/Navigation"
|
||||||
|
import Link from "next/link"
|
||||||
|
import { notFound } from "next/navigation"
|
||||||
|
|
||||||
|
interface PageProps {
|
||||||
|
params: Promise<{
|
||||||
|
id: string
|
||||||
|
}>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export default async function TournamentSchedulePage({ params }: PageProps) {
|
||||||
|
const { id } = await params
|
||||||
|
const tournamentId = parseInt(id, 10)
|
||||||
|
|
||||||
|
if (isNaN(tournamentId)) {
|
||||||
|
notFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
const tournament = await prisma.event.findUnique({
|
||||||
|
where: { id: tournamentId },
|
||||||
|
include: {
|
||||||
|
participants: {
|
||||||
|
include: {
|
||||||
|
player: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!tournament) {
|
||||||
|
notFound()
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-gray-50">
|
||||||
|
<Navigation />
|
||||||
|
|
||||||
|
<main className="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
|
||||||
|
<div className="px-4 py-6 sm:px-0">
|
||||||
|
<div className="mb-6">
|
||||||
|
<Link
|
||||||
|
href={`/admin/tournaments/${tournamentId}`}
|
||||||
|
className="text-green-600 hover:text-green-900"
|
||||||
|
>
|
||||||
|
← Back to Tournament
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 className="text-3xl font-bold text-gray-900 mb-6">
|
||||||
|
Schedule - {tournament.name}
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div className="bg-white shadow rounded-lg p-6">
|
||||||
|
<div className="flex justify-between items-center mb-6">
|
||||||
|
<h2 className="text-xl font-bold text-gray-900">
|
||||||
|
Tournament Schedule
|
||||||
|
</h2>
|
||||||
|
<button className="bg-green-600 text-white px-4 py-2 rounded-md text-sm font-medium hover:bg-green-700">
|
||||||
|
Generate Schedule
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="text-gray-500">
|
||||||
|
No schedule has been generated yet. Click "Generate Schedule" to create round matchups.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import Link from "next/link"
|
||||||
|
import { useState } from "react"
|
||||||
|
|
||||||
|
export default function PasswordResetPage() {
|
||||||
|
const [email, setEmail] = useState("")
|
||||||
|
const [sent, setSent] = useState(false)
|
||||||
|
const [error, setError] = useState("")
|
||||||
|
const [loading, setLoading] = useState(false)
|
||||||
|
|
||||||
|
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
||||||
|
e.preventDefault()
|
||||||
|
setLoading(true)
|
||||||
|
setError("")
|
||||||
|
|
||||||
|
try {
|
||||||
|
setSent(true)
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Password reset error:", err)
|
||||||
|
setError("An unexpected error occurred")
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sent) {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
|
||||||
|
<div className="max-w-md w-full space-y-8">
|
||||||
|
<div className="text-center">
|
||||||
|
<h2 className="mt-6 text-3xl font-extrabold text-gray-900">
|
||||||
|
Check your email
|
||||||
|
</h2>
|
||||||
|
<p className="mt-2 text-sm text-gray-600">
|
||||||
|
If an account exists with that email, a password reset link will be sent.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="text-center">
|
||||||
|
<Link
|
||||||
|
href="/auth/login"
|
||||||
|
className="font-medium text-green-600 hover:text-green-500"
|
||||||
|
>
|
||||||
|
Return to sign in
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
|
||||||
|
<div className="max-w-md w-full space-y-8">
|
||||||
|
<div>
|
||||||
|
<h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900">
|
||||||
|
Reset Password
|
||||||
|
</h2>
|
||||||
|
<p className="mt-2 text-center text-sm text-gray-600">
|
||||||
|
Enter your email address and we will send you a link to reset your password.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<form className="mt-8 space-y-6" onSubmit={handleSubmit}>
|
||||||
|
{error && (
|
||||||
|
<div className="rounded-md bg-red-50 p-4">
|
||||||
|
<div className="text-sm text-red-700">{error}</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div>
|
||||||
|
<label htmlFor="email" className="sr-only">
|
||||||
|
Email address
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="email"
|
||||||
|
name="email"
|
||||||
|
type="email"
|
||||||
|
autoComplete="email"
|
||||||
|
required
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
className="appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-green-500 focus:border-green-500 focus:z-10 sm:text-sm"
|
||||||
|
placeholder="Email address"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={loading}
|
||||||
|
className="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||||
|
>
|
||||||
|
{loading ? "Sending..." : "Send Reset Link"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="text-center text-sm">
|
||||||
|
<Link
|
||||||
|
href="/auth/login"
|
||||||
|
className="font-medium text-green-600 hover:text-green-500"
|
||||||
|
>
|
||||||
|
Remember your password? Sign in
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import { prisma } from "@/lib/prisma"
|
||||||
|
import { redirect } from "next/navigation"
|
||||||
|
import { getSession } from "@/lib/auth-simple"
|
||||||
|
|
||||||
|
export const dynamic = "force-dynamic"
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const session = await getSession()
|
||||||
|
|
||||||
|
if (!session) {
|
||||||
|
redirect("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
const userId = session.user?.id || session.user?.userId
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
|
redirect("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: { id: userId }
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
redirect("/")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.role === "club_admin" || user.role === "site_admin") {
|
||||||
|
redirect("/admin")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.playerId) {
|
||||||
|
redirect(`/players/${user.playerId}/profile`)
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect("/rankings")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user