0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Fixed archived offers incorrectly showing offer page

refs https://github.com/TryGhost/Team/issues/1269

- accessing an archived offer url was incorrectly showing the offer page, as we were not checking for the status of offer
- the archived offer redemption was working correctly as it was blocked on API, this change updates the ui to hide offer screen for archived as well
This commit is contained in:
Rishabh 2022-01-06 19:25:14 +05:30
parent e47a24f362
commit b659996082
2 changed files with 6 additions and 2 deletions

View file

@ -10,7 +10,7 @@ import * as Fixtures from './utils/fixtures';
import ActionHandler from './actions';
import './App.css';
import NotificationParser from './utils/notifications';
import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductFromId, getQueryPrice, getSiteDomain, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers';
import {createPopupNotification, getCurrencySymbol, getFirstpromoterId, getPriceIdFromPageQuery, getProductFromId, getQueryPrice, getSiteDomain, isActiveOffer, isComplimentaryMember, isInviteOnlySite, isPaidMember, isSentryEventAllowed, removePortalLinkFromUrl} from './utils/helpers';
const handleDataAttributes = require('./data-attributes');
const React = require('react');
@ -576,7 +576,7 @@ export default class App extends React.Component {
try {
const offerData = await this.GhostApi.site.offer({offerId});
const offer = offerData?.offers[0];
if (offer) {
if (isActiveOffer({offer})) {
if (!portalButton) {
const product = getProductFromId({site, productId: offer.tier.id});
const price = offer.cadence === 'month' ? product.monthlyPrice : product.yearlyPrice;

View file

@ -528,3 +528,7 @@ export const getUpdatedOfferPrice = ({offer, price, useFormatted = false}) => {
}
return updatedAmount;
};
export const isActiveOffer = ({offer}) => {
return offer?.status === 'active';
};