From 81bef69e5d960613b00ddf4ce7060fa535c8e867 Mon Sep 17 00:00:00 2001 From: Maxime Beauchamp <15185355+baktun14@users.noreply.github.com> Date: Wed, 4 Dec 2024 12:40:23 -0500 Subject: [PATCH 01/26] features/credit card banner (#514) --- apps/deploy-web/package.json | 1 + .../components/layout/CreditCardBanner.tsx | 14 +++ .../src/components/layout/Layout.tsx | 87 ++++++++----------- apps/deploy-web/src/components/layout/Nav.tsx | 7 +- .../src/components/layout/Sidebar.tsx | 16 ++-- .../src/components/layout/WelcomeModal.tsx | 63 -------------- .../wallet/ConnectManagedWalletButton.tsx | 10 ++- .../src/hooks/useHasCreditCardBanner.ts | 32 +++++++ .../src/pages/new-deployment/index.tsx | 19 +++- package-lock.json | 3 +- packages/ui/components/button.tsx | 2 +- 11 files changed, 127 insertions(+), 127 deletions(-) create mode 100644 apps/deploy-web/src/components/layout/CreditCardBanner.tsx delete mode 100644 apps/deploy-web/src/components/layout/WelcomeModal.tsx create mode 100644 apps/deploy-web/src/hooks/useHasCreditCardBanner.ts diff --git a/apps/deploy-web/package.json b/apps/deploy-web/package.json index 3784e04d9..9b6b271af 100644 --- a/apps/deploy-web/package.json +++ b/apps/deploy-web/package.json @@ -21,6 +21,7 @@ "@akashnetwork/akashjs": "^0.10.0", "@akashnetwork/env-loader": "*", "@akashnetwork/http-sdk": "*", + "@akashnetwork/logging": "*", "@akashnetwork/network-store": "*", "@akashnetwork/ui": "*", "@auth0/nextjs-auth0": "^3.5.0", diff --git a/apps/deploy-web/src/components/layout/CreditCardBanner.tsx b/apps/deploy-web/src/components/layout/CreditCardBanner.tsx new file mode 100644 index 000000000..4492a0023 --- /dev/null +++ b/apps/deploy-web/src/components/layout/CreditCardBanner.tsx @@ -0,0 +1,14 @@ +import { useWallet } from "@src/context/WalletProvider/WalletProvider"; +import { ConnectManagedWalletButton } from "../wallet/ConnectManagedWalletButton"; + +export function CreditCardBanner() { + const { hasManagedWallet } = useWallet(); + + return ( +
+ Credit Card payments are now available! + + {!hasManagedWallet && } +
+ ); +} diff --git a/apps/deploy-web/src/components/layout/Layout.tsx b/apps/deploy-web/src/components/layout/Layout.tsx index 97afb5d2f..bc2e4faf8 100644 --- a/apps/deploy-web/src/components/layout/Layout.tsx +++ b/apps/deploy-web/src/components/layout/Layout.tsx @@ -9,10 +9,11 @@ import { useMediaQuery, useTheme as useMuiTheme } from "@mui/material"; import { ACCOUNT_BAR_HEIGHT } from "@src/config/ui.config"; import { useSettings } from "@src/context/SettingsProvider"; import { useWallet } from "@src/context/WalletProvider"; +import { useHasCreditCardBanner } from "@src/hooks/useHasCreditCardBanner"; import { LinearLoadingSkeleton } from "../shared/LinearLoadingSkeleton"; +import { CreditCardBanner } from "./CreditCardBanner"; import { Nav } from "./Nav"; import { Sidebar } from "./Sidebar"; -import { WelcomeModal } from "./WelcomeModal"; type Props = { isLoading?: boolean; @@ -49,12 +50,12 @@ const Layout: React.FunctionComponent = ({ children, isLoading, isUsingSe const LayoutApp: React.FunctionComponent = ({ children, isLoading, isUsingSettings, isUsingWallet, disableContainer, containerClassName = "" }) => { const muiTheme = useMuiTheme(); - const [isShowingWelcome, setIsShowingWelcome] = useState(false); const [isNavOpen, setIsNavOpen] = useState(true); const [isMobileOpen, setIsMobileOpen] = useState(false); const { refreshNodeStatuses, isSettingsInit } = useSettings(); const { isWalletLoaded } = useWallet(); const smallScreen = useMediaQuery(muiTheme.breakpoints.down("md")); + const hasCreditCardBanner = useHasCreditCardBanner(); useEffect(() => { const _isNavOpen = localStorage.getItem("isNavOpen"); @@ -71,22 +72,6 @@ const LayoutApp: React.FunctionComponent = ({ children, isLoading, isUsin clearInterval(refreshNodeIntervalId); }; }, [refreshNodeStatuses]); - - useEffect(() => { - const agreedToTerms = localStorage.getItem("agreedToTerms") === "true"; - - if (!agreedToTerms) { - setIsShowingWelcome(true); - } - - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - const onWelcomeClose = () => { - localStorage.setItem("agreedToTerms", "true"); - setIsShowingWelcome(false); - }; - const onOpenMenuClick = () => { setIsNavOpen(prev => { const newValue = !prev; @@ -102,42 +87,46 @@ const LayoutApp: React.FunctionComponent = ({ children, isLoading, isUsin }; return ( - <> - - -
-
-
-