From 49b430394dc961451a6abca26a95ebba8d22f68c Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Thu, 15 Sep 2022 21:23:49 +0800 Subject: [PATCH] feat(console): auto detect language setting (#1941) --- .../components/LanguagesForm.tsx | 62 +++++++------------ .../components/index.module.scss | 6 ++ .../src/pages/SignInExperience/types.ts | 13 +--- .../src/pages/SignInExperience/utilities.ts | 23 +------ .../translation/admin-console/sign-in-exp.ts | 16 ++--- .../translation/admin-console/sign-in-exp.ts | 16 ++--- .../translation/admin-console/sign-in-exp.ts | 15 +++-- .../translation/admin-console/sign-in-exp.ts | 15 +++-- .../translation/admin-console/sign-in-exp.ts | 16 ++--- .../translation/admin-console/sign-in-exp.ts | 15 +++-- 10 files changed, 86 insertions(+), 111 deletions(-) diff --git a/packages/console/src/pages/SignInExperience/components/LanguagesForm.tsx b/packages/console/src/pages/SignInExperience/components/LanguagesForm.tsx index 3f87fc376..988f11af0 100644 --- a/packages/console/src/pages/SignInExperience/components/LanguagesForm.tsx +++ b/packages/console/src/pages/SignInExperience/components/LanguagesForm.tsx @@ -3,58 +3,40 @@ import { Controller, useFormContext } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import FormField from '@/components/FormField'; -import RadioGroup, { Radio } from '@/components/RadioGroup'; import Select from '@/components/Select'; +import Switch from '@/components/Switch'; -import { LanguageMode, SignInExperienceForm } from '../types'; +import { SignInExperienceForm } from '../types'; import * as styles from './index.module.scss'; const LanguagesForm = () => { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); - const { watch, control } = useFormContext(); - const mode = watch('languageInfo.mode'); + const { watch, control, register } = useFormContext(); + const isAutoDetect = watch('languageInfo.autoDetect'); return ( <>
{t('sign_in_exp.others.languages.title')}
- - ( - - - - - )} + + - {mode === LanguageMode.Auto && ( - - ( - - )} - /> - - )} + + ( +