Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add switch unit logic to CJIT screen #1827

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
pwltr marked this conversation as resolved.
Show resolved Hide resolved
};

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
Loading