From 5d8e84e5412d8999cc704cca74d762e7708e5a6c Mon Sep 17 00:00:00 2001 From: Olha Date: Wed, 5 Mar 2025 14:28:53 +0100 Subject: [PATCH] fix: split components into three --- .../Root_PurchaseConfirmationScreen.tsx | 101 +++++----- .../components/PaymentBrand.tsx | 7 +- .../components/PaymentCard.tsx | 138 +++++++++++++ .../components/SelectPaymentMethodSheet.tsx | 186 ++++++++++++++++-- .../Profile_PaymentMethodsScreen.tsx | 48 ++++- .../screens/subscreens/AnonymousPurchases.ts | 5 + .../screens/subscreens/PaymentMethods.ts | 3 +- .../subscreens/PurchaseConfirmation.ts | 35 ++-- .../subscreens/SelectPaymentMethodTexts.ts | 4 +- 9 files changed, 435 insertions(+), 92 deletions(-) create mode 100644 src/stacks-hierarchy/Root_PurchaseConfirmationScreen/components/PaymentCard.tsx diff --git a/src/stacks-hierarchy/Root_PurchaseConfirmationScreen/Root_PurchaseConfirmationScreen.tsx b/src/stacks-hierarchy/Root_PurchaseConfirmationScreen/Root_PurchaseConfirmationScreen.tsx index 0b604f165b..1002afd362 100644 --- a/src/stacks-hierarchy/Root_PurchaseConfirmationScreen/Root_PurchaseConfirmationScreen.tsx +++ b/src/stacks-hierarchy/Root_PurchaseConfirmationScreen/Root_PurchaseConfirmationScreen.tsx @@ -1,10 +1,4 @@ import {useAnalyticsContext} from '@atb/analytics'; -import { - Amex, - MasterCard, - Vipps, - Visa, -} from '@atb/assets/svg/color/icons/ticketing'; import {useBottomSheetContext} from '@atb/components/bottom-sheet'; import {Button} from '@atb/components/button'; import {MessageInfoBox} from '@atb/components/message-info-box'; @@ -52,6 +46,9 @@ import {closeInAppBrowseriOS} from '@atb/in-app-browser'; import {openInAppBrowser} from '@atb/in-app-browser/in-app-browser'; import {APP_SCHEME} from '@env'; import {useAuthContext} from '@atb/auth'; +import {GenericSectionItem, Section} from '@atb/components/sections'; +import {formatNumberToString} from '@atb/utils/numbers'; +import {PaymentSelectionCard} from './components/PaymentCard'; type Props = RootStackScreenProps<'Root_PurchaseConfirmationScreen'>; @@ -61,7 +58,7 @@ export const Root_PurchaseConfirmationScreen: React.FC = ({ }) => { const styles = useStyles(); const {theme} = useThemeContext(); - const {t} = useTranslation(); + const {t, language} = useTranslation(); const {userId} = useAuthContext(); const interactiveColor = theme.color.interactive[0]; @@ -108,6 +105,7 @@ export const Root_PurchaseConfirmationScreen: React.FC = ({ offer_id, }), ); + const totalPriceString = formatNumberToString(totalPrice, language); const reserveMutation = useReserveOfferMutation({ offers, @@ -191,28 +189,6 @@ export const Root_PurchaseConfirmationScreen: React.FC = ({ } } - function getPaymentMethodTexts(method: PaymentMethod): string { - let str; - switch (method.paymentType) { - case PaymentType.Vipps: - str = t(PurchaseConfirmationTexts.payWithVipps.text); - break; - case PaymentType.Visa: - str = t(PurchaseConfirmationTexts.payWithVisa.text); - break; - case PaymentType.Mastercard: - str = t(PurchaseConfirmationTexts.payWithMasterCard.text); - break; - case PaymentType.Amex: - str = t(PurchaseConfirmationTexts.payWithAmex.text); - break; - } - if (method.recurringCard) { - str = str + ` (**** ${method.recurringCard.masked_pan})`; - } - return str; - } - async function selectPaymentMethod() { openBottomSheet(() => { return ( @@ -318,6 +294,16 @@ export const Root_PurchaseConfirmationScreen: React.FC = ({ type="error" /> )} + {paymentMethod && ( +
+ + + +
+ )} {isSearchingOffer ? ( = ({