Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[_]: feat/renewal label for subscriptions with coupon code #1303

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"selectedPlan": "Ausgewählter Plan",
"numberOfUsers": "Anzahl der Benutzer: {{seats}}",
"renewalPeriod": {
"renewsAt": "* Verlängert sich am",
"month": "monatlich",
"year": "jährlich",
"lifetime": "lebenslang"
Expand Down
1 change: 1 addition & 0 deletions src/app/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
"paymentTitle": "Select a payment method",
"productCard": {
"renewalPeriod": {
"renewsAt": "* Renews at",
"month": "month",
"year": "year",
"lifetime": "lifetime"
Expand Down
1 change: 1 addition & 0 deletions src/app/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"selectedPlan": "Plan seleccionado",
"numberOfUsers": "Número de usuarios: {{seats}}",
"renewalPeriod": {
"renewsAt": "* Se renueva en",
"month": "mensual",
"year": "anual",
"lifetime": "lifetime"
Expand Down
1 change: 1 addition & 0 deletions src/app/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"selectedPlan": "Plan sélectionné",
"numberOfUsers": "Nombre d'utilisateurs : {{seats}}",
"renewalPeriod": {
"renewsAt": "* Se renouvelle le",
"month": "mensuel",
"year": "annuel",
"lifetime": "à vie"
Expand Down
1 change: 1 addition & 0 deletions src/app/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"selectedPlan": "Piano selezionato",
"numberOfUsers": "Numero di utenti: {{seats}}",
"renewalPeriod": {
"renewsAt": "* Si rinnova il",
"month": "mensile",
"year": "annuale",
"lifetime": "a vita"
Expand Down
1 change: 1 addition & 0 deletions src/app/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"selectedPlan": "Выбранный план",
"numberOfUsers": "Количество пользователей: {{seats}}",
"renewalPeriod": {
"renewsAt": "* Продлевается",
"month": "ежемесячный",
"year": "ежегодный",
"lifetime": "пожизненный"
Expand Down
1 change: 1 addition & 0 deletions src/app/i18n/locales/tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"selectedPlan": "選擇的計劃",
"numberOfUsers": "用戶數:{{seats}}",
"renewalPeriod": {
"renewsAt": "* 續訂日期為",
"month": "每月",
"year": "每年",
"lifetime": "終身"
Expand Down
1 change: 1 addition & 0 deletions src/app/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"selectedPlan": "选择的计划",
"numberOfUsers": "用户数量:{{seats}}",
"renewalPeriod": {
"renewsAt": "* 续订日期为",
"month": "每月",
"year": "每年",
"lifetime": "终身"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Check, SealPercent, X } from '@phosphor-icons/react';

import { bytesToString } from '../../../drive/services/size.service';
import { useTranslationContext } from '../../../i18n/provider/TranslationProvider';
import { UpsellManagerProps } from '../../../payment/views/IntegratedCheckoutView/CheckoutViewWrapper';
import { UpsellManagerProps } from '../../views/IntegratedCheckoutView/CheckoutViewWrapper';
import TextInput from '../../../share/components/ShareItemDialog/components/TextInput';
import Button from '../../../shared/components/Button/Button';
import { useThemeContext } from '../../../theme/ThemeProvider';
Expand All @@ -15,7 +15,7 @@ import { CouponCodeData, Currency, RequestedPlanData } from '../../types';
import { SelectSeatsComponent } from './SelectSeatsComponent';
import { getProductAmount } from 'app/payment/utils/getProductAmount';

interface ProductFeaturesComponentProps {
interface CheckoutProductCardProps {
selectedPlan: RequestedPlanData;
seatsForBusinessSubscription: number;
upsellManager: UpsellManagerProps;
Expand Down Expand Up @@ -58,7 +58,7 @@ const getTextContent = (
};
};

export const ProductFeaturesComponent = ({
export const CheckoutProductCard = ({
selectedPlan,
couponCodeData,
couponError,
Expand All @@ -67,12 +67,14 @@ export const ProductFeaturesComponent = ({
onSeatsChange,
onRemoveAppliedCouponCode,
onCouponInputChange,
}: ProductFeaturesComponentProps) => {
}: CheckoutProductCardProps) => {
const { translate, translateList } = useTranslationContext();
const { checkoutTheme } = useThemeContext();
const [couponName, setCouponName] = useState<string>('');
const [openCouponCodeDropdown, setOpenCouponCodeDropdown] = useState<boolean>(false);
const bytes = bytesToString(selectedPlan.bytes);
const currencySymbol = Currency[selectedPlan.currency];
const normalPriceAmount = selectedPlan.decimalAmount;

const { isUpsellSwitchActivated, showUpsellSwitch, onUpsellSwitchButtonClicked } = upsellManager;
const isBusiness = selectedPlan.type === UserType.Business;
Expand All @@ -84,8 +86,11 @@ export const ProductFeaturesComponent = ({
translate,
translateList,
);
const renewalPeriodLabel = `${translate('checkout.productCard.renewalPeriod.renewsAt')}
${currencySymbol}${normalPriceAmount}/${translate(
`checkout.productCard.renewalPeriod.${selectedPlan.interval}`,
)}`;

const normalPriceAmount = selectedPlan.decimalAmount;
const planAmount = getProductAmount(selectedPlan.decimalAmount, 1, couponCodeData);
const totalAmount = getProductAmount(selectedPlan.decimalAmount, seatsForBusinessSubscription, couponCodeData);
const upsellPlanAmount =
Expand Down Expand Up @@ -134,7 +139,7 @@ export const ProductFeaturesComponent = ({
{textContent.perUserLabel}
</p>
<p className="font-semibold">
{Currency[selectedPlan.currency]}
{currencySymbol}
{planAmount}
</p>
</div>
Expand All @@ -149,7 +154,7 @@ export const ProductFeaturesComponent = ({
</p>
</div>
<p className="text-gray-50 line-through">
{Currency[selectedPlan.currency]}
{currencySymbol}
{normalPriceAmount}
</p>
</div>
Expand All @@ -170,7 +175,7 @@ export const ProductFeaturesComponent = ({
<div className="flex flex-row items-center justify-between text-2xl font-semibold text-gray-100">
<p>{textContent.totalLabel}</p>
<p>
{Currency[selectedPlan.currency]}
{currencySymbol}
{totalAmount}
</p>
</div>
Expand All @@ -197,15 +202,15 @@ export const ProductFeaturesComponent = ({
<div className="flex h-full rounded-lg bg-green/10 px-3 py-1">
<p className="text-sm text-green">
{translate('checkout.productCard.amountSaved')}
{Currency[selectedPlan.currency]}
{currencySymbol}
{upsellManager.amountSaved}
</p>
</div>
<p className="font-medium text-gray-80">{translate('checkout.productCard.withAnnualBilling')}</p>
</div>
<div className="flex flex-row items-center">
<p className="text-sm text-gray-80">
{Currency[selectedPlan.currency]}
{currencySymbol}
{upsellPlanAmount}/{translate('views.account.tabs.account.view.subscription.yearly')}
</p>
</div>
Expand Down Expand Up @@ -292,6 +297,7 @@ export const ProductFeaturesComponent = ({
)}
</div>
</div>
{couponCodeData && selectedPlan.interval !== 'lifetime' && <p className="text-gray-60">{renewalPeriodLabel}</p>}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Button from 'app/shared/components/Button/Button';
import { useTranslationContext } from 'app/i18n/provider/TranslationProvider';
import { InputsComponent } from './InputsComponent';

interface CreateAccountComponentProps {
interface CheckoutUserAuthProps {
userData: {
name: string;
avatar: Blob | null;
Expand All @@ -21,15 +21,15 @@ interface CreateAccountComponentProps {
onLogOut: () => void;
}

export const UserAuthComponent = ({
export const CheckoutUserAuth = ({
register,
errors,
authMethod,
authError,
onAuthMethodToggled,
userData,
onLogOut,
}: CreateAccountComponentProps) => {
}: CheckoutUserAuthProps) => {
const { translate } = useTranslationContext();

const isUserSignedIn = authMethod === 'userIsSignedIn';
Expand All @@ -45,12 +45,21 @@ export const UserAuthComponent = ({
signUp: translate('auth.signup.login'),
};

const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') {
e.preventDefault();
}
};

return (
<div className="flex flex-col space-y-8">
<p className="text-2xl font-semibold text-gray-100">
1. {translate(`checkout.authComponent.title.${authMethod}`)}
</p>
<div className="flex flex-col space-y-4 rounded-2xl border border-gray-10 bg-surface p-5">
<div
onKeyDown={handleKeyDown}
className="flex flex-col space-y-4 rounded-2xl border border-gray-10 bg-surface p-5"
>
{isUserSignedIn ? (
<div className="flex w-full items-center justify-center">
<div className="flex flex-col items-center gap-2.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { IFormValues } from 'app/core/types';
import { useState } from 'react';
import { FieldErrors, UseFormRegister } from 'react-hook-form';

interface OptionalB2BDropdownComponentProps {
interface OptionalB2BDropdownProps {
errors: FieldErrors<IFormValues>;
translate: (key: string, props?: Record<string, unknown>) => string;
register: UseFormRegister<IFormValues>;
}

export const OptionalB2BDropdownComponent = ({ errors, translate, register }: OptionalB2BDropdownComponentProps) => {
export const OptionalB2BDropdown = ({ errors, translate, register }: OptionalB2BDropdownProps) => {
const [optionalAddressBillingDetailsDialogClicked, setOptionalAddressBillingDetailsDialogClicked] =
useState<boolean>();

Expand Down
12 changes: 6 additions & 6 deletions src/app/payment/views/IntegratedCheckoutView/CheckoutView.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { ProductFeaturesComponent } from '../../components/checkout/ProductCardComponent';
import { CheckoutProductCard } from '../../components/checkout/CheckoutProductCard';
import { HeaderComponent } from '../../components/checkout/Header';
import LoadingPulse from 'app/shared/components/LoadingPulse/LoadingPulse';
import { AddressElement, PaymentElement, useElements, useStripe } from '@stripe/react-stripe-js';
import Button from 'app/shared/components/Button/Button';
import { useForm } from 'react-hook-form';
import { IFormValues } from 'app/core/types';
import { AuthMethodTypes } from '../../types';
import { UserAuthComponent } from '../../components/checkout/UserAuthComponent';
import { CheckoutUserAuth } from '../../components/checkout/CheckoutUserAuth';
import { useTranslationContext } from 'app/i18n/provider/TranslationProvider';
import { StripePaymentElementOptions } from '@stripe/stripe-js';
import { CheckoutViewManager, UpsellManagerProps, UserInfoProps } from './CheckoutViewWrapper';
import { State } from 'app/payment/store/types';
import { LegacyRef } from 'react';
import { OptionalB2BDropdownComponent } from 'app/payment/components/checkout/OptionalB2BDropdownComponent';
import { OptionalB2BDropdown } from 'app/payment/components/checkout/OptionalB2BDropdown';
import { UserType } from '@internxt/sdk/dist/drive/payments/types';

export const PAYMENT_ELEMENT_OPTIONS: StripePaymentElementOptions = {
Expand Down Expand Up @@ -92,7 +92,7 @@ const CheckoutView = ({
{currentSelectedPlan ? (
<div className="flex flex-col items-center justify-center gap-10 lg:flex-row lg:items-start lg:justify-between">
<div className="flex w-full max-w-xl flex-col space-y-14" ref={userAuthComponentRef}>
<UserAuthComponent
<CheckoutUserAuth
errors={errors}
authError={error?.auth}
register={register}
Expand All @@ -119,7 +119,7 @@ const CheckoutView = ({
/>
</div>
{currentSelectedPlan.type === UserType.Business ? (
<OptionalB2BDropdownComponent errors={errors} register={register} translate={translate} />
<OptionalB2BDropdown errors={errors} register={register} translate={translate} />
) : undefined}
</div>
<p className="text-2xl font-semibold text-gray-100">3. {translate('checkout.paymentTitle')}</p>
Expand All @@ -135,7 +135,7 @@ const CheckoutView = ({
</div>
</div>
<div className="top-5 flex w-full max-w-xl flex-col gap-5 pb-10 lg:sticky lg:max-w-lg">
<ProductFeaturesComponent
<CheckoutProductCard
selectedPlan={currentSelectedPlan}
couponCodeData={couponCodeData}
couponError={error?.coupon}
Expand Down
Loading