Skip to content

Commit

Permalink
fix: improvement on existing piece of code
Browse files Browse the repository at this point in the history
  • Loading branch information
mirovladimitrovski committed Sep 27, 2024
1 parent 1d94467 commit 1451204
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useLocation } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import type { Subscription as SubscriptionType } from '@jwp/ott-common/types/subscription';
import { formatLocalizedDate, formatPrice } from '@jwp/ott-common/src/utils/formatting';
Expand Down Expand Up @@ -56,14 +56,11 @@ type Props = {
const Subscription: React.FC<Props> = ({ subscription }) => {
const { t } = useTranslation('user');

const navigate = useNavigate();
const location = useLocation();

const hasActiveSubscription = subscription?.status === 'active' || subscription?.status === 'active_trial';

const onClick = () => {
navigate(modalURLFromLocation(location, 'choose-offer'));
};
const modalURL = modalURLFromLocation(location, 'choose-offer');

return (
<section className={userStyles.panel}>
Expand All @@ -75,7 +72,7 @@ const Subscription: React.FC<Props> = ({ subscription }) => {
) : (
<>
<p>{t('user:payment.no_subscription_new_payment')}</p>
<Button onClick={onClick} label={t('user:payment.view_plans')} />
<Button to={modalURL} label={t('user:payment.view_plans')} />
</>
)}
</section>
Expand Down

0 comments on commit 1451204

Please sign in to comment.