diff --git a/example/src/assets/countries.ts b/example/src/assets/countries.ts new file mode 100644 index 000000000..a07515ad8 --- /dev/null +++ b/example/src/assets/countries.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Adyen N.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ + +export type CountryInfo = { + name: string; + currency: string; +}; + +export const COUNTRY_DATA: Record = { + AE: { name: 'United Arab Emirates', currency: 'AED' }, + AT: { name: 'Austria', currency: 'EUR' }, + AU: { name: 'Australia', currency: 'AUD' }, + BE: { name: 'Belgium', currency: 'EUR' }, + BR: { name: 'Brazil', currency: 'BRL' }, + CA: { name: 'Canada', currency: 'CAD' }, + CH: { name: 'Switzerland', currency: 'CHF' }, + CN: { name: 'China', currency: 'CNY' }, + CZ: { name: 'Czech Republic', currency: 'CZK' }, + DE: { name: 'Germany', currency: 'EUR' }, + DK: { name: 'Denmark', currency: 'DKK' }, + ES: { name: 'Spain', currency: 'EUR' }, + FI: { name: 'Finland', currency: 'EUR' }, + FR: { name: 'France', currency: 'EUR' }, + GB: { name: 'United Kingdom', currency: 'GBP' }, + HK: { name: 'Hong Kong', currency: 'HKD' }, + ID: { name: 'Indonesia', currency: 'IDR' }, + IN: { name: 'India', currency: 'INR' }, + IT: { name: 'Italy', currency: 'EUR' }, + JP: { name: 'Japan', currency: 'JPY' }, + KE: { name: 'Kenya', currency: 'KES' }, + KR: { name: 'South Korea', currency: 'KRW' }, + MX: { name: 'Mexico', currency: 'MXN' }, + MY: { name: 'Malaysia', currency: 'MYR' }, + NL: { name: 'Netherlands', currency: 'EUR' }, + NO: { name: 'Norway', currency: 'NOK' }, + NZ: { name: 'New Zealand', currency: 'NZD' }, + PH: { name: 'Philippines', currency: 'PHP' }, + PL: { name: 'Poland', currency: 'PLN' }, + PT: { name: 'Portugal', currency: 'EUR' }, + RU: { name: 'Russia', currency: 'RUB' }, + SE: { name: 'Sweden', currency: 'SEK' }, + SG: { name: 'Singapore', currency: 'SGD' }, + TH: { name: 'Thailand', currency: 'THB' }, + US: { name: 'United States', currency: 'USD' }, + VN: { name: 'Vietnam', currency: 'VND' }, + ZA: { name: 'South Africa', currency: 'ZAR' }, +}; + +export const COUNTRY_CODES = Object.keys(COUNTRY_DATA); + +export const getCountryLabel = (countryCode: string): string => { + const data = COUNTRY_DATA[countryCode]; + return data ? `${data.name} - ${data.currency}` : countryCode; +}; + +export const getCurrency = (countryCode: string): string | undefined => { + return COUNTRY_DATA[countryCode]?.currency; +}; diff --git a/example/src/components/Checkout/components/PaymentMethodsView.tsx b/example/src/components/Checkout/components/PaymentMethodsView.tsx index 88d2b4a0f..68ef7875f 100644 --- a/example/src/components/Checkout/components/PaymentMethodsView.tsx +++ b/example/src/components/Checkout/components/PaymentMethodsView.tsx @@ -1,6 +1,6 @@ import { useAdyenCheckout } from '@adyen/react-native'; -import { View, Text, ScrollView, ActivityIndicator } from 'react-native'; -import Styles from '../../common/Styles'; +import { Text, ActivityIndicator } from 'react-native'; +import PageScrollView from '../../common/PageScrollView'; import PaymentMethodsList from './PaymentMethodsList'; import DropInButton from './DropInButton'; import PlatformPayButton from './PlatformPayButton'; @@ -37,7 +37,7 @@ const PaymentMethods = (prop: PaymentMethodsProps) => { } return ( - + {showDropIn && } {showEmbeddedComponents && ( @@ -54,9 +54,7 @@ const PaymentMethods = (prop: PaymentMethodsProps) => { {showDropinBasedComponents && ( )} - - - + ); }; diff --git a/example/src/components/Settings/ApplePaySettingsView.tsx b/example/src/components/Settings/ApplePaySettingsView.tsx index 8690b3f7f..85e66ea6f 100644 --- a/example/src/components/Settings/ApplePaySettingsView.tsx +++ b/example/src/components/Settings/ApplePaySettingsView.tsx @@ -1,10 +1,11 @@ import { useCallback, useState } from 'react'; -import { Button, ScrollView, View } from 'react-native'; +import { Button, View } from 'react-native'; import { useAppContext } from '../../hooks/useAppContext'; import Styles from '../common/Styles'; import FormToggle from '../common/FormToggle'; import FormTextInput from '../common/FormTextInput'; -import FormDropdown from '../common/FormDropdown'; +import FormDropdown from './common/FormDropdown'; +import PageScrollView from '../common/PageScrollView'; import { ENVIRONMENT } from '../../Configuration'; import type { ApplePaySettings } from '../../settings/types'; import type { NativeStackScreenProps } from '@react-navigation/native-stack'; @@ -54,7 +55,7 @@ const ApplePaySettingsView = ({ navigation }: Props) => { ]); return ( - + {