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: removed unnecessary forwardwithrefs #4426

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Flex, StackProps } from '@stacks/ui';
import { forwardRefWithAs } from '@stacks/ui-core';
import { CryptoAssetSelectors } from '@tests/selectors/crypto-asset.selectors';
import { HStack } from 'leather-styles/jsx';
import { Flex, HStack } from 'leather-styles/jsx';
import { StackProperties } from 'leather-styles/patterns';

import { Money } from '@shared/models/money.model';

Expand All @@ -13,51 +11,42 @@ import { Caption, Text } from '@app/components/typography';

import { LoadingSpinner } from '../loading-spinner';

interface BitcoinContractEntryPointLayoutProps extends StackProps {
interface BitcoinContractEntryPointLayoutProps extends StackProperties {
balance: Money;
caption: string;
icon: React.JSX.Element;
usdBalance?: string;
isLoading?: boolean;
cursor?: 'pointer' | 'default';
onClick: () => void;
}
export const BitcoinContractEntryPointLayout = forwardRefWithAs(
(props: BitcoinContractEntryPointLayoutProps) => {
const { balance, caption, icon, usdBalance, isLoading, onClick } = props;
export function BitcoinContractEntryPointLayout(props: BitcoinContractEntryPointLayoutProps) {
const { balance, caption, icon, usdBalance, isLoading, cursor, onClick } = props;

const amount = balance.decimals
? ftDecimals(balance.amount, balance.decimals)
: balance.amount.toString();
const dataTestId = CryptoAssetSelectors.CryptoAssetListItem.replace(
'{symbol}',
balance.symbol.toLowerCase()
);
const formattedBalance = formatBalance(amount);
const amount = balance.decimals
? ftDecimals(balance.amount, balance.decimals)
: balance.amount.toString();
const formattedBalance = formatBalance(amount);

return (
<Flex as={'button'} onClick={onClick} data-testid={dataTestId} outline={0}>
<Flag img={icon} align="middle" spacing="base" width="100%">
<HStack alignItems="center" justifyContent="space-between" width="100%">
<Text>{'Bitcoin Contracts'}</Text>
<Tooltip
label={formattedBalance.isAbbreviated ? balance.amount.toString() : undefined}
placement="left-start"
>
<Text
data-testid={'Bitcoin Contracts'}
fontVariantNumeric="tabular-nums"
textAlign="right"
>
{isLoading ? <LoadingSpinner size="sm" /> : formattedBalance.value}
</Text>
</Tooltip>
</HStack>
<HStack height="1.25rem" alignItems="center" justifyContent="space-between" width="100%">
<Caption>{caption}</Caption>
<Flex>{isLoading ? '' : <Caption>{usdBalance}</Caption>}</Flex>
</HStack>
</Flag>
</Flex>
);
}
);
return (
<Flex cursor={cursor} onClick={onClick} outline={0}>
<Flag img={icon} align="middle" spacing="base" width="100%">
<HStack alignItems="center" justifyContent="space-between" width="100%">
<Text>{'Bitcoin Contracts'}</Text>
<Tooltip
label={formattedBalance.isAbbreviated ? balance.amount.toString() : undefined}
placement="left-start"
>
<Text fontVariantNumeric="tabular-nums" textAlign="right">
{isLoading ? <LoadingSpinner size="sm" /> : formattedBalance.value}
</Text>
</Tooltip>
</HStack>
<HStack height="1.25rem" alignItems="center" justifyContent="space-between" width="100%">
<Caption>{caption}</Caption>
<Flex>{isLoading ? '' : <Caption>{usdBalance}</Caption>}</Flex>
</HStack>
</Flag>
</Flex>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
setBitcoinContractSum(currentBitcoinContractSum);
setIsLoading(false);
};
getBitcoinContractDataAndSetState();

Check warning on line 36 in src/app/components/bitcoin-contract-entry-point/bitcoin-contract-entry-point.tsx

View workflow job for this annotation

GitHub Actions / lint-eslint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [btcAddress]);

Expand All @@ -44,11 +44,11 @@
return (
<BitcoinContractEntryPointLayout
isLoading={isLoading}
cursor={'pointer'}
balance={bitcoinContractSum}
caption={bitcoinContractSum.symbol}
icon={<Box as={BitcoinContractIcon} />}
usdBalance={i18nFormatCurrency(calculateFiatValue(bitcoinContractSum))}
cursor={'pointer'}
onClick={onClick}
/>
);
Expand Down
Loading