mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
mobile: redeem gift code
This commit is contained in:
committed by
Abdullah Atta
parent
6b4f7900ec
commit
c2e7f7576e
@@ -78,8 +78,7 @@ import { verifyUser, verifyUserWithApplock } from "./functions";
|
|||||||
import { SettingSection } from "./types";
|
import { SettingSection } from "./types";
|
||||||
import { getTimeLeft } from "./user-section";
|
import { getTimeLeft } from "./user-section";
|
||||||
import Clipboard from "@react-native-clipboard/clipboard";
|
import Clipboard from "@react-native-clipboard/clipboard";
|
||||||
|
import { User } from "@notesnook/core";
|
||||||
type User = any;
|
|
||||||
|
|
||||||
export const settingsGroups: SettingSection[] = [
|
export const settingsGroups: SettingSection[] = [
|
||||||
{
|
{
|
||||||
@@ -119,6 +118,10 @@ export const settingsGroups: SettingSection[] = [
|
|||||||
"MMMM D, YYYY"
|
"MMMM D, YYYY"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (user.subscription.provider === 4) {
|
||||||
|
return strings.subEndsOn(expiryDate);
|
||||||
|
}
|
||||||
|
|
||||||
return user.subscription?.type === 2
|
return user.subscription?.type === 2
|
||||||
? strings.signedUpOn(startDate)
|
? strings.signedUpOn(startDate)
|
||||||
: user.subscription?.type === 1
|
: user.subscription?.type === 1
|
||||||
@@ -134,6 +137,39 @@ export const settingsGroups: SettingSection[] = [
|
|||||||
: strings.neverHesitate();
|
: strings.neverHesitate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "redeem-gift-code",
|
||||||
|
name: strings.redeemGiftCode(),
|
||||||
|
description: strings.redeemGiftCodeDesc(),
|
||||||
|
hidden: (current) => {
|
||||||
|
return !current as boolean;
|
||||||
|
},
|
||||||
|
useHook: () =>
|
||||||
|
useUserStore(
|
||||||
|
(state) =>
|
||||||
|
state.user?.subscription.type == SUBSCRIPTION_STATUS.TRIAL ||
|
||||||
|
state.user?.subscription.type == SUBSCRIPTION_STATUS.BASIC
|
||||||
|
),
|
||||||
|
icon: "gift",
|
||||||
|
modifer: () => {
|
||||||
|
presentDialog({
|
||||||
|
title: strings.redeemGiftCode(),
|
||||||
|
paragraph: strings.redeemGiftCodeDesc(),
|
||||||
|
input: true,
|
||||||
|
inputPlaceholder: strings.code(),
|
||||||
|
positiveText: strings.redeem(),
|
||||||
|
positivePress: async (value) => {
|
||||||
|
db.subscriptions.redeemCode(value).catch((e) => {
|
||||||
|
ToastManager.show({
|
||||||
|
heading: "Error redeeming code",
|
||||||
|
message: (e as Error).message,
|
||||||
|
type: "error"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "account-settings",
|
id: "account-settings",
|
||||||
type: "screen",
|
type: "screen",
|
||||||
|
|||||||
@@ -126,18 +126,19 @@ export const Subscription = () => {
|
|||||||
user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&
|
user.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM_EXPIRED &&
|
||||||
user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC ? (
|
user.subscription?.type !== SUBSCRIPTION_STATUS.BASIC ? (
|
||||||
<Button
|
<Button
|
||||||
title={subscriptionProviderInfo?.title}
|
title={subscriptionProviderInfo?.title()}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
presentSheet({
|
presentSheet({
|
||||||
title: subscriptionProviderInfo.title,
|
title: subscriptionProviderInfo.title(),
|
||||||
paragraph: subscriptionProviderInfo.desc
|
paragraph: subscriptionProviderInfo.desc()
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
alignSelf: "flex-start",
|
alignSelf: "flex-start",
|
||||||
borderRadius: 100
|
width: "100%",
|
||||||
|
paddingHorizontal: 0
|
||||||
}}
|
}}
|
||||||
fontSize={SIZE.sm}
|
fontSize={SIZE.xs}
|
||||||
height={30}
|
height={30}
|
||||||
type="secondaryAccented"
|
type="secondaryAccented"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Binary file not shown.
@@ -81,7 +81,8 @@ const EXTRA_ICON_NAMES = [
|
|||||||
"notebook-plus",
|
"notebook-plus",
|
||||||
"arrow-right-bold-box-outline",
|
"arrow-right-bold-box-outline",
|
||||||
"arrow-up-bold",
|
"arrow-up-bold",
|
||||||
"login"
|
"login",
|
||||||
|
"gift"
|
||||||
];
|
];
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
|||||||
@@ -4584,6 +4584,10 @@ msgstr "Recovery key text file saved"
|
|||||||
msgid "Recovery successful!"
|
msgid "Recovery successful!"
|
||||||
msgstr "Recovery successful!"
|
msgstr "Recovery successful!"
|
||||||
|
|
||||||
|
#: src/strings.ts:2408
|
||||||
|
msgid "Redeem"
|
||||||
|
msgstr "Redeem"
|
||||||
|
|
||||||
#: src/strings.ts:2405
|
#: src/strings.ts:2405
|
||||||
msgid "Redeem gift code"
|
msgid "Redeem gift code"
|
||||||
msgstr "Redeem gift code"
|
msgstr "Redeem gift code"
|
||||||
|
|||||||
@@ -4564,6 +4564,10 @@ msgstr "<<<<<<< HEAD<<<<<<< HEAD"
|
|||||||
|
|
||||||
#: src/strings.ts:1891
|
#: src/strings.ts:1891
|
||||||
msgid "Recovery successful!"
|
msgid "Recovery successful!"
|
||||||
|
msgstr "<<<<<<< HEAD"
|
||||||
|
|
||||||
|
#: src/strings.ts:2408
|
||||||
|
msgid "Redeem"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: src/strings.ts:2405
|
#: src/strings.ts:2405
|
||||||
|
|||||||
@@ -2404,5 +2404,6 @@ Use this if changes from other devices are not appearing on this device. This wi
|
|||||||
emailCopied: () => t`Email copied`,
|
emailCopied: () => t`Email copied`,
|
||||||
redeemGiftCode: () => t`Redeem gift code`,
|
redeemGiftCode: () => t`Redeem gift code`,
|
||||||
redeemGiftCodeDesc: () => t`Enter the gift code to redeem your subscription.`,
|
redeemGiftCodeDesc: () => t`Enter the gift code to redeem your subscription.`,
|
||||||
redeemingGiftCode: () => t`Redeeming gift code`
|
redeemingGiftCode: () => t`Redeeming gift code`,
|
||||||
|
redeem: () => t`Redeem`
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user