fix: Address second code review findings (test isolation, frontend type safety)
This commit is contained in:
@@ -37,7 +37,7 @@ function App() {
|
||||
setUser(userData)
|
||||
setIsAuthenticated(true)
|
||||
if (userData.theme_preference) {
|
||||
setThemeLocal(userData.theme_preference as "light" | "dark")
|
||||
setThemeLocal(userData.theme_preference)
|
||||
}
|
||||
// Load history after successful auth
|
||||
loadHistory()
|
||||
@@ -67,7 +67,7 @@ function App() {
|
||||
setUser(userData)
|
||||
setIsAuthenticated(true)
|
||||
if (userData.theme_preference) {
|
||||
setThemeLocal(userData.theme_preference as "light" | "dark")
|
||||
setThemeLocal(userData.theme_preference)
|
||||
}
|
||||
loadHistory()
|
||||
} catch (err: unknown) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createContext, useContext, useEffect, useState } from "react"
|
||||
import { AuthService } from "@/services/auth"
|
||||
|
||||
type Theme = "light" | "dark"
|
||||
export type Theme = "light" | "dark"
|
||||
|
||||
interface ThemeContextType {
|
||||
theme: Theme
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import api from "./api"
|
||||
import type { Theme } from "@/components/theme-provider"
|
||||
|
||||
export interface AuthResponse {
|
||||
access_token: string
|
||||
@@ -9,7 +10,7 @@ export interface UserResponse {
|
||||
id: string
|
||||
email: string
|
||||
display_name?: string
|
||||
theme_preference: string
|
||||
theme_preference: Theme
|
||||
}
|
||||
|
||||
export const AuthService = {
|
||||
@@ -51,7 +52,7 @@ export const AuthService = {
|
||||
await api.post("/auth/logout")
|
||||
},
|
||||
|
||||
async updateTheme(theme: string): Promise<UserResponse> {
|
||||
async updateTheme(theme: Theme): Promise<UserResponse> {
|
||||
const response = await api.patch<UserResponse>("/auth/theme", { theme })
|
||||
return response.data
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user