feat(frontend): Finalize auth refactor, routing, and resolve all code review findings
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user