mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
fix: address code review comments
- Use DEFAULT_THEME constant for theme reset - Type user selector properly - Include LOCALE_CONFIG in preferences cleanup - Add newline to migration file
This commit is contained in:
parent
60ac63604f
commit
8e91edd9d8
4 changed files with 6 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { Row, Button, Icon, useTheme } from '@umami/react-zen';
|
import { Row, Button, Icon, useTheme } from '@umami/react-zen';
|
||||||
import { useMessages, usePreferences } from '@/components/hooks';
|
import { useMessages, usePreferences } from '@/components/hooks';
|
||||||
import { Sun, Moon } from '@/components/icons';
|
import { Sun, Moon } from '@/components/icons';
|
||||||
|
import { DEFAULT_THEME } from '@/lib/constants';
|
||||||
|
|
||||||
export function ThemeSetting() {
|
export function ThemeSetting() {
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
|
|
@ -13,7 +14,7 @@ export function ThemeSetting() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
setTheme('light');
|
setTheme(DEFAULT_THEME);
|
||||||
updatePreferences({ theme: null });
|
updatePreferences({ theme: null });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
import { User } from '@/generated/prisma/client';
|
||||||
import { useApi } from './useApi';
|
import { useApi } from './useApi';
|
||||||
import { useApp } from '@/store/app';
|
import { useApp } from '@/store/app';
|
||||||
|
|
||||||
const userSelector = (state: { user: any }) => state.user;
|
const userSelector = (state: { user: User }) => state.user;
|
||||||
|
|
||||||
export function usePreferences() {
|
export function usePreferences() {
|
||||||
const { post } = useApi();
|
const { post } = useApi();
|
||||||
|
|
|
||||||
|
|
@ -67,5 +67,6 @@ export function setClientPreferences(preferences: {
|
||||||
export function removeClientPreferences() {
|
export function removeClientPreferences() {
|
||||||
removeItem(DATE_RANGE_CONFIG);
|
removeItem(DATE_RANGE_CONFIG);
|
||||||
removeItem(TIMEZONE_CONFIG);
|
removeItem(TIMEZONE_CONFIG);
|
||||||
|
removeItem(LOCALE_CONFIG);
|
||||||
removeItem(THEME_CONFIG);
|
removeItem(THEME_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue