From 83de9aa284b5512774cadefb9a8400f25de421ca Mon Sep 17 00:00:00 2001 From: Christiaan Scheermeijer Date: Tue, 27 Jul 2021 10:05:13 +0200 Subject: [PATCH] feat(user): add no subscription text --- src/components/Account/Account.tsx | 23 +++++------ .../__snapshots__/Account.test.tsx.snap | 16 ++++++-- src/components/Payment/Payment.tsx | 41 ++++++++++++------- .../__snapshots__/Payment.test.tsx.snap | 29 ++++++------- src/i18n/locales/en_US/user.json | 4 +- src/i18n/locales/nl_NL/user.json | 4 +- types/subscription.d.ts | 2 +- 7 files changed, 69 insertions(+), 50 deletions(-) diff --git a/src/components/Account/Account.tsx b/src/components/Account/Account.tsx index 71b508e66..786e2b634 100644 --- a/src/components/Account/Account.tsx +++ b/src/components/Account/Account.tsx @@ -88,19 +88,16 @@ const Account = ({

{t('account.email')}

- {editing === 'account' ? ( - - ) : ( -

{customer?.email}

- )} + {editing === 'account' && ( renders and matches snapshot 1`] = `
-

- email@domain.com -

+
+ +

+ email@domain.com +

+
diff --git a/src/components/Payment/Payment.tsx b/src/components/Payment/Payment.tsx index d1b6cb6e3..d13a9f465 100644 --- a/src/components/Payment/Payment.tsx +++ b/src/components/Payment/Payment.tsx @@ -8,6 +8,7 @@ import type { Customer } from '../../../types/account'; import LoadingOverlay from '../LoadingOverlay/LoadingOverlay'; import styles from './Payment.module.scss'; +import Button from '../Button/Button'; type Props = { activeSubscription?: Subscription; @@ -28,55 +29,66 @@ const Payment = ({ panelClassName, panelHeaderClassName, }: Props): JSX.Element => { - const { t } = useTranslation('user'); + const { t } = useTranslation(['user', 'account']); return ( <>
-

{t('payment.subscription_details')}

+

{t('user:payment.subscription_details')}

{activeSubscription ? (

- {t('payment.monthly_subscription')}
- {t('payment.next_billing_date_on')} {formatDate(activeSubscription.expiresAt)} + {t('user:payment.monthly_subscription')}
+ {t('user:payment.next_billing_date_on')} {formatDate(activeSubscription.expiresAt)}

{formatPrice(activeSubscription.totalPrice, activeSubscription.nextPaymentCurrency, customer.country)} - {'/'} - {t(`payment.month`)} {/** @todo: create dynamic translation keys by period */} + /{t(`account:periods.${activeSubscription.period}`)}

- ) : null} + ) : ( + +

{t('user:payment.no_subscription')}

+
-

{t('payment.payment_method')}

+

{t('user:payment.payment_method')}

{activePaymentDetail ? (
- - + +
) : null}
-

{t('payment.transactions')}

+

{t('user:payment.transactions')}

- {transactions?.map(transaction => ( + {transactions?.map((transaction) => (

{transaction.offerTitle}
- {t('payment.price_payed_with', { price: formatPrice(parseInt(transaction.transactionPriceInclTax), transaction.transactionCurrency, transaction.customerCountry), method: transaction.paymentMethod })} + {t('user:payment.price_payed_with', { + price: formatPrice(parseInt(transaction.transactionPriceInclTax), transaction.transactionCurrency, transaction.customerCountry), + method: transaction.paymentMethod, + })}

{transaction.transactionId} @@ -90,5 +102,4 @@ const Payment = ({ ); }; - export default Payment; diff --git a/src/components/Payment/__snapshots__/Payment.test.tsx.snap b/src/components/Payment/__snapshots__/Payment.test.tsx.snap index dd5146a68..155ba2572 100644 --- a/src/components/Payment/__snapshots__/Payment.test.tsx.snap +++ b/src/components/Payment/__snapshots__/Payment.test.tsx.snap @@ -5,7 +5,7 @@ exports[` renders and matches snapshot 1`] = `

- payment.subscription_details + user:payment.subscription_details

renders and matches snapshot 1`] = ` >

- payment.monthly_subscription + user:payment.monthly_subscription
- payment.next_billing_date_on + user:payment.next_billing_date_on 3/16/2021

@@ -27,16 +27,17 @@ exports[` renders and matches snapshot 1`] = ` € 20,00 - / - payment.month - + + / + account:periods.year +

- payment.payment_method + user:payment.payment_method

@@ -47,7 +48,7 @@ exports[` renders and matches snapshot 1`] = ` class="label" for="text-field_1235" > - payment.card_number + user:payment.card_number

•••• •••• •••• 0002 @@ -63,7 +64,7 @@ exports[` renders and matches snapshot 1`] = ` class="label" for="text-field_1235" > - payment.expiry_date + user:payment.expiry_date

03/2030 @@ -76,7 +77,7 @@ exports[` renders and matches snapshot 1`] = ` class="label" for="text-field_1235" > - payment.cvc_cvv + user:payment.cvc_cvv

****** @@ -88,7 +89,7 @@ exports[` renders and matches snapshot 1`] = `

- payment.transactions + user:payment.transactions

renders and matches snapshot 1`] = `
- payment.price_payed_with + user:payment.price_payed_with

T712014024 @@ -117,7 +118,7 @@ exports[` renders and matches snapshot 1`] = `
- payment.price_payed_with + user:payment.price_payed_with

T177974068 @@ -134,7 +135,7 @@ exports[` renders and matches snapshot 1`] = `
- payment.price_payed_with + user:payment.price_payed_with

T996601696 diff --git a/src/i18n/locales/en_US/user.json b/src/i18n/locales/en_US/user.json index 777bbfa71..399362ee7 100644 --- a/src/i18n/locales/en_US/user.json +++ b/src/i18n/locales/en_US/user.json @@ -31,12 +31,12 @@ }, "payment": { "card_number": "Card number", + "complete_subscription": "Complete subscription", "cvc_cvv": "CVC / CVV", - "edit_subscription": "Edit subscription", "expiry_date": "Expiry date", - "month": "month", "monthly_subscription": "Monthly subscription", "next_billing_date_on": "Next billing date is on", + "no_subscription": "You have no subscription. Complete your subscription to start watching all movies and series.", "payment_method": "Payment method", "price_payed_with": "{{price}} payed with {{method}}", "subscription_details": "Subscription details", diff --git a/src/i18n/locales/nl_NL/user.json b/src/i18n/locales/nl_NL/user.json index 69fb1018f..8e7a5c3b4 100644 --- a/src/i18n/locales/nl_NL/user.json +++ b/src/i18n/locales/nl_NL/user.json @@ -31,12 +31,12 @@ }, "payment": { "card_number": "", + "complete_subscription": "", "cvc_cvv": "", - "edit_subscription": "", "expiry_date": "", - "month": "", "monthly_subscription": "", "next_billing_date_on": "", + "no_subscription": "", "payment_method": "", "price_payed_with": "", "subscription_details": "", diff --git a/types/subscription.d.ts b/types/subscription.d.ts index 8a14188c5..9593cbee9 100644 --- a/types/subscription.d.ts +++ b/types/subscription.d.ts @@ -9,7 +9,7 @@ export type Subscription = { paymentGateway: string; paymentMethod: string; offerTitle: string; - period: string; + period: 'day' | 'week' | 'month' | 'year'; totalPrice: number; };