32 lines
1.7 KiB
TypeScript
32 lines
1.7 KiB
TypeScript
// Metro module 6261 (f6262).
|
|
import { useEffect } from "react";
|
|
import SubscriptionStore from "../../../../stores/billing/SubscriptionStore";
|
|
import PromotionsStore from "../../promotions/PromotionsStore";
|
|
import { PremiumTypes } from "../../PremiumConstants";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { usePremiumTrialOffer } from "../../hooks/usePremiumTrialOffer.android";
|
|
import { usePremiumDiscountOffer } from "../../hooks/usePremiumDiscountOffer.native";
|
|
import { useIsPaymentsBlocked } from "../../../billing/experiments/BlockedPaymentsCountryExperiment";
|
|
import { useForceUpdate } from "../../../../_bundle/Module6235";
|
|
export function useIsEligibleForBogoOffer() {
|
|
let forceUpdate, c15638_1;
|
|
const stateFromStores = useStateFromStores([PromotionsStore], () => PromotionsStore.getActiveBogoRewardPromotion());
|
|
const stateFromStores2 = useStateFromStores([SubscriptionStore], () => SubscriptionStore.getPremiumTypeSubscription());
|
|
const premiumTrialOffer = usePremiumTrialOffer();
|
|
const premiumDiscountOffer = usePremiumDiscountOffer();
|
|
const isPaymentsBlocked = useIsPaymentsBlocked();
|
|
forceUpdate = useForceUpdate();
|
|
const r16 = stateFromStores != null ? stateFromStores.endDate.valueOf() : null;
|
|
c15638_1 = r16;
|
|
useEffect(() => {
|
|
if (c15638_1 != null) {
|
|
const r8 = c15638_1 - Date.now();
|
|
if (!(r8 <= 0)) {
|
|
let c25767_0 = setTimeout(forceUpdate, r8);
|
|
return () => clearTimeout(c25767_0);
|
|
}
|
|
}
|
|
}, [r16, forceUpdate]);
|
|
return stateFromStores != null && !isPaymentsBlocked && (premiumTrialOffer == null && premiumDiscountOffer == null && (stateFromStores2 == null ? void 0 : stateFromStores2.hasPremiumAtLeast(PremiumTypes.TIER_2)) !== true);
|
|
}
|