Skip to content

Commit

Permalink
fix: add switch unit logic to CJIT screen
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed May 15, 2024
1 parent c52ff13 commit 02d72a8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/screens/Wallets/Receive/ReceiveAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
unitSelector,
} from '../../../store/reselect/settings';
import type { ReceiveScreenProps } from '../../../navigation/types';
import { useSwitchUnit } from '../../../hooks/wallet';

const ReceiveAmount = ({
navigation,
Expand All @@ -43,6 +44,7 @@ const ReceiveAmount = ({
const denomination = useAppSelector(denominationSelector);
const invoice = useAppSelector(receiveSelector);
const blocktank = useAppSelector(blocktankInfoSelector);
const switchUnit = useSwitchUnit();
const [minimumAmount, setMinimumAmount] = useState(0);

const { maxChannelSizeSat } = blocktank.options;
Expand Down Expand Up @@ -76,12 +78,17 @@ const ReceiveAmount = ({
const onChangeUnit = (): void => {
const result = getNumberPadText(invoice.amount, denomination, nextUnit);
dispatch(updateInvoice({ numberPadText: result }));
switchUnit();
};

const onContinue = (): void => {
navigation.navigate('ReceiveConnect');
};

const onNumberPadPress = (): void => {
onChangeUnit();
};

const continueDisabled =
invoice.amount < minimumAmount || invoice.amount > channelSize;

Expand All @@ -95,6 +102,7 @@ const ReceiveAmount = ({
<NumberPadTextField
value={invoice.numberPadText}
testID="ReceiveNumberPadTextField"
onPress={onNumberPadPress}
/>

<View style={styles.numberPad} testID="ReceiveNumberPad">
Expand Down

0 comments on commit 02d72a8

Please sign in to comment.