From dbb147a13cfc4859365bdee9a7f4af88654eb701 Mon Sep 17 00:00:00 2001 From: jusrhee Date: Wed, 17 Apr 2024 13:44:27 -0400 Subject: [PATCH] trial banner boilerplate fe --- dashboard/src/main/home/Home.tsx | 58 ++++++++++++++++++- .../src/main/home/modals/BillingModal.tsx | 51 +++++++++++----- 2 files changed, 92 insertions(+), 17 deletions(-) diff --git a/dashboard/src/main/home/Home.tsx b/dashboard/src/main/home/Home.tsx index de63bed609..9c29e4cfd2 100644 --- a/dashboard/src/main/home/Home.tsx +++ b/dashboard/src/main/home/Home.tsx @@ -12,6 +12,7 @@ import ConfirmOverlay from "components/ConfirmOverlay"; import Loading from "components/Loading"; import NoClusterPlaceHolder from "components/NoClusterPlaceHolder"; import Button from "components/porter/Button"; +import Link from "components/porter/Link"; import Modal from "components/porter/Modal"; import Spacer from "components/porter/Spacer"; import Text from "components/porter/Text"; @@ -56,6 +57,7 @@ import CreateClusterForm from "./infrastructure-dashboard/forms/CreateClusterFor import Integrations from "./integrations/Integrations"; import LaunchWrapper from "./launch/LaunchWrapper"; import ModalHandler from "./ModalHandler"; +import BillingModal from "./modals/BillingModal"; import Navbar from "./navbar/Navbar"; import { NewProjectFC } from "./new-project/NewProject"; import Onboarding from "./onboarding/Onboarding"; @@ -108,6 +110,7 @@ const Home: React.FC = (props) => { setShouldRefreshClusters, } = useContext(Context); + const [showBillingModal, setShowBillingModal] = useState(false); const [showWelcome, setShowWelcome] = useState(false); const [forceRefreshClusters, setForceRefreshClusters] = useState(false); const [ghRedirect, setGhRedirect] = useState(false); @@ -363,13 +366,52 @@ const Home: React.FC = (props) => { pushFiltered(props, "/dashboard", []); }; + const showCardBanner = true; + const trialExpired = true; + const { cluster, baseRoute } = props.match.params as any; return ( - + + {!currentProject?.sandbox_enabled && showCardBanner && ( + <> + + warning + Please + + { + setShowBillingModal(true); + }} + > + connect a valid payment method + + . Your project has 127 free days remaining. + + {!trialExpired && showBillingModal && ( + { + setShowBillingModal(false); + }} + onCreate={async () => { + setShowBillingModal(false); + }} + /> + )} + {trialExpired && ( + { + setShowBillingModal(false); + }} + /> + )} + + )} {currentOverlay && createPortal( @@ -620,9 +662,10 @@ const GlobalBanner = styled.div` z-index: 999; position: fixed; top: 0; + color: #fefefe; left: 0; height: 35px; - background: #263061; + background: #4752ba; display: flex; align-items: center; justify-content: center; @@ -633,6 +676,12 @@ const GlobalBanner = styled.div` height: 16px; margin-right: 10px; } + + > i { + margin-right: 10px; + font-size: 16px; + opacity: 0.8; + } `; const ViewWrapper = styled.div` @@ -657,13 +706,16 @@ const DashboardWrapper = styled.div` height: fit-content; `; -const StyledHome = styled.div` +const StyledHome = styled.div<{ + showCardBanner: boolean; +}>` width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; margin: 0; + padding-top: ${(props) => (props.showCardBanner ? "35px" : "0")}; user-select: none; display: flex; justify-content: center; diff --git a/dashboard/src/main/home/modals/BillingModal.tsx b/dashboard/src/main/home/modals/BillingModal.tsx index 51823c2715..7a227207f4 100644 --- a/dashboard/src/main/home/modals/BillingModal.tsx +++ b/dashboard/src/main/home/modals/BillingModal.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useContext } from "react"; import { Elements } from "@stripe/react-stripe-js"; import { loadStripe } from "@stripe/stripe-js"; @@ -8,15 +8,20 @@ import Spacer from "components/porter/Spacer"; import Text from "components/porter/Text"; import { usePublishableKey } from "lib/hooks/useStripe"; +import { Context } from "shared/Context"; + import PaymentSetupForm from "./PaymentSetupForm"; const BillingModal = ({ back, onCreate, + trialExpired, }: { - back: (value: React.SetStateAction) => void; + back?: (value: React.SetStateAction) => void; onCreate: () => Promise; + trialExpired?: boolean; }) => { + const { currentProject } = useContext(Context); const { publishableKey } = usePublishableKey(); const stripePromise = loadStripe(publishableKey); @@ -44,20 +49,38 @@ const BillingModal = ({ return (
- Add payment method - - - - You will not be charged until you have an app deployed and have run - out of credits. - {" "} - A payment method is required to begin deploying applications on - Porter. You can learn more about our pricing{" "} - - here - + + {trialExpired + ? "Your Porter trial has expired" + : "Add payment method"} + {currentProject?.sandbox_enabled ? ( + + + You will not be charged until you have an app deployed and have + run out of credits. + {" "} + A payment method is required to begin deploying applications on + Porter. You can learn more about our pricing{" "} + + here + + + ) : ( + + {trialExpired + ? `Your applications will continue to run but you will not be able to access your project until you link a payment method. ` + : "Link a payment method to your Porter project."} +
+
+ {`You can learn more about our pricing under "For Businesses" `} + + here + +
+ )} +