Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: add user's subscription info in settings

thecodrrf97a8b76cac0
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index e551b47d7..d028f0623 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -13,10 +13,15 @@ import { store as userstore } from "../stores/user-store";
import { hashNavigate } from "../navigation";
export const db = new Database(StorageInterface, EventSource);
+// db.host({
+// API_HOST: "https://api.notesnook.com",
+// AUTH_HOST: "https://auth.streetwriters.co",
+// SSE_HOST: "https://events.streetwriters.co",
+// });
db.host({
- API_HOST: "https://192.168.10.5:5264",
- AUTH_HOST: "https://192.168.10.5:8264",
- SSE_HOST: "https://192.168.10.5:7264",
+ API_HOST: "http://localhost:5264",
+ AUTH_HOST: "http://localhost:8264",
+ SSE_HOST: "http://localhost:7264",
});
//db.host("http://192.168.10.5:8100");
// db.host();
@@ -33,11 +38,11 @@ export const COLORS = {
};
export const SUBSCRIPTION_STATUS = {
- EXPIRED: 0,
+ BASIC: 0,
TRIAL: 1,
- ACTIVE: 2,
- ACTIVE_RENEWING: 3,
- CANCELLED: 4,
+ BETA: 2,
+ TRIAL_EXPIRED: 3,
+ BETA_EXPIRED: 4,
};
export const SELECTION_OPTIONS_MAP = {
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 972814067..cdba3b5ea 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -54,6 +54,14 @@ function importBackup() {
});
}
+function subscriptionStatusToString(user) {
+ const status = user?.subscription?.type;
+
+ if (status === SUBSCRIPTION_STATUS.BETA) return "Beta";
+ else if (status === SUBSCRIPTION_STATUS.TRIAL) return "Trial";
+ else return "Basic";
+}
+
function Settings(props) {
const isSystemThemeDark = useSystemTheme();
const isVaultCreated = useAppStore((store) => store.isVaultCreated);
@@ -79,10 +87,14 @@ function Settings(props) {
() => dayjs(user?.subscription?.expiry).diff(dayjs(), "day") + 1,
[user]
);
- const isTrial = useMemo(
- () => user?.subscription?.status === SUBSCRIPTION_STATUS.TRIAL,
- [user]
- );
+
+ const isTrial = useMemo(() => {
+ return user?.subscription?.type === SUBSCRIPTION_STATUS.TRIAL;
+ }, [user]);
+
+ const isBeta = useMemo(() => {
+ return user?.subscription?.type === SUBSCRIPTION_STATUS.BETA;
+ }, [user]);
useEffect(() => {
if (!followSystemTheme) return;
@@ -94,16 +106,19 @@ function Settings(props) {
<Flex variant="columnFill" px={2}>
{isLoggedIn ? (
<Flex
- bg="shade"
+ bg={user.isEmailConfirmed ? "shade" : "errorBg"}
flexDirection="column"
p={2}
sx={{ borderRadius: "default" }}
>
<Flex flex="1" justifyContent="space-between">
<Flex>
- <Icon.User size={15} color="primary" />
+ <Icon.User
+ size={15}
+ color={user.isEmailConfirmed ? "primary" : "error"}
+ />
<Text variant="body" color="text" ml={1}>
- {user.username}
+ {user.email}
</Text>
</Flex>
<Text
@@ -111,29 +126,59 @@ function Settings(props) {
px={"2px"}
py={"1px"}
sx={{ borderRadius: "default" }}
- bg="static"
- color="primary"
+ bg={user.isEmailConfirmed ? "primary" : "errorBg"}
+ color={user.isEmailConfirmed ? "static" : "error"}
>
- {isTrial ? "Trial" : "Pro"}
+ {subscriptionStatusToString(user)}
</Text>
</Flex>
- <Text
- color={subscriptionDaysRemaining <= 5 ? "error" : "primary"}
- variant="body"
- fontSize={26}
- mt={2}
- >
- {subscriptionDaysRemaining > 0
- ? `${subscriptionDaysRemaining} Days Remaining`
- : "Your trial has ended."}
- </Text>
- <Text variant="subBody">
- Your trial period started on{" "}
- {dayjs(user.subscription.start).format("MMMM D, YYYY")}
- </Text>
- {isTrial && (
- <Button mt={2} onClick={showBuyDialog}>
- Upgrade to Notesnook Pro
+ {user.isEmailConfirmed ? (
+ isTrial ? (
+ <>
+ <Text
+ color={subscriptionDaysRemaining <= 5 ? "error" : "primary"}
+ variant="body"
+ fontSize={26}
+ mt={2}
+ >
+ {subscriptionDaysRemaining > 0
+ ? `${subscriptionDaysRemaining} Days Remaining`
+ : "Your trial has ended."}
+ </Text>
+ <Text variant="subBody">
+ Your trial period started on{" "}
+ {dayjs(user.subscription.start).format("MMMM D, YYYY")}
+ </Text>
+ <Button mt={2} onClick={showBuyDialog}>
+ Upgrade to Notesnook Pro
+ </Button>
+ </>
+ ) : isBeta ? (
+ <>
+ <Text
+ color={subscriptionDaysRemaining <= 5 ? "error" : "primary"}
+ variant="body"
+ fontSize={26}
+ mt={2}
+ >
+ {subscriptionDaysRemaining > 0
+ ? `${subscriptionDaysRemaining} Days Remaining`
+ : "Your beta subscription has ended."}
+ </Text>
+ <Text variant="subBody">
+ Your were enrolled in our beta program on{" "}
+ {dayjs(user.subscription.start).format("MMMM D, YYYY")}
+ </Text>
+ </>
+ ) : null
+ ) : (
+ <Button mt={2} bg="error">
+ <Flex alignItems="center">
+ <Icon.Warn color="static" size={13} />
+ <Text color="static" ml={1}>
+ Please verify your email.
+ </Text>
+ </Flex>
</Button>
)}
</Flex>