Skip to content

Commit

Permalink
Error handling of web3 communication, center miniCard image
Browse files Browse the repository at this point in the history
  • Loading branch information
SunDr17 committed Jan 25, 2024
1 parent de755de commit 61b13d9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/common/MiniCard/MiniCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function MiniCard({ item }: { item: Item }) {
function renderCard() {
return (
<Card bsPrefix={cn(styles['card-flyer'], 'text-center flex-fill card')}>
<div className="image-box pt-2">
<div className="image-box d-flex flex-grow-1 flex-column justify-content-center align-items-center pt-2">
{isSvg(item.imageSrc)
? <FilledSvg
src={item.imageSrc}
Expand All @@ -31,7 +31,7 @@ export default function MiniCard({ item }: { item: Item }) {
/>
}
</div>
<Card.Body>
<Card.Body className="d-flex flex-grow-0 flex-column justify-content-end align-items-center">
<Card.Title>{item.fullName ?? item.name}</Card.Title>
<Card.Text>
{t('miniCard.price', { price: item.price })}
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Modal(props: ModalType) {
{...props}
show={modal.show}
onHide={onHide}
size="lg"
size={modalProps.size ?? 'lg'}
aria-labelledby="contained-modal-title-vcenter"
centered
>
Expand Down
16 changes: 10 additions & 6 deletions src/components/common/web3/SendTransactionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ export default function SendTransactionButton({
} = useSendTransaction();

async function sendTransactionClick() {
await sendTransactionAsync({
to: process.env.REACT_APP_WEB3_WALLET_BASE_ADDRESS as `0x${string}`,
value: parseEther(String(transactionSum)),
});
try {
await sendTransactionAsync({
to: process.env.REACT_APP_WEB3_WALLET_BASE_ADDRESS as `0x${string}`,
value: parseEther(String(transactionSum)),
});

if (onConfirm) {
onConfirm();
if (onConfirm) {
onConfirm();
}
} catch (e) {
// errors handled by useSendTransaction().error prop
}
}

Expand Down
1 change: 1 addition & 0 deletions src/components/pages/Home/FinishCycleModalButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function FinishCycleModalButton({ onFinishCycle }: Props) {

const openModal = () => {
dispatch(showModal({
size: 'sm',
onConfirm,
header: t('finish_cycle_modal.header'),
body: t('finish_cycle_modal.body'),
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/ReferralProgram/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function ReferralProgram() {
secondaryCurrency: t(`currencies.${CURRENCIES.BNB}`),
})}
</p>
<SendTransactionButton transactionSum={referralBalanceInBnb} />
<SendTransactionButton transactionSum={Number(referralBalanceInBnb.toFixed(6))} />
</div>
</Container>
);
Expand Down

0 comments on commit 61b13d9

Please sign in to comment.