mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
mobile: fix pricing on github release
This commit is contained in:
@@ -940,19 +940,22 @@ const PricingPlanCard = ({
|
||||
regionalDiscount?.sku ||
|
||||
`notesnook.${plan.id}.${annualBilling ? "yearly" : "monthly"}`
|
||||
];
|
||||
const price = pricingPlans?.getPrice(
|
||||
product as RNIap.Subscription,
|
||||
pricingPlans.hasTrialOffer(plan.id, product?.productId) ? 1 : 0,
|
||||
annualBilling
|
||||
);
|
||||
|
||||
const WebPlan = pricingPlans?.getWebPlan(
|
||||
plan.id,
|
||||
annualBilling ? "yearly" : "monthly"
|
||||
);
|
||||
|
||||
const price = pricingPlans?.getPrice(
|
||||
pricingPlans.isGithubRelease && WebPlan
|
||||
? WebPlan
|
||||
: (product as RNIap.Subscription),
|
||||
pricingPlans.hasTrialOffer(plan.id, product?.productId) ? 1 : 0,
|
||||
annualBilling
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (pricingPlans?.isGithubRelease) return;
|
||||
if (pricingPlans?.isGithubRelease || !annualBilling) return;
|
||||
pricingPlans
|
||||
?.getRegionalDiscount(
|
||||
plan.id,
|
||||
@@ -963,7 +966,13 @@ const PricingPlanCard = ({
|
||||
.then((value) => {
|
||||
setRegionaDiscount(value);
|
||||
});
|
||||
}, []);
|
||||
}, [annualBilling]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!annualBilling) {
|
||||
setRegionaDiscount(undefined);
|
||||
}
|
||||
}, [annualBilling]);
|
||||
|
||||
const isSubscribed =
|
||||
product?.productId &&
|
||||
@@ -994,8 +1003,8 @@ const PricingPlanCard = ({
|
||||
: "monthly"
|
||||
}`
|
||||
: pricingPlans.isGithubRelease
|
||||
? (WebPlan?.period as string)
|
||||
: (product?.productId as string)
|
||||
? (WebPlan?.period as string)
|
||||
: (product?.productId as string)
|
||||
);
|
||||
setStep(Steps.buy);
|
||||
}}
|
||||
@@ -1117,12 +1126,12 @@ const PricingPlanCard = ({
|
||||
{annualBilling
|
||||
? strings.billedAnnually(
|
||||
pricingPlans?.getStandardPrice(
|
||||
(product as RNIap.Subscription) || (WebPlan as Plan)
|
||||
(product || WebPlan) as any
|
||||
) as string
|
||||
)
|
||||
: strings.billedMonthly(
|
||||
pricingPlans?.getStandardPrice(
|
||||
(product as RNIap.Subscription) || (WebPlan as Plan)
|
||||
(product || WebPlan) as any
|
||||
) as string
|
||||
)}
|
||||
</Paragraph>
|
||||
|
||||
@@ -73,6 +73,13 @@ export const BuyPlan = (props: {
|
||||
}}
|
||||
>
|
||||
<Paragraph>{strings.finishPurchaseInBrowser()}</Paragraph>
|
||||
<Button
|
||||
title={strings.next()}
|
||||
type="accent"
|
||||
onPress={() => {
|
||||
pricingPlans.finish();
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
title={strings.goBack()}
|
||||
onPress={() => {
|
||||
|
||||
@@ -272,9 +272,9 @@ const usePricingPlans = (options?: PricingPlansOptions) => {
|
||||
if (!(product as Plan)?.price) return null;
|
||||
return `${(product as Plan).price.currency} ${
|
||||
(product as Plan).period === "yearly"
|
||||
? ((product as Plan).price.gross / 12).toFixed(2)
|
||||
? (product as Plan).price.gross
|
||||
: (product as Plan).period === "5-year"
|
||||
? ((product as Plan).price.gross / (12 * 5)).toFixed(2)
|
||||
? (product as Plan).price.gross
|
||||
: (product as Plan).price.gross
|
||||
}`;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ async function setPremiumStatus() {
|
||||
|
||||
async function loadProductsAndSubs() {
|
||||
try {
|
||||
if (Config.GITHUB_RELEASE === "true") throw new Error("Github release");
|
||||
if (!subs || subs.length === 0) {
|
||||
subs = await RNIap.getSubscriptions({
|
||||
skus: itemSkus
|
||||
|
||||
Reference in New Issue
Block a user