fix: Address code review findings (backend validation, hydration efficiency, plot readability)
This commit is contained in:
@@ -12,7 +12,7 @@ import { Button } from "./components/ui/button"
|
||||
import { useTheme } from "./components/theme-provider"
|
||||
|
||||
function App() {
|
||||
const { setTheme } = useTheme()
|
||||
const { setThemeLocal } = useTheme()
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
||||
const [user, setUser] = useState<UserResponse | null>(null)
|
||||
const [authMode, setAuthMode] = useState<"login" | "register">("login")
|
||||
@@ -37,7 +37,7 @@ function App() {
|
||||
setUser(userData)
|
||||
setIsAuthenticated(true)
|
||||
if (userData.theme_preference) {
|
||||
setTheme(userData.theme_preference as "light" | "dark")
|
||||
setThemeLocal(userData.theme_preference as "light" | "dark")
|
||||
}
|
||||
// Load history after successful auth
|
||||
loadHistory()
|
||||
@@ -67,7 +67,7 @@ function App() {
|
||||
setUser(userData)
|
||||
setIsAuthenticated(true)
|
||||
if (userData.theme_preference) {
|
||||
setTheme(userData.theme_preference as "light" | "dark")
|
||||
setThemeLocal(userData.theme_preference as "light" | "dark")
|
||||
}
|
||||
loadHistory()
|
||||
} catch (err: unknown) {
|
||||
|
||||
@@ -6,6 +6,7 @@ type Theme = "light" | "dark"
|
||||
interface ThemeContextType {
|
||||
theme: Theme
|
||||
setTheme: (theme: Theme) => void
|
||||
setThemeLocal: (theme: Theme) => void
|
||||
toggleTheme: () => void
|
||||
}
|
||||
|
||||
@@ -35,12 +36,16 @@ export function ThemeProvider({
|
||||
}
|
||||
}
|
||||
|
||||
const setThemeLocal = (newTheme: Theme) => {
|
||||
setThemeState(newTheme)
|
||||
}
|
||||
|
||||
const toggleTheme = () => {
|
||||
setTheme(theme === "light" ? "dark" : "light")
|
||||
}
|
||||
|
||||
return (
|
||||
<ThemeContext.Provider value={{ theme, setTheme, toggleTheme }}>
|
||||
<ThemeContext.Provider value={{ theme, setTheme, setThemeLocal, toggleTheme }}>
|
||||
{children}
|
||||
</ThemeContext.Provider>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user