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

nft expanded state sell button #5428

Merged
merged 1 commit into from
Feb 22, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
130 changes: 84 additions & 46 deletions src/components/expanded-state/UniqueTokenExpandedState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ import { getUniqueTokenType, magicMemo, safeAreaInsetValues } from '@/utils';
import { usePersistentDominantColorFromImage } from '@/hooks/usePersistentDominantColorFromImage';
import { buildRainbowUrl } from '@/utils/buildRainbowUrl';
import isHttpUrl from '@/helpers/isHttpUrl';
import { useNFTOffers } from '@/resources/reservoir/nftOffersQuery';
import { convertAmountToNativeDisplay } from '@/helpers/utilities';

const BackgroundBlur = styled(BlurView).attrs({
blurAmount: 100,
Expand Down Expand Up @@ -226,6 +228,28 @@ const UniqueTokenExpandedState = ({ asset: passedAsset, external }: UniqueTokenE
const { isReadOnlyWallet } = useWallets();
const collecible = useCollectible(passedAsset?.uniqueId);
const asset = external ? passedAsset : collecible;
const {
data: { nftOffers },
} = useNFTOffers({
walletAddress: accountAddress,
});

const offer = useMemo(() => nftOffers?.find(offer => offer.nft.uniqueId === asset.fullUniqueId), [asset.fullUniqueId, nftOffers]);
const offerValue = useMemo(
() =>
offer
? convertAmountToNativeDisplay(
offer.netAmount.usd,
'USD',
undefined,
// don't show decimals
true,
// abbreviate if amount is >= 10,000
offer.netAmount.decimal >= 10_000
)
: undefined,
[offer]
);

const isSupportedOnRainbowWeb = getIsSupportedOnRainbowWeb(asset.network);

Expand Down Expand Up @@ -461,52 +485,66 @@ const UniqueTokenExpandedState = ({ asset: passedAsset, external }: UniqueTokenE
onRefresh={activateRefreshMetadataToast}
/>
</Stack>
{isNFT || isENS ? (
<Columns space="15px (Deprecated)">
{hasEditButton ? (
<SheetActionButton
color={imageColor}
label={`􀉮 ${lang.t('expanded_state.unique_expanded.edit')}`}
nftShadows
onPress={handlePressEdit}
testID="edit"
textColor={textColor}
weight="heavy"
/>
) : isParty ? (
<SheetActionButton
color={imageColor}
nftShadows
onPress={handlePressParty}
testID="unique-expanded-state-party-button"
textColor={textColor}
weight="heavy"
>
<ImgixImage resizeMode="contain" source={partyLogo as any} size={20} style={{ height: 25, width: 25 }} />
<Text weight="heavy" size="20pt" color={{ custom: textColor }}>
Party
</Text>
</SheetActionButton>
) : asset.permalink ? (
<SheetActionButton
color={imageColor}
label={
hasSendButton
? `􀮶 ${marketplaceName}`
: `􀮶 ${lang.t('expanded_state.unique_expanded.view_on_marketplace_name', {
marketplaceName,
})}`
}
nftShadows
onPress={handlePressMarketplaceName}
testID="unique-expanded-state-send"
textColor={textColor}
weight="heavy"
/>
) : null}
{hasSendButton ? <SendActionButton asset={asset} color={imageColor} nftShadows textColor={textColor} /> : null}
</Columns>
) : null}
<Stack space="15px (Deprecated)">
{isNFT || isENS ? (
<Columns space="15px (Deprecated)">
{hasEditButton ? (
<SheetActionButton
color={imageColor}
label={`􀉮 ${lang.t('expanded_state.unique_expanded.edit')}`}
nftShadows
onPress={handlePressEdit}
testID="edit"
textColor={textColor}
weight="heavy"
/>
) : isParty ? (
<SheetActionButton
color={imageColor}
nftShadows
onPress={handlePressParty}
testID="unique-expanded-state-party-button"
textColor={textColor}
weight="heavy"
>
<ImgixImage resizeMode="contain" source={partyLogo as any} size={20} style={{ height: 25, width: 25 }} />
<Text weight="heavy" size="20pt" color={{ custom: textColor }}>
Party
</Text>
</SheetActionButton>
) : asset.permalink ? (
<SheetActionButton
color={imageColor}
label={
hasSendButton
? `􀮶 ${marketplaceName}`
: `􀮶 ${lang.t('expanded_state.unique_expanded.view_on_marketplace_name', {
marketplaceName,
})}`
}
nftShadows
onPress={handlePressMarketplaceName}
testID="unique-expanded-state-send"
textColor={textColor}
weight="heavy"
/>
) : null}
{hasSendButton ? <SendActionButton asset={asset} color={imageColor} nftShadows textColor={textColor} /> : null}
</Columns>
) : null}
{!!offer && (
<SheetActionButton
color={imageColor}
label={`􀋡 ${lang.t('expanded_state.unique_expanded.sell_for_x', {
price: offerValue,
})}`}
nftShadows
onPress={() => navigate(Routes.NFT_SINGLE_OFFER_SHEET, { offer })}
textColor={textColor}
weight="heavy"
/>
)}
</Stack>
{asset.network !== Network.mainnet ? (
// @ts-expect-error JavaScript component
<L2Disclaimer
Expand Down
1 change: 1 addition & 0 deletions src/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@
"registrant": "Registrant",
"resolver": "Resolver",
"save_to_photos": "Save to Photos",
"sell_for_x": "Sell for %{price}",
"set_primary_name": "Set as my ENS name",
"share_token_info": "Share %{uniqueTokenName} Info",
"showcase": "Showcase",
Expand Down