Skip to content

Commit

Permalink
fix: move useoffers call to payments
Browse files Browse the repository at this point in the history
  • Loading branch information
naumovski-filip committed Jul 17, 2023
1 parent d79f779 commit 1cfcf45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/Payment/Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type { Offer } from '#types/checkout';
import OfferSwitch from '#components/OfferSwitch/OfferSwitch';
import Alert from '#components/Alert/Alert';
import { useSubscriptionChange } from '#src/hooks/useSubscriptionChange';
import useOffers from '#src/hooks/useOffers';

const VISIBLE_TRANSACTIONS = 4;

Expand All @@ -42,7 +43,6 @@ type Props = {
canUpdatePaymentMethod: boolean;
canRenewSubscription?: boolean;
canShowReceipts?: boolean;
offers?: Offer[];
};

const Payment = ({
Expand All @@ -63,8 +63,9 @@ const Payment = ({
canUpdatePaymentMethod,
onUpgradeSubscriptionClick,
offerSwitchesAvailable,
offers = [],
}: Props): JSX.Element => {
const { offers } = useOffers();

const { t, i18n } = useTranslation(['user', 'account']);
const hiddenTransactionsCount = transactions ? transactions?.length - VISIBLE_TRANSACTIONS : 0;
const hasMoreTransactions = hiddenTransactionsCount > 0;
Expand Down
3 changes: 0 additions & 3 deletions src/pages/User/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { clear as clearFavorites } from '#src/stores/FavoritesController';
import { getSubscriptionSwitches } from '#src/stores/CheckoutController';
import { useCheckoutStore } from '#src/stores/CheckoutStore';
import { addQueryParam } from '#src/utils/location';
import useOffers from '#src/hooks/useOffers';

const User = (): JSX.Element => {
const { accessModel, favoritesList } = useConfigStore(
Expand Down Expand Up @@ -57,7 +56,6 @@ const User = (): JSX.Element => {
canShowReceipts,
} = useAccountStore();
const { offerSwitches } = useCheckoutStore();
const { offers } = useOffers();
const location = useLocation();

const onCardClick = (playlistItem: PlaylistItem) => navigate(mediaURL({ media: playlistItem }));
Expand Down Expand Up @@ -199,7 +197,6 @@ const User = (): JSX.Element => {
offerSwitchesAvailable={!!offerSwitches.length}
canShowReceipts={canShowReceipts}
onShowReceiptClick={handleShowReceiptClick}
offers={offers}
/>
) : (
<Navigate to="my-account" />
Expand Down

0 comments on commit 1cfcf45

Please sign in to comment.