-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegionSelectSection.tsx
More file actions
54 lines (44 loc) · 1.43 KB
/
RegionSelectSection.tsx
File metadata and controls
54 lines (44 loc) · 1.43 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React, { FC } from 'react';
import { useAppDispatch, useAppSelector } from '../../state/hooks';
import {
regionsOfWorldSelector,
setSelectedRegionOfWorld,
setStep,
selectedRegionOfWorldSelector,
} from '../../state/region/regionSlice';
import { Steps } from '../../state/region/types';
import FormSection from '../common/FormSection/FormSection';
import Select from '../common/Select/Select';
const RegionSelectSection: FC = () => {
const dispatch = useAppDispatch();
const regionsOfWorld = useAppSelector(regionsOfWorldSelector);
const selectedRegionOfWorld = useAppSelector(selectedRegionOfWorldSelector);
const onFormSubmit = (event: React.SyntheticEvent) => {
event.preventDefault();
dispatch(setStep(Steps.Step2));
};
const onRegionSelect = (event: React.SyntheticEvent) => {
const target = event.target as typeof event.target & {
value: number;
};
dispatch(setSelectedRegionOfWorld(target.value));
};
return (
<FormSection
legend={<h1 className='u-font-heading h200'>Select a region</h1>}
submitButtonText='Next'
onFormSubmit={onFormSubmit}
isDisabled={false}
>
<label htmlFor='regionSelect'>Enter a region</label>
<Select
id='regionSelect'
options={regionsOfWorld}
onChange={onRegionSelect}
value={selectedRegionOfWorld.index}
autoFocus
/>
</FormSection>
);
};
export default RegionSelectSection;