forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLanguageSelect.js
More file actions
34 lines (31 loc) · 889 Bytes
/
LanguageSelect.js
File metadata and controls
34 lines (31 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react'
import { useField } from 'formik'
import { string } from 'prop-types'
import {
FormControl,
FormErrorMessage,
FormLabel,
Select,
} from '@chakra-ui/react'
import { t, Trans } from '@lingui/macro'
export function LanguageSelect({ name, ...props }) {
const [field, meta] = useField(name)
return (
<FormControl isInvalid={meta.error && meta.touched} {...props}>
<FormLabel htmlFor="lang" fontWeight="bold">
<Trans>Language:</Trans>
</FormLabel>
<Select {...field} id="lang">
<option hidden value="">
{t`Select Preferred Language`}
</option>
<option value="ENGLISH">English</option>
<option value="FRENCH">Français</option>
</Select>
<FormErrorMessage>{meta.error}</FormErrorMessage>
</FormControl>
)
}
LanguageSelect.propTypes = {
name: string.isRequired,
}