From d7c6cb63d07456d38d7be00bd8cfe1e5dd39b8e8 Mon Sep 17 00:00:00 2001 From: Eduardo <orthmann2811@gmail.com> Date: Mon, 26 Feb 2024 11:01:38 -0300 Subject: [PATCH] add form control type --- src/app/[locale]/wallet/settings/page.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/[locale]/wallet/settings/page.tsx b/src/app/[locale]/wallet/settings/page.tsx index 2d75a2c..9ba09a8 100644 --- a/src/app/[locale]/wallet/settings/page.tsx +++ b/src/app/[locale]/wallet/settings/page.tsx @@ -3,7 +3,7 @@ import { Button, Col, Container, Form, FormControl, FormGroup, FormLabel, FormSelect, Row } from 'react-bootstrap'; import css from './settings.module.scss'; import Divider from '@/components/divider/Divider'; -import { useTranslations } from 'next-intl'; +import { useLocale, useTranslations } from 'next-intl'; import { useContext, useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import { AppContext } from '@/store/AppContextProvider'; @@ -14,6 +14,7 @@ import { useAuth } from 'oidc-react'; const Settings = (): JSX.Element => { const t = useTranslations('Settings'); const router = useRouter(); + const currentLocale = useLocale(); const { userData } = useAuth(); const { data, error } = useApiData<DefaultConfig>( 'defaultConfig', @@ -61,7 +62,12 @@ const Settings = (): JSX.Element => { body: JSON.stringify(formData), }); - router.push(`/${formData.language}/wallet/settings`); + if (formData.language.toLocaleLowerCase() !== currentLocale) { + router.push(`/${formData.language.toLowerCase()}/wallet/settings`); + return; + } + + router.refresh(); } catch (error) { setError(error as Error); } @@ -97,7 +103,7 @@ const Settings = (): JSX.Element => { </FormLabel> <FormSelect name="language" - value={formData.language} + value={formData.language.toLowerCase()} onChange={handleInputChange} > <option value="en">English</option> @@ -113,7 +119,7 @@ const Settings = (): JSX.Element => { type="number" name="historyLimit" value={formData.historyLimit} - onChange={handleInputChange} + onChange={(e: React.ChangeEvent<any>) => handleInputChange(e)} /> </FormGroup> -- GitLab