0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Passed correct offerId to Offer Modals (#18893)

This commit is contained in:
Princi Vershwal 2023-11-07 14:52:46 +05:30 committed by GitHub
parent 9c6dc044b3
commit 71d84c6a05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,7 +18,7 @@ const createRedemptionFilterUrl = (id: string): string => {
return `${baseHref}?filter=${encodeURIComponent('offer_redemptions:' + id)}`; return `${baseHref}?filter=${encodeURIComponent('offer_redemptions:' + id)}`;
}; };
const OfferCard: React.FC<{amount: number, cadence: string, currency: string, duration: string, name: string, offerTier: Tier | undefined, redemptionCount: number, type: OfferType, onClick: ()=>void}> = ({amount, cadence, currency, duration, name, offerTier, redemptionCount, type, onClick}) => { const OfferCard: React.FC<{amount: number, cadence: string, currency: string, duration: string, name: string, offerId: string, offerTier: Tier | undefined, redemptionCount: number, type: OfferType, onClick: ()=>void}> = ({amount, cadence, currency, duration, name, offerId, offerTier, redemptionCount, type, onClick}) => {
let discountColor = ''; let discountColor = '';
let discountOffer = ''; let discountOffer = '';
const originalPrice = cadence === 'month' ? offerTier?.monthly_price ?? 0 : offerTier?.yearly_price ?? 0; const originalPrice = cadence === 'month' ? offerTier?.monthly_price ?? 0 : offerTier?.yearly_price ?? 0;
@ -58,8 +58,7 @@ const OfferCard: React.FC<{amount: number, cadence: string, currency: string, du
</div> </div>
<div className='flex flex-col items-center text-xs'> <div className='flex flex-col items-center text-xs'>
<span className='font-medium'>{tierName}</span> <span className='font-medium'>{tierName}</span>
{/* TODO: pass in actual offer ID */} <a className='text-grey-700 hover:underline' href={createRedemptionFilterUrl(offerId)}>{redemptionCount} redemptions</a>
<a className='text-grey-700 hover:underline' href={createRedemptionFilterUrl('fda10d177a4f5be094fb4a84')}>{redemptionCount} redemptions</a>
</div> </div>
</div>; </div>;
}; };
@ -125,7 +124,6 @@ const OffersModal = () => {
{offers.filter(offer => offer.status === selectedTab).map((offer) => { {offers.filter(offer => offer.status === selectedTab).map((offer) => {
const offerTier = paidActiveTiers.find(tier => tier.id === offer?.tier.id); const offerTier = paidActiveTiers.find(tier => tier.id === offer?.tier.id);
{/* TODO replace 123 with actual offer ID */}
return ( return (
<OfferCard <OfferCard
key={offer?.id} key={offer?.id}
@ -134,10 +132,11 @@ const OffersModal = () => {
currency={offer?.currency || 'USD'} currency={offer?.currency || 'USD'}
duration={offer?.duration} duration={offer?.duration}
name={offer?.name} name={offer?.name}
offerId={offer?.id}
offerTier={offerTier} offerTier={offerTier}
redemptionCount={offer?.redemption_count} redemptionCount={offer?.redemption_count}
type={offer?.type as OfferType} type={offer?.type as OfferType}
onClick={() => handleOfferEdit('123')} onClick={() => handleOfferEdit(offer?.id)}
/> />
); );
})} })}