Skip to content
Snippets Groups Projects
Commit d7c6cb63 authored by Eduardo Orthmann's avatar Eduardo Orthmann
Browse files

add form control type

parent 82c37994
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import { Button, Col, Container, Form, FormControl, FormGroup, FormLabel, FormSelect, Row } from 'react-bootstrap'; import { Button, Col, Container, Form, FormControl, FormGroup, FormLabel, FormSelect, Row } from 'react-bootstrap';
import css from './settings.module.scss'; import css from './settings.module.scss';
import Divider from '@/components/divider/Divider'; import Divider from '@/components/divider/Divider';
import { useTranslations } from 'next-intl'; import { useLocale, useTranslations } from 'next-intl';
import { useContext, useEffect, useState } from 'react'; import { useContext, useEffect, useState } from 'react';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { AppContext } from '@/store/AppContextProvider'; import { AppContext } from '@/store/AppContextProvider';
...@@ -14,6 +14,7 @@ import { useAuth } from 'oidc-react'; ...@@ -14,6 +14,7 @@ import { useAuth } from 'oidc-react';
const Settings = (): JSX.Element => { const Settings = (): JSX.Element => {
const t = useTranslations('Settings'); const t = useTranslations('Settings');
const router = useRouter(); const router = useRouter();
const currentLocale = useLocale();
const { userData } = useAuth(); const { userData } = useAuth();
const { data, error } = useApiData<DefaultConfig>( const { data, error } = useApiData<DefaultConfig>(
'defaultConfig', 'defaultConfig',
...@@ -61,7 +62,12 @@ const Settings = (): JSX.Element => { ...@@ -61,7 +62,12 @@ const Settings = (): JSX.Element => {
body: JSON.stringify(formData), 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) { } catch (error) {
setError(error as Error); setError(error as Error);
} }
...@@ -97,7 +103,7 @@ const Settings = (): JSX.Element => { ...@@ -97,7 +103,7 @@ const Settings = (): JSX.Element => {
</FormLabel> </FormLabel>
<FormSelect <FormSelect
name="language" name="language"
value={formData.language} value={formData.language.toLowerCase()}
onChange={handleInputChange} onChange={handleInputChange}
> >
<option value="en">English</option> <option value="en">English</option>
...@@ -113,7 +119,7 @@ const Settings = (): JSX.Element => { ...@@ -113,7 +119,7 @@ const Settings = (): JSX.Element => {
type="number" type="number"
name="historyLimit" name="historyLimit"
value={formData.historyLimit} value={formData.historyLimit}
onChange={handleInputChange} onChange={(e: React.ChangeEvent<any>) => handleInputChange(e)}
/> />
</FormGroup> </FormGroup>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment