Commit 1f755f74 authored by Johnny's avatar Johnny

fix(web): make login screen theme selector reactive

This fixes an issue where the theme selector on the login screen would not update its display value after selection because the component was not re-rendering. Added local state to track the current theme. Validated that this pattern is unique to the unauthenticated context.
parent fb4f3e70
import { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { loadLocale } from "@/utils/i18n"; import { loadLocale } from "@/utils/i18n";
import { getInitialTheme, loadTheme } from "@/utils/theme"; import { getInitialTheme, loadTheme, Theme } from "@/utils/theme";
import LocaleSelect from "./LocaleSelect"; import LocaleSelect from "./LocaleSelect";
import ThemeSelect from "./ThemeSelect"; import ThemeSelect from "./ThemeSelect";
...@@ -12,7 +13,7 @@ interface Props { ...@@ -12,7 +13,7 @@ interface Props {
const AuthFooter = ({ className }: Props) => { const AuthFooter = ({ className }: Props) => {
const { i18n: i18nInstance } = useTranslation(); const { i18n: i18nInstance } = useTranslation();
const currentLocale = i18nInstance.language as Locale; const currentLocale = i18nInstance.language as Locale;
const currentTheme = getInitialTheme(); const [currentTheme, setCurrentTheme] = useState(getInitialTheme());
const handleLocaleChange = (locale: Locale) => { const handleLocaleChange = (locale: Locale) => {
loadLocale(locale); loadLocale(locale);
...@@ -20,6 +21,7 @@ const AuthFooter = ({ className }: Props) => { ...@@ -20,6 +21,7 @@ const AuthFooter = ({ className }: Props) => {
const handleThemeChange = (theme: string) => { const handleThemeChange = (theme: string) => {
loadTheme(theme); loadTheme(theme);
setCurrentTheme(theme as Theme);
}; };
return ( return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment