diff --git a/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/ChangePlan/PaymentMethodSelector.tsx b/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/ChangePlan/PaymentMethodSelector.tsx index 430db82645..b53e76df7b 100644 --- a/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/ChangePlan/PaymentMethodSelector.tsx +++ b/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/ChangePlan/PaymentMethodSelector.tsx @@ -86,7 +86,7 @@ interface IPaymentMethodProps { const PaymentMethodSelector = ({ selectedProductPrice, goBack, onSelectPaymentMethod }: IPaymentMethodProps) => { const classes = useStyles() const [paymentMethod, setPaymentMethod] = useState<"creditCard" | "crypto" | undefined>() - const [view, setView] = useState<"selectPaymentMethod" | "addCard">("selectPaymentMethod") + const [isCardFormOpen, setIsCardFormOpen] = useState(false) const { defaultCard } = useBilling() useEffect(() => { @@ -110,10 +110,10 @@ const PaymentMethodSelector = ({ selectedProductPrice, goBack, onSelectPaymentMe component="p" className={classes.subHeading} > - {view === "addCard" && This card will become your default payment method} + {isCardFormOpen && This card will become your default payment method} - {view === "selectPaymentMethod" && <> + {!isCardFormOpen && <>
setView("addCard")} + onClick={() => setIsCardFormOpen(true)} data-cy={defaultCard ? "text-button-update-card" : "text-button-add-card"} > {defaultCard @@ -149,17 +149,16 @@ const PaymentMethodSelector = ({ selectedProductPrice, goBack, onSelectPaymentMe /> } - {view === "addCard" &&
+ {isCardFormOpen &&
setView("selectPaymentMethod")} - goBack={() => setView("selectPaymentMethod")} + onCardAdd={() => setIsCardFormOpen(false)} + goBack={() => setIsCardFormOpen(false)} />
} - -
+ {!isCardFormOpen &&
-
+
} ) } diff --git a/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/Common/AddCard.tsx b/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/Common/AddCard.tsx index 5141d348e5..ea13e0d315 100644 --- a/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/Common/AddCard.tsx +++ b/packages/files-ui/src/Components/Modules/Settings/SubscriptionTab/Common/AddCard.tsx @@ -1,10 +1,11 @@ import React, { FormEvent, useMemo, useState } from "react" -import { Button, Grid, Typography, useToasts } from "@chainsafe/common-components" +import { Button, Typography, useToasts } from "@chainsafe/common-components" import { createStyles, makeStyles, useTheme, useThemeSwitcher } from "@chainsafe/common-theme" import { CSFTheme } from "../../../../../Themes/types" import CustomButton from "../../../../Elements/CustomButton" import { t, Trans } from "@lingui/macro" -import { useStripe, +import { + useStripe, useElements, CardNumberElement, CardExpiryElement, @@ -61,14 +62,14 @@ const useStyles = makeStyles( marginTop: constants.generalUnit * 2, color: palette.error.main }, - backButton: { - flex: 1, + buttons: { display: "flex", - alignItems: "center" - }, - linkButton: { - textDecoration: "underline", - cursor: "pointer" + flexDirection: "row", + alignItems: "center", + justifyContent: "flex-end", + "& > *": { + marginLeft: constants.generalUnit + } } }) } @@ -168,7 +169,8 @@ const AddCard = ({ onClose, onCardAdd, footerClassName, submitText, goBack }: IA color: theme.constants.addCard.placeholderColor } } - } }} + } + }} onFocus={() => setFocusElement("number")} onBlur={() => setFocusElement(undefined)} onChange={() => setCardAddError(undefined)} @@ -191,7 +193,8 @@ const AddCard = ({ onClose, onCardAdd, footerClassName, submitText, goBack }: IA color: theme.constants.addCard.placeholderColor } } - } }} + } + }} />
{cardAddError && } - -
- {goBack && - - Go back - - } -
+
+ {goBack && + + } {onClose && {submitText} - +
)