|
1 | 1 | import { type FC, useCallback } from 'react'; |
2 | 2 |
|
3 | | -import { |
4 | | - type ModalData, |
5 | | - useValidatorModal, |
6 | | -} from 'features/validators/contexts'; |
7 | | -import { VALIDATOR_MODALS } from 'features/validators/const'; |
8 | | - |
9 | 3 | import { SwitcherItemStyled, SwitcherStyled } from './styles'; |
10 | 4 |
|
| 5 | +export type WithdrawalVariant = 'partial' | 'full'; |
| 6 | + |
11 | 7 | type WithdrawalTypeProps = { |
12 | | - modalData: ModalData; |
| 8 | + value: WithdrawalVariant; |
| 9 | + onChange: (value: WithdrawalVariant) => void; |
13 | 10 | }; |
14 | 11 |
|
15 | | -export const WithdrawalType: FC<WithdrawalTypeProps> = ({ modalData }) => { |
16 | | - const { openModal } = useValidatorModal(); |
17 | | - const { currentModal } = modalData; |
18 | | - const isPartial = VALIDATOR_MODALS.partialWithdrawal === currentModal; |
19 | | - const isFull = VALIDATOR_MODALS.fullWithdrawal === currentModal; |
| 12 | +export const WithdrawalType: FC<WithdrawalTypeProps> = ({ |
| 13 | + value, |
| 14 | + onChange, |
| 15 | +}) => { |
| 16 | + const isFull = value === 'full'; |
20 | 17 |
|
21 | 18 | const openPartialWithdrawal = useCallback(() => { |
22 | | - openModal({ |
23 | | - ...modalData, |
24 | | - currentModal: VALIDATOR_MODALS.partialWithdrawal, |
25 | | - }); |
26 | | - }, [openModal, modalData]); |
| 19 | + onChange('partial'); |
| 20 | + }, [onChange]); |
27 | 21 |
|
28 | 22 | const openFullWithdrawal = useCallback(() => { |
29 | | - openModal({ |
30 | | - ...modalData, |
31 | | - currentModal: VALIDATOR_MODALS.fullWithdrawal, |
32 | | - }); |
33 | | - }, [openModal, modalData]); |
| 23 | + onChange('full'); |
| 24 | + }, [onChange]); |
34 | 25 |
|
35 | 26 | return ( |
36 | 27 | <SwitcherStyled> |
37 | | - <SwitcherItemStyled active={isPartial} onClick={openPartialWithdrawal}> |
| 28 | + <SwitcherItemStyled active={!isFull} onClick={openPartialWithdrawal}> |
38 | 29 | Partial withdrawal |
39 | 30 | </SwitcherItemStyled> |
40 | 31 | <SwitcherItemStyled active={isFull} onClick={openFullWithdrawal}> |
|
0 commit comments