import { useCallback } from 'react' import { useTranslation } from 'react-i18next' import { useNavigate } from 'react-router-dom' import { useSelector } from 'react-redux' import { selectors } from '../../store' import { useAuth } from '../../auth' import { useApi, useApiCall, SubscriptionCheckout } from '../../api' import UserHeader from '../UserHeader' import Title from '../Title' import Loader from '../Loader' import MainButton from '../MainButton' import applePaySafeCheckout from './Apple-Pay.png' import gPaySafeCheckout from './Google-Pay.png' import secure from './Secure.png' import ApplePay from './Apple-Pay.svg' import GooglePay from './G-Pay.svg' import card from './card.svg' import routes from '../../routes' import './styles.css' const isAndroid = () => /Android/i.test(navigator.userAgent) const isApple = () => /Macintosh|iPhone|iPad|iPod/i.test(navigator.userAgent) function PaymentPage(): JSX.Element { const api = useApi() const { token } = useAuth() const { t, i18n } = useTranslation() const locale = i18n.language const navigate = useNavigate() const email = useSelector(selectors.selectEmail) const handleClick = () => navigate(routes.client.wallpaper()) const loadData = useCallback(() => { return api.getSubscriptionItems({ locale, token }) .then(({ item_prices }) => item_prices.find(({ id }) => id === 'aura-membership-2-week-USD')) .then((item) => api.getSubscriptionCheckout({ locale, token, itemPriceId: item?.id || '' })) }, [api, locale, token]) const { data, isPending } = useApiCall(loadData) console.log(data, isPending) return ( <>
{isAndroid() && Guaranteed safe checkout} {isApple() && Guaranteed safe checkout} 100% Secure
{t('choose_payment')} {isPending ? : ( <> {isAndroid() && Google Pay} {isApple() && Apple Pay}
{t('or').toUpperCase()}
Credit / Debit Card {t('card')}

You will be charged only $1 for your 7-day trial. We'll email your a reminder before your trial period ends.

)}
) } export default PaymentPage