From 57c99c28d73ac973b4213701df9b196e6ff1f60a Mon Sep 17 00:00:00 2001 From: Junior Campos Date: Thu, 23 Jun 2022 11:03:30 -0400 Subject: [PATCH] feat: add message for trimestral/semestral/year accounts --- .../PlanCalculator/SubscriptionType/index.js | 22 ++++++++ .../SubscriptionType/index.test.js | 19 +++++++ src/components/Plans/PlanCalculator/index.js | 25 ++++++--- .../Plans/PlanCalculator/index.test.js | 52 +++++++++++++++++++ src/i18n/en.js | 2 + src/i18n/es.js | 2 + 6 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 src/components/Plans/PlanCalculator/SubscriptionType/index.js create mode 100644 src/components/Plans/PlanCalculator/SubscriptionType/index.test.js diff --git a/src/components/Plans/PlanCalculator/SubscriptionType/index.js b/src/components/Plans/PlanCalculator/SubscriptionType/index.js new file mode 100644 index 000000000..8e7927f47 --- /dev/null +++ b/src/components/Plans/PlanCalculator/SubscriptionType/index.js @@ -0,0 +1,22 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import { FormattedMessageMarkdown } from '../../../../i18n/FormattedMessageMarkdown'; + +export const SubscriptionType = ({ period, discountPercentage }) => { + return ( +
+
+ +
+ +
+ ); +}; + +SubscriptionType.propTypes = { + period: PropTypes.oneOf([1, 3, 6, 12]), + discountPercentage: PropTypes.number, +}; diff --git a/src/components/Plans/PlanCalculator/SubscriptionType/index.test.js b/src/components/Plans/PlanCalculator/SubscriptionType/index.test.js new file mode 100644 index 000000000..3990ab47d --- /dev/null +++ b/src/components/Plans/PlanCalculator/SubscriptionType/index.test.js @@ -0,0 +1,19 @@ +import '@testing-library/jest-dom/extend-expect'; +import { render, screen } from '@testing-library/react'; +import { SubscriptionType } from '.'; +import IntlProvider from '../../../../i18n/DopplerIntlProvider.double-with-ids-as-values'; + +describe('SuscriptionType', () => { + it(`should render SuscriptionType`, async () => { + // Act + render( + + + , + ); + + // Assert + screen.getByText('plan_calculator.current_subscription'); + screen.getByText('plan_calculator.subscription_discount'); + }); +}); diff --git a/src/components/Plans/PlanCalculator/index.js b/src/components/Plans/PlanCalculator/index.js index 1e69d5bfb..85a356ad1 100644 --- a/src/components/Plans/PlanCalculator/index.js +++ b/src/components/Plans/PlanCalculator/index.js @@ -31,6 +31,7 @@ import { PROMOCODE_ACTIONS, } from './reducers/promocodeReducer'; import { Slider } from './Slider'; +import { SubscriptionType } from './SubscriptionType'; import { UnexpectedError } from './UnexpectedError'; export const PlanCalculator = InjectAppServices( @@ -173,6 +174,8 @@ export const PlanCalculator = InjectAppServices( const promocode = query.get('promo-code') ?? query.get('PromoCode') ?? ''; const hasPromocode = !!promocode; + const isMonthlySubscription = sessionPlan.plan.planSubscription === 1; + return ( <>
@@ -204,14 +207,24 @@ export const PlanCalculator = InjectAppServices( currentPlanList={plansByType} planTypes={planTypes} /> - {discounts.length > 0 && ( + {isMonthlySubscription ? ( + discounts.length > 0 && ( + <> +
+ + + ) + ) : ( <>
- )} diff --git a/src/components/Plans/PlanCalculator/index.test.js b/src/components/Plans/PlanCalculator/index.test.js index 5db2af599..f84886142 100644 --- a/src/components/Plans/PlanCalculator/index.test.js +++ b/src/components/Plans/PlanCalculator/index.test.js @@ -378,6 +378,58 @@ describe('PlanCalculator component', () => { expect(byEmailsTab).not.toBeInTheDocument(); }); + it('should be visible current description type', async () => { + // Arrange + const planTypes = [PLAN_TYPE.byContact]; + const forcedServices = { + appSessionRef: { + current: { + userData: { + user: { + plan: { + idPlan: 3, + planType: PLAN_TYPE.byContact, + planSubscription: 3, + }, + }, + }, + }, + }, + planService: { + getPlanTypes: async () => planTypes, + getPlansByType: async () => plansByContacts, + }, + experimentalFeatures: { + getFeature: () => false, + }, + ipinfoClient: { + getCountryCode: () => 'CL', + }, + }; + + // Act + render( + + + + + + + + + , + ); + + // Assert + const loader = screen.getByTestId('wrapper-loading'); + await waitForElementToBeRemoved(loader); + + screen.getByText('plan_calculator.current_subscription'); + expect(screen.queryByText('plan_calculator.discount_title')).not.toBeInTheDocument(); + }); + describe('Redirections when the type of plan is by email', () => { [ { diff --git a/src/i18n/en.js b/src/i18n/en.js index 556238eb5..fa4b6bcad 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -745,6 +745,7 @@ You'll find an Email with steps to follow.`, button_purchase: 'Continue', button_purchase_tooltip: 'This is your current Plan! Change it to continue.', cost_per_email: 'Cost per email', + current_subscription: 'You currently have a subscription for {period} months', discount_clarification: `The renewal is automatic and you can cancel it whenever you want. Plan price doesn’t include taxes.`, discount_clarification_prepaid: 'Plan price doesn’t include taxes.', discount_half_yearly: '6 months', @@ -774,6 +775,7 @@ You'll find an Email with steps to follow.`, We couldn't apply the discount. Promo code isn’t valid.`, + subscription_discount: 'You save {discountPercentage}% on the value of the Plan', suggestion_for_monthly_deliveries: '¿Do you have more than 10.000.000 schedules? Contact us.', suggestion_for_prepaid: ' ', suggestion_for_subscribers: '¿Do you have more than de 100.000 contacts? We recommend our SHIPPING PLANS, contact us.', diff --git a/src/i18n/es.js b/src/i18n/es.js index 31da8c9cd..914662a00 100644 --- a/src/i18n/es.js +++ b/src/i18n/es.js @@ -745,6 +745,7 @@ Encontrarás un Email con los pasos a seguir.`, button_purchase: 'Continuar', button_purchase_tooltip: '¡Este es el Plan que tienes actualmente! Modifícalo para continuar.', cost_per_email: 'Costo por email', + current_subscription: 'Actualmente tienes una **suscripción por {period} meses**', discount_clarification: 'La renovación es automática y puedes cancelarla cuando quieras. El precio del Plan no incluye impuestos.', discount_clarification_prepaid: 'El precio del Plan no incluye impuestos.', discount_half_yearly: '6 meses', @@ -774,6 +775,7 @@ Encontrarás un Email con los pasos a seguir.`, No pudimos aplicar el descuento. El código es inválido.`, + subscription_discount: 'Ahorras {discountPercentage}% sobre el valor del Plan', suggestion_for_monthly_deliveries: '¿Realizas más de 10.000.000 de envíos? Contáctanos y te asesoraremos.', suggestion_for_prepaid: ' ', suggestion_for_subscribers: '¿Tienes más de 100.000 contactos? Te recomendamos nuestros PLANES POR ENVÍOS, contáctanos y te asesoraremos.',