feat(frontend): Finalize auth refactor, routing, and resolve all code review findings

This commit is contained in:
Yunxiao Xu
2026-02-12 00:11:08 -08:00
parent 7fe020f26c
commit 2545f6df13
17 changed files with 335 additions and 216 deletions

View File

@@ -14,6 +14,7 @@ import {
import { Input } from "@/components/ui/input"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { useState } from "react"
import axios from "axios"
interface RegisterFormProps {
onSuccess: () => void
@@ -38,12 +39,14 @@ export function RegisterForm({ onSuccess, onToggleMode }: RegisterFormProps) {
setError(null)
try {
await AuthService.register(values.email, values.password)
// Automatically login after registration or just switch to login?
// For now, let's just switch to login or notify success
alert("Registration successful! Please login.")
onToggleMode()
} catch (err: any) {
setError(err.response?.data?.detail || "Registration failed. Please try again.")
// Since backend sets cookie on registration now, we can just call onSuccess
onSuccess()
} catch (err: unknown) {
if (axios.isAxiosError(err)) {
setError(err.response?.data?.detail || "Registration failed. Please try again.")
} else {
setError("An unexpected error occurred.")
}
} finally {
setIsLoading(false)
}