From effa062d708091edb779d936860a9f0253409acc Mon Sep 17 00:00:00 2001
From: Arman
Date: Thu, 25 May 2023 14:26:37 +0200
Subject: [PATCH] fix: selected tier is not a env variable but a store
---
src/lib/components/support.svelte | 7 +++----
src/lib/stores/app.ts | 13 ++++++++++++-
src/lib/system.ts | 8 --------
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte
index e4537e84d..892274cac 100644
--- a/src/lib/components/support.svelte
+++ b/src/lib/components/support.svelte
@@ -4,12 +4,11 @@
import SupportOfflineDark from '$lib/images/support/support-offline-dark.png';
import SupportOnlineLight from '$lib/images/support/support-online-light.png';
import SupportOnlineDark from '$lib/images/support/support-online-dark.png';
- import { app } from '$lib/stores/app';
+ import { app, isFreeTier } from '$lib/stores/app';
import { wizard } from '$lib/stores/wizard';
import SupportWizard from '../../routes/console/supportWizard.svelte';
import { isSupportOnline } from '../../routes/console/wizard/store';
- import { isCloud, Tier } from '$lib/system';
- const tier = import.meta.env.VITE_CONSOLE_TIER?.toString() || Tier.FREE;
+ import { isCloud } from '$lib/system';
export let show = false;
@@ -35,7 +34,7 @@
Get personalized support from the Appwrite team from 09:00 - 17:00 UTC
- {#if tier === 'base'}
+ {#if isFreeTier}
diff --git a/src/lib/stores/app.ts b/src/lib/stores/app.ts
index 11afe9d6a..b092b3456 100644
--- a/src/lib/stores/app.ts
+++ b/src/lib/stores/app.ts
@@ -1,6 +1,6 @@
import { browser } from '$app/environment';
import { VARS } from '$lib/system';
-import { writable } from 'svelte/store';
+import { get, writable } from 'svelte/store';
export type AppStore = {
theme: 'light' | 'dark' | 'auto';
@@ -15,11 +15,22 @@ export type Feedback = {
show: boolean;
};
+export enum Tier {
+ FREE = 'free',
+ PRO = 'pro',
+ ENTERPRISE = 'enterprise'
+}
+
export const app = writable({
theme: 'auto',
themeInUse: 'light'
});
+//TODO: once billing is enabled on organization load/update, update the tier
+export const tier = writable(Tier.FREE);
+export const isFreeTier = get(tier) === Tier.FREE;
+export const isPaidTier = get(tier) === Tier.PRO || get(tier) === Tier.ENTERPRISE;
+
function createFeedbackStore() {
const { subscribe, update } = writable({
elapsed: browser ? parseInt(localStorage.getItem('feedbackElapsed')) : 0,
diff --git a/src/lib/system.ts b/src/lib/system.ts
index ccd609806..596e4faca 100644
--- a/src/lib/system.ts
+++ b/src/lib/system.ts
@@ -3,12 +3,6 @@ export enum Mode {
SELF_HOSTED = 'self-hosted'
}
-export enum Tier {
- FREE = 'free',
- PRO = 'pro',
- ENTERPRISE = 'enterprise'
-}
-
export const VARS = {
APPWRITE_ENDPOINT: import.meta.env?.VITE_APPWRITE_ENDPOINT?.toString() as string | undefined,
GROWTH_ENDPOINT: import.meta.env?.VITE_APPWRITE_GROWTH_ENDPOINT?.toString() as
@@ -29,5 +23,3 @@ export const ENV = {
export const MODE = VARS.CONSOLE_MODE === Mode.CLOUD ? Mode.CLOUD : Mode.SELF_HOSTED;
export const isCloud = MODE === Mode.CLOUD;
export const isSelfHosted = MODE === Mode.SELF_HOSTED;
-
-export const TIER = VARS;