MCPcopy Create free account
hub / github.com/dailydotdev/apps / usePlusSale

Function usePlusSale

packages/shared/src/hooks/usePlusSale.ts:14–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12};
13
14export const usePlusSale = (): UsePlusSale => {
15 const { isAuthReady } = useAuthContext();
16 const { isPlus } = usePlusSubscription();
17 const { value, isLoading } = useConditionalFeature({
18 feature: featurePlusSale,
19 shouldEvaluate: isAuthReady && !isPlus,
20 });
21 const { discountId, label, endDate } = value;
22
23 const hasNotEnded = !!endDate && Date.now() < new Date(endDate).getTime();
24 const isActive =
25 !isLoading &&
26 !!discountId &&
27 // A payload configured without copy would advertise an empty badge.
28 !!label &&
29 !isPlus &&
30 hasNotEnded &&
31 // StoreKit purchases go through Apple, which can't honour a Paddle discount.
32 !iOSSupportsPlusPurchase();
33
34 return {
35 ...value,
36 isActive,
37 discountId: isActive ? discountId : undefined,
38 };
39};

Callers 10

UpgradeToPlusFunction · 0.90
PlusSaleLabelFunction · 0.90
PlusSummerSaleBannerFunction · 0.90
PostUpgradeToPlusFunction · 0.90
ProfilePanelSectionFunction · 0.90
MainSectionFunction · 0.90
BriefPlusUpgradeCTAFunction · 0.90
PlusSalePaymentProviderFunction · 0.90
PlusPaymentPageFunction · 0.90

Calls 4

useAuthContextFunction · 0.90
usePlusSubscriptionFunction · 0.90
useConditionalFeatureFunction · 0.90
iOSSupportsPlusPurchaseFunction · 0.90

Tested by

no test coverage detected