From 8f4c07cd0672080b1e59fc4d3118e5c879d0a07c Mon Sep 17 00:00:00 2001 From: katspaugh <381895+katspaugh@users.noreply.github.com> Date: Wed, 8 May 2024 16:44:46 +0200 Subject: [PATCH] Refactor: walletconnect card on dashboard (#3616) --- public/images/common/walletconnect.svg | 4 +- .../dashboard/FeaturedApps/FeaturedApps.tsx | 51 ++++++++++--------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/public/images/common/walletconnect.svg b/public/images/common/walletconnect.svg index f2970ae478..c3d115798a 100644 --- a/public/images/common/walletconnect.svg +++ b/public/images/common/walletconnect.svg @@ -1,3 +1,3 @@ - - + + diff --git a/src/components/dashboard/FeaturedApps/FeaturedApps.tsx b/src/components/dashboard/FeaturedApps/FeaturedApps.tsx index 1d5bed056c..fbef5f3013 100644 --- a/src/components/dashboard/FeaturedApps/FeaturedApps.tsx +++ b/src/components/dashboard/FeaturedApps/FeaturedApps.tsx @@ -1,32 +1,27 @@ import type { ReactElement, SyntheticEvent } from 'react' import { Box, Grid, Typography, Link } from '@mui/material' -import type { SafeAppData } from '@safe-global/safe-gateway-typescript-sdk' import { Card, WidgetBody, WidgetContainer } from '../styled' -import { useRouter } from 'next/router' import NextLink from 'next/link' -import { AppRoutes } from '@/config/routes' -import { SafeAppsTag } from '@/config/constants' -import { useRemoteSafeApps } from '@/hooks/safe-apps/useRemoteSafeApps' import SafeAppIconCard from '@/components/safe-apps/SafeAppIconCard' -import { isWalletConnectSafeApp } from '@/utils/gateway' import { openWalletConnect } from '@/features/walletconnect/components' import { useHasFeature } from '@/hooks/useChains' import { FEATURES } from '@/utils/chains' +import { useTxBuilderApp } from '@/hooks/safe-apps/useTxBuilderApp' -const FeaturedAppCard = ({ app }: { app: SafeAppData }) => ( +const FeaturedAppCard = ({ name, description, iconUrl }: { name: string; description: string; iconUrl: string }) => ( - + - {app.description} + {description} - Use {app.name} + Use {name} @@ -39,11 +34,8 @@ const onWcWidgetClick = (e: SyntheticEvent) => { } export const FeaturedApps = ({ stackedLayout }: { stackedLayout: boolean }): ReactElement | null => { - const router = useRouter() - const [featuredApps, _, remoteSafeAppsLoading] = useRemoteSafeApps(SafeAppsTag.DASHBOARD_FEATURED) - const enableWc = useHasFeature(FEATURES.NATIVE_WALLETCONNECT) - - if (!featuredApps?.length && !remoteSafeAppsLoading) return null + const txBuilder = useTxBuilderApp() + const isWcEnabled = useHasFeature(FEATURES.NATIVE_WALLETCONNECT) return ( @@ -53,17 +45,28 @@ export const FeaturedApps = ({ stackedLayout }: { stackedLayout: boolean }): Rea - {featuredApps?.map((app) => ( - - - + {txBuilder?.app && ( + + + - ))} + )} + {isWcEnabled && ( + + + + + + )}