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

refresh balance after sending tokens #1857

Merged
merged 1 commit into from
Dec 7, 2022
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
58 changes: 34 additions & 24 deletions nym-wallet/src/components/Send/SendSuccessModal.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import React, { useContext } from 'react';
import { Stack, Typography, SxProps } from '@mui/material';
import { Link } from '@nymproject/react/link/Link';
import { TTransactionDetails } from './types';
import { ConfirmationModal } from '../Modals/ConfirmationModal';
import { AppContext } from 'src/context';

export const SendSuccessModal = ({
txDetails,
Expand All @@ -14,26 +15,35 @@ export const SendSuccessModal = ({
onClose: () => void;
sx?: SxProps;
backdropProps?: object;
}) => (
<ConfirmationModal
open
onConfirm={onClose}
onClose={onClose}
title=""
confirmButton="Done"
maxWidth="xs"
fullWidth
sx={sx}
backdropProps={backdropProps}
>
<Stack alignItems="center" spacing={2}>
<Typography>You sent</Typography>
{txDetails && (
<>
<Typography variant="h5">{txDetails.amount}</Typography>
<Link href={txDetails.txUrl} target="_blank" sx={{ ml: 1 }} text="View on blockchain" />
</>
)}
</Stack>
</ConfirmationModal>
);
}) => {
const { userBalance } = useContext(AppContext);

const handleClose = async () => {
await userBalance.refreshBalances();
onClose();
};

return (
<ConfirmationModal
open
onConfirm={handleClose}
onClose={handleClose}
title=""
confirmButton="Done"
maxWidth="xs"
fullWidth
sx={sx}
backdropProps={backdropProps}
>
<Stack alignItems="center" spacing={2}>
<Typography>You sent</Typography>
{txDetails && (
<>
<Typography variant="h5">{txDetails.amount}</Typography>
<Link href={txDetails.txUrl} target="_blank" sx={{ ml: 1 }} text="View on blockchain" />
</>
)}
</Stack>
</ConfirmationModal>
);
};