From 87deeca110ef6d23b6ba02686128111eb3ee0f41 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 23 Jul 2024 22:39:05 +0800 Subject: [PATCH] chore: tweak user settings --- .../components/setting/PreferenceSection.tsx | 24 +- frontend/web/src/layouts/Root.tsx | 11 +- proto/api/v1/user_setting_service.proto | 17 +- proto/gen/api/v1/README.md | 36 +- proto/gen/api/v1/user_setting_service.pb.go | 309 +++++------------- proto/gen/apidocs.swagger.yaml | 21 +- proto/gen/store/README.md | 35 +- proto/gen/store/user_setting.pb.go | 235 +++---------- proto/store/user_setting.proto | 19 +- server/route/api/v1/user_setting_service.go | 68 +--- store/db/postgres/user_setting.go | 8 +- store/db/sqlite/user_setting.go | 8 +- test/store/user_setting_test.go | 16 +- 13 files changed, 192 insertions(+), 615 deletions(-) diff --git a/frontend/web/src/components/setting/PreferenceSection.tsx b/frontend/web/src/components/setting/PreferenceSection.tsx index a59a340..7b02b25 100644 --- a/frontend/web/src/components/setting/PreferenceSection.tsx +++ b/frontend/web/src/components/setting/PreferenceSection.tsx @@ -2,7 +2,7 @@ import { Option, Select } from "@mui/joy"; import { useTranslation } from "react-i18next"; import BetaBadge from "@/components/BetaBadge"; import { useUserStore } from "@/stores"; -import { UserSetting, UserSetting_ColorTheme, UserSetting_Locale } from "@/types/proto/api/v1/user_setting_service"; +import { UserSetting } from "@/types/proto/api/v1/user_setting_service"; const PreferenceSection: React.FC = () => { const { t } = useTranslation(); @@ -13,39 +13,39 @@ const PreferenceSection: React.FC = () => { const languageOptions = [ { - value: UserSetting_Locale.LOCALE_EN, + value: "EN", label: "English", }, { - value: UserSetting_Locale.LOCALE_ZH, + value: "ZH", label: "中文", }, { - value: UserSetting_Locale.LOCALE_FR, + value: "FR", label: "Français", }, { - value: UserSetting_Locale.LOCALE_JA, + value: "JA", label: "日本語", }, ]; const colorThemeOptions = [ { - value: UserSetting_ColorTheme.COLOR_THEME_SYSTEM, + value: "SYSTEM", label: "System", }, { - value: UserSetting_ColorTheme.COLOR_THEME_LIGHT, + value: "LIGHT", label: "Light", }, { - value: UserSetting_ColorTheme.COLOR_THEME_DARK, + value: "DARK", label: "Dark", }, ]; - const handleSelectLanguage = async (locale: UserSetting_Locale) => { + const handleSelectLanguage = async (locale: string) => { await userStore.updateUserSetting( { ...userSetting, @@ -55,7 +55,7 @@ const PreferenceSection: React.FC = () => { ); }; - const handleSelectColorTheme = async (colorTheme: UserSetting_ColorTheme) => { + const handleSelectColorTheme = async (colorTheme: string) => { await userStore.updateUserSetting( { ...userSetting, @@ -73,7 +73,7 @@ const PreferenceSection: React.FC = () => {
{t("settings.preference.color-theme")}
- handleSelectColorTheme(value as string)}> {colorThemeOptions.map((option) => { return (