Skip to content

Commit

Permalink
NavigationRays component to handle null or undefined walletAddress (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinciarka committed Jul 16, 2024
1 parent 96de260 commit 5b8076d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
21 changes: 13 additions & 8 deletions components/navigation/NavigationRays.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ export const NavigationRays = () => {

const raysUserData = useUserRays({ walletAddress })

if (!raysUserData?.userRays || !Rays) {
if (!Rays) {
return null
}

return (
<Flex sx={{ mr: !isViewBelowL ? 3 : 0, alignItems: 'center' }}>
<a
href={`${INTERNAL_LINKS.rays}?userAddress=${walletAddress}`}
href={
walletAddress
? `${INTERNAL_LINKS.rays}?userAddress=${walletAddress}`
: INTERNAL_LINKS.rays
}
style={{ textDecoration: 'none' }}
>
<Flex
Expand All @@ -38,12 +42,13 @@ export const NavigationRays = () => {
<Icon icon={rays} size={24} />{' '}
{!isViewBelowL && (
<Text variant="boldParagraph3" sx={{ fontSize: 1 }}>
{
formatCryptoBalance(new BigNumber(raysUserData?.userRays.allPossiblePoints)).split(
'.',
)[0]
}{' '}
Rays
{raysUserData?.userRays
? `${
formatCryptoBalance(
new BigNumber(raysUserData?.userRays.allPossiblePoints),
).split('.')[0]
} Rays`
: 'Get $RAYS'}
</Text>
)}
</Flex>
Expand Down
5 changes: 3 additions & 2 deletions features/navigation/controls/NavigationActionsController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ export function NavigationActionsController({ isConnected }: NavigationActionsCo
{isViewBelowXl && <NavigationRays />}
{isViewBelowXl && <MyPositionsOrb />}
{!isViewBelowXl && <NavigationRays />}
{<NavigationNetworkSwitcherOrb />}
<NavigationNetworkSwitcherOrb />
{isViewBelowM ? <WalletPanelMobile /> : <WalletOrb />}
</>
) : (
<>
{<NavigationNetworkSwitcherOrb />}
<NavigationRays />
<NavigationNetworkSwitcherOrb />
{!isViewBelowL && <ConnectButton />}
</>
)}
Expand Down

0 comments on commit 5b8076d

Please sign in to comment.