import { useEffect, useState, ReactElement } from "react"; import { observer } from "mobx-react"; import { useTheme } from "next-themes"; // ui import { setPromiseToast } from "@plane/ui"; // components import { LogoSpinner } from "@/components/common"; import { CustomThemeSelector, ThemeSwitch, PageHead } from "@/components/core"; // constants import { I_THEME_OPTION, THEME_OPTIONS } from "@/constants/themes"; // hooks import { useUserProfile } from "@/hooks/store"; // layouts import { ProfilePreferenceSettingsLayout } from "@/layouts/settings-layout/profile/preferences"; // type import { NextPageWithLayout } from "@/lib/types"; const ProfilePreferencesThemePage: NextPageWithLayout = observer(() => { const { setTheme } = useTheme(); // states const [currentTheme, setCurrentTheme] = useState(null); // hooks const { data: userProfile, updateUserTheme } = useUserProfile(); useEffect(() => { if (userProfile?.theme?.theme) { const userThemeOption = THEME_OPTIONS.find((t) => t.value === userProfile?.theme?.theme); if (userThemeOption) { setCurrentTheme(userThemeOption); } } }, [userProfile?.theme?.theme]); const handleThemeChange = (themeOption: I_THEME_OPTION) => { setTheme(themeOption.value); const updateCurrentUserThemePromise = updateUserTheme({ theme: themeOption.value }); setPromiseToast(updateCurrentUserThemePromise, { loading: "Updating theme...", success: { title: "Success!", message: () => "Theme updated successfully!", }, error: { title: "Error!", message: () => "Failed to Update the theme", }, }); }; return ( <> {userProfile ? (

Preferences

Theme

Select or customize your interface color scheme.

{userProfile?.theme?.theme === "custom" && }
) : (
)} ); }); ProfilePreferencesThemePage.getLayout = function getLayout(page: ReactElement) { return {page}; }; export default ProfilePreferencesThemePage;