- Create LanguageSelector component with dropdown (shows flag + name) - Add LanguageSelector to Header (right side, near user email/logout) - Add LanguageSelector to login, signup, and signup/[code] pages - Create test-utils.tsx with renderWithProviders helper - Add vitest.setup.ts to mock localStorage - Update all test files to use renderWithProviders - Language selector persists choice in localStorage - HTML lang attribute updates dynamically based on selected language All frontend and e2e tests passing.
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import { useRouter, useParams } from "next/navigation";
|
|
import { useAuth } from "../../auth-context";
|
|
import { LanguageSelector } from "../../components/LanguageSelector";
|
|
|
|
export default function SignupWithCodePage() {
|
|
const params = useParams();
|
|
const router = useRouter();
|
|
const { user, isLoading } = useAuth();
|
|
const code = params.code as string;
|
|
|
|
useEffect(() => {
|
|
// Wait for auth check to complete before redirecting
|
|
if (isLoading) return;
|
|
|
|
if (user) {
|
|
// Already logged in, redirect to home
|
|
router.replace("/");
|
|
} else {
|
|
// Redirect to signup with code as query param
|
|
// Invite codes only contain [a-z0-9-] so no encoding needed
|
|
router.replace(`/signup?code=${code}`);
|
|
}
|
|
}, [user, isLoading, code, router]);
|
|
|
|
return (
|
|
<main
|
|
style={{
|
|
minHeight: "100vh",
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
background: "linear-gradient(135deg, #0f0f23 0%, #1a1a3e 50%, #0f0f23 100%)",
|
|
color: "rgba(255,255,255,0.6)",
|
|
fontFamily: "'DM Sans', system-ui, sans-serif",
|
|
}}
|
|
>
|
|
<div style={{ position: "absolute", top: "1rem", right: "1rem" }}>
|
|
<LanguageSelector />
|
|
</div>
|
|
Redirecting...
|
|
</main>
|
|
);
|
|
}
|