Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: Separate vite and next plan util

Richie McIlroyb3f4d0be15d3
diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
index 4fd75afc4..65f1f8ca0 100644
--- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
+++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx
@@ -1,5 +1,5 @@
import { createSignal, onCleanup, onMount } from "solid-js";
-import { getProPlanId } from "@cap/utils";
+import { getProPlanId } from "~/utils/plans";
import { commands } from "~/utils/tauri";
import { clientEnv } from "~/utils/env";
import { authStore } from "../../store";
diff --git a/apps/desktop/src/utils/plans.ts b/apps/desktop/src/utils/plans.ts
new file mode 100644
index 000000000..dec332013
--- /dev/null
+++ b/apps/desktop/src/utils/plans.ts
@@ -0,0 +1,32 @@
+const planIds = {
+ development: {
+ yearly: "price_1Q3esrFJxA1XpeSsFwp486RN",
+ monthly: "price_1P9C1DFJxA1XpeSsTwwuddnq",
+ },
+ production: {
+ yearly: "price_1Q29mcFJxA1XpeSsbti0xJpZ",
+ monthly: "price_1OtBMeFJxA1XpeSsfOu2SKp1",
+ },
+};
+
+export const getProPlanId = (billingCycle: "yearly" | "monthly") => {
+ const environment = import.meta.env.VITE_ENVIRONMENT === "development" ? "development" : "production";
+ return planIds[environment]?.[billingCycle] || "";
+};
+
+export const isUserOnProPlan = ({
+ subscriptionStatus,
+}: {
+ subscriptionStatus: string;
+}) => {
+ if (
+ subscriptionStatus === "active" ||
+ subscriptionStatus === "trialing" ||
+ subscriptionStatus === "complete" ||
+ subscriptionStatus === "paid"
+ ) {
+ return true;
+ }
+
+ return false;
+};
\ No newline at end of file
diff --git a/packages/utils/src/constants/plans.ts b/packages/utils/src/constants/plans.ts
index 625e056e1..48569a46e 100644
--- a/packages/utils/src/constants/plans.ts
+++ b/packages/utils/src/constants/plans.ts
@@ -10,10 +10,7 @@ const planIds = {
};
export const getProPlanId = (billingCycle: "yearly" | "monthly") => {
- const value =
- typeof import.meta !== 'undefined' && typeof import.meta.env !== 'undefined'
- ? import.meta.env.VITE_ENVIRONMENT
- : process.env.NEXT_PUBLIC_ENVIRONMENT;
+ const value = process.env.NEXT_PUBLIC_ENVIRONMENT;
const environment = value === "development" ? "development" : "production";
return planIds[environment]?.[billingCycle] || "";