Skip to content

Commit b5e9288

Browse files
committed
feat: add language select
1 parent a56997b commit b5e9288

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

frontend/app/i18n/en/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"common": {
33
"ok": "OK",
44
"cancel": "Cancel",
5-
"message": "Message"
5+
"message": "Message",
6+
"language": "Language",
7+
"english": "English",
8+
"german": "German"
69
},
710
"login": {
811
"username": "Username",

frontend/app/login/login.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@
1616

1717
.toright {
1818
float: right;
19+
}
20+
21+
.content {
22+
width: 450px;
1923
}

frontend/app/login/login.tsx

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
limitations under the License.
1212
*/
1313
import { useNavigate } from "react-router";
14-
import { Dialog, DialogContent, Button, Tabs, Tab, Box, TextField } from '@mui/material';
14+
import { Dialog, DialogContent, Button, Tabs, Tab, Box, TextField, type SelectChangeEvent, FormControl, InputLabel, Select, MenuItem } from '@mui/material';
1515
import * as React from 'react';
1616
import {useState} from 'react';
1717
import GlobalState, { type UserDataState } from "~/GlobalState";
@@ -152,8 +152,13 @@ export function Login() {
152152
};
153153
}
154154

155+
const [language, setLanguage] = React.useState('en');
156+
const handleLanguageChange = (event: SelectChangeEvent) => {
157+
setLanguage(event.target.value);
158+
};
159+
155160
return (<Dialog open={globalLoginModal} onClose={handleClose} className="backDrop">
156-
<DialogContent>
161+
<DialogContent className={styles.content}>
157162
<Tabs value={activeTab} onChange={handleTabChange} aria-label="basic tabs example">
158163
<Tab label={t('login.login')} {...a11yProps(0)} />
159164
<Tab label={t('login.signin')} {...a11yProps(1)} />
@@ -187,10 +192,25 @@ export function Login() {
187192
fullWidth
188193
variant="standard"
189194
/>
190-
<div>
195+
<div className="flex justify-between items-center mt-4">
196+
<div>
191197
<Button type="submit">{t('common.ok')}</Button>
192198
<Button onClick={handleCancel}>{t('common.cancel')}</Button>
193-
</div>
199+
</div>
200+
<FormControl sx={{ minWidth: 120 }} size="small">
201+
<InputLabel id="demo-select-small-label">{t('common.language')}</InputLabel>
202+
<Select
203+
labelId="demo-select-small-label"
204+
id="demo-select-small"
205+
value={language}
206+
label={t('common.language')}
207+
onChange={handleLanguageChange}
208+
>
209+
<MenuItem value={'en'}>{t('common.english')}</MenuItem>
210+
<MenuItem value={'de'}>{t('common.german')}</MenuItem>
211+
</Select>
212+
</FormControl>
213+
</div>
194214
<div className={styles.responseMsg}>
195215
{[responseMsg].filter(value => !!value).map((value, index) =>
196216
<span key={index}>{t('common.message')}: {value}</span>
@@ -238,9 +258,25 @@ export function Login() {
238258
fullWidth
239259
variant="standard"
240260
/>
241-
<div>
261+
<div className="flex justify-between items-center mt-4">
262+
<div>
242263
<Button type="submit">{t('common.ok')}</Button>
243264
<Button onClick={handleCancel}>{t('common.cancel')}</Button>
265+
</div>
266+
<FormControl sx={{ minWidth: 120 }} size="small">
267+
<InputLabel id="demo-select-small-label">{t('common.language')}</InputLabel>
268+
<Select
269+
labelId="demo-select-small-label"
270+
id="demo-select-small"
271+
value={language}
272+
label={t('common.language')}
273+
onChange={handleLanguageChange}
274+
>
275+
<MenuItem value={'en'}>{t('common.english')}</MenuItem>
276+
<MenuItem value={'de'}>{t('common.german')}</MenuItem>
277+
</Select>
278+
</FormControl>
279+
244280
</div>
245281
<div className={styles.responseMsg}>
246282
{[responseMsg].filter(value => !!value).map((value, index) =>

0 commit comments

Comments
 (0)