User feedback: still ugly, the 1xbet navigation was never actually reproduced. Now follows its structure: - thin utility bar on top (country picker, Connexion + Inscription) above the main bar (logo, nav) - horizontal icon strip of the country's lotteries under the header, with the active one underlined in gold - compact promo banner instead of a full-height hero, so results stay above the fold - right rail in the bet-slip position: top-5 leaderboard and army stats Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
82 lines
3.0 KiB
TypeScript
82 lines
3.0 KiB
TypeScript
"use client"
|
|
|
|
import { useActionState, useState } from "react"
|
|
import { loginWithPassword, signupWithPassword, type MemberAuthState } from "@/app/connexion/actions"
|
|
import { Button } from "@/components/ui/button"
|
|
import { Input } from "@/components/ui/input"
|
|
import { Label } from "@/components/ui/label"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
const INITIAL: MemberAuthState = { ok: false, message: "" }
|
|
|
|
export function MemberAuthForm({ next, initialMode = "login" }: { next: string; initialMode?: "login" | "signup" }) {
|
|
const [mode, setMode] = useState<"login" | "signup">(initialMode)
|
|
const [loginState, loginAction, loginPending] = useActionState(loginWithPassword, INITIAL)
|
|
const [signupState, signupActionFn, signupPending] = useActionState(signupWithPassword, INITIAL)
|
|
|
|
const action = mode === "login" ? loginAction : signupActionFn
|
|
const state = mode === "login" ? loginState : signupState
|
|
const pending = mode === "login" ? loginPending : signupPending
|
|
|
|
return (
|
|
<div>
|
|
<div className="mb-4 flex rounded-md border border-border/60 bg-panel p-1 text-sm">
|
|
<button
|
|
type="button"
|
|
onClick={() => setMode("login")}
|
|
className={cn(
|
|
"flex-1 rounded py-1.5 font-medium transition-colors",
|
|
mode === "login" ? "bg-panel-hover text-foreground" : "text-muted-foreground"
|
|
)}
|
|
>
|
|
Connexion
|
|
</button>
|
|
<button
|
|
type="button"
|
|
onClick={() => setMode("signup")}
|
|
className={cn(
|
|
"flex-1 rounded py-1.5 font-medium transition-colors",
|
|
mode === "signup" ? "bg-panel-hover text-foreground" : "text-muted-foreground"
|
|
)}
|
|
>
|
|
Créer un compte
|
|
</button>
|
|
</div>
|
|
|
|
<form action={action} className="space-y-3">
|
|
<input type="hidden" name="next" value={next} />
|
|
{mode === "signup" && (
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="name">Nom</Label>
|
|
<Input id="name" name="name" type="text" required autoComplete="name" />
|
|
</div>
|
|
)}
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="email">Courriel</Label>
|
|
<Input id="email" name="email" type="email" required autoComplete="email" />
|
|
</div>
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="password">Mot de passe</Label>
|
|
<Input
|
|
id="password"
|
|
name="password"
|
|
type="password"
|
|
required
|
|
minLength={mode === "signup" ? 8 : undefined}
|
|
autoComplete={mode === "login" ? "current-password" : "new-password"}
|
|
/>
|
|
{mode === "signup" && (
|
|
<p className="text-[11px] text-muted-foreground">8 caractères minimum.</p>
|
|
)}
|
|
</div>
|
|
|
|
{!state.ok && state.message && <p className="text-xs text-destructive">{state.message}</p>}
|
|
|
|
<Button type="submit" disabled={pending} className="w-full">
|
|
{pending ? "…" : mode === "login" ? "Se connecter" : "Créer mon compte"}
|
|
</Button>
|
|
</form>
|
|
</div>
|
|
)
|
|
}
|