-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSelectContainer.tsx
49 lines (41 loc) · 1.42 KB
/
SelectContainer.tsx
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
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { selectContainerLayout, selectSection } from './SelectContainer.styled';
import Button from '@/components/common/Button/Button';
import SelectOption from '@/components/SelectOption/SelectOption';
import useBalanceContentQuery from '@/hooks/useBalanceContentQuery';
const SelectContainer = () => {
const navigate = useNavigate();
const { balanceContent, isLoading } = useBalanceContentQuery();
const [selectedId, setSelectedId] = useState(0);
const goToRoundResult = () => {
navigate('/round-result');
};
const handleSelectOption = (selectedId: number) => {
setSelectedId(selectedId);
};
if (isLoading) return <div>Loading...</div>;
return (
<>
{balanceContent && (
<div css={selectContainerLayout}>
<section css={selectSection}>
<SelectOption
option={balanceContent.firstOption}
selectedId={selectedId}
handleSelectOption={handleSelectOption}
/>
<span>VS</span>
<SelectOption
option={balanceContent.secondOption}
selectedId={selectedId}
handleSelectOption={handleSelectOption}
/>
</section>
<Button text="선택" active={Boolean(selectedId)} onClick={goToRoundResult} />
</div>
)}
</>
);
};
export default SelectContainer;