Skip to content

Commit

Permalink
fix(send): show invoice expiry as date
Browse files Browse the repository at this point in the history
  • Loading branch information
pwltr committed Feb 28, 2024
1 parent adff5ff commit 18caee7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/screens/Wallets/Send/ReviewAndSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, {
import { StyleSheet, View, TouchableOpacity, Keyboard } from 'react-native';
import { TInvoice } from '@synonymdev/react-native-ldk';
import { useTranslation } from 'react-i18next';
import { validateTransaction } from 'beignet';

import { Caption13Up, Text02M } from '../../../styles/text';
import {
Expand Down Expand Up @@ -75,7 +76,7 @@ import { updateLastPaidContacts } from '../../../store/slices/slashtags';
import { truncate } from '../../../utils/helpers';
import AmountToggle from '../../../components/AmountToggle';
import LightningSyncing from '../../../components/LightningSyncing';
import { validateTransaction } from 'beignet';
import { i18nTime } from '../../../utils/i18n';

const Section = memo(
({
Expand Down Expand Up @@ -106,6 +107,7 @@ const ReviewAndSend = ({
navigation,
}: SendScreenProps<'ReviewAndSend'>): ReactElement => {
const { t, i18n } = useTranslation('wallet');
const { t: tTime } = useTranslation('intl', { i18n: i18nTime });
const selectedWallet = useAppSelector(selectedWalletSelector);
const selectedNetwork = useAppSelector(selectedNetworkSelector);
const onChainBalance = useAppSelector(onChainBalanceSelector);
Expand Down Expand Up @@ -562,6 +564,10 @@ const ReviewAndSend = ({
}
}, [selectedFeeId]);

const invoiceExpiryTimestamp = new Date(
new Date().getTime() + decodedInvoice?.expiry_time! * 1000,
);

return (
<>
<GradientView style={styles.container}>
Expand Down Expand Up @@ -646,7 +652,17 @@ const ReviewAndSend = ({
<>
<ClockIcon style={styles.icon} color="purple" />
<Text02M>
{(decodedInvoice.expiry_time / 60).toFixed()} minutes
{tTime('dateTime', {
v: invoiceExpiryTimestamp,
formatParams: {
v: {
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
},
},
})}
</Text02M>
</>
}
Expand Down

0 comments on commit 18caee7

Please sign in to comment.