From 358f0f07b24fc63616010ec678540c4fca6fdf92 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 16 Nov 2022 04:47:02 -0500 Subject: [PATCH 1/2] fix build errors --- packages/fakeyou/src/v2/view/premium/CheckoutSuccessPage.tsx | 2 +- packages/fakeyou/src/v2/view/premium/PortalSuccessPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/fakeyou/src/v2/view/premium/CheckoutSuccessPage.tsx b/packages/fakeyou/src/v2/view/premium/CheckoutSuccessPage.tsx index d96a798c80..18966f6341 100644 --- a/packages/fakeyou/src/v2/view/premium/CheckoutSuccessPage.tsx +++ b/packages/fakeyou/src/v2/view/premium/CheckoutSuccessPage.tsx @@ -2,7 +2,7 @@ import React from "react"; import { Link } from "react-router-dom"; import { motion } from "framer-motion"; -import { container, item, image, panel } from "../../../data/animation"; +import { container, item, image } from "../../../data/animation"; import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper"; interface Props { diff --git a/packages/fakeyou/src/v2/view/premium/PortalSuccessPage.tsx b/packages/fakeyou/src/v2/view/premium/PortalSuccessPage.tsx index a212393e5d..83bac1a5b4 100644 --- a/packages/fakeyou/src/v2/view/premium/PortalSuccessPage.tsx +++ b/packages/fakeyou/src/v2/view/premium/PortalSuccessPage.tsx @@ -1,7 +1,7 @@ import React from "react"; import { Link } from "react-router-dom"; import { motion } from "framer-motion"; -import { container, item, image, panel } from "../../../data/animation"; +import { container, item, image } from "../../../data/animation"; import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper"; interface Props { From b0335b40473a025f65956ab8542f69f470a01640 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Wed, 16 Nov 2022 06:56:23 -0500 Subject: [PATCH 2/2] Plans based on environment --- packages/fakeyou/src/data/PriceTiers.js | 25 +++++++-- .../v2/view/_common/FrontendEnvironment.ts | 51 +++++++++++++++++++ .../src/v2/view/premium/PricingPage.tsx | 14 +++-- 3 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 packages/fakeyou/src/v2/view/_common/FrontendEnvironment.ts diff --git a/packages/fakeyou/src/data/PriceTiers.js b/packages/fakeyou/src/data/PriceTiers.js index c0abaeddc7..4782f83b22 100644 --- a/packages/fakeyou/src/data/PriceTiers.js +++ b/packages/fakeyou/src/data/PriceTiers.js @@ -1,7 +1,10 @@ const FAKEYOU_PRICES = { //Starter Tier starter: { - internal_plan_key: null, + internal_plan_key: { + development: null, + production: null, + }, tier: "Starter", price: 0, tts: { @@ -32,7 +35,10 @@ const FAKEYOU_PRICES = { //Basic Tier basic: { - internal_plan_key: null, // TODO + internal_plan_key: { + development: null, // TODO + production: null, // TODO + }, tier: "Basic", price: 3, tts: { @@ -63,7 +69,10 @@ const FAKEYOU_PRICES = { //Plus Tier plus: { - internal_plan_key: "development_fakeyou_plus", + internal_plan_key: { + development: "development_fakeyou_plus", + production: "fakeyou_plus", + }, tier: "Plus", price: 7, tts: { @@ -94,7 +103,10 @@ const FAKEYOU_PRICES = { //Pro Tier pro: { - internal_plan_key: "development_fakeyou_pro", + internal_plan_key: { + development: "development_fakeyou_pro", + production: "fakeyou_pro", + }, tier: "Pro", price: 15, tts: { @@ -134,7 +146,10 @@ const FAKEYOU_PRICES = { //Elite Tier elite: { - internal_plan_key: "development_fakeyou_elite", + internal_plan_key: { + development: "development_fakeyou_elite", + production: "fakeyou_elite", + }, tier: "Elite", price: 25, tts: { diff --git a/packages/fakeyou/src/v2/view/_common/FrontendEnvironment.ts b/packages/fakeyou/src/v2/view/_common/FrontendEnvironment.ts new file mode 100644 index 0000000000..24026211e7 --- /dev/null +++ b/packages/fakeyou/src/v2/view/_common/FrontendEnvironment.ts @@ -0,0 +1,51 @@ + +enum Environment { + Development, + Staging, + Production, +} + +export class FrontendEnvironment { + static instance?: FrontendEnvironment; + + environment: Environment; + + private constructor() { + switch (document.location.host) { + case 'fakeyou.com': + this.environment = Environment.Production; + break; + case 'staging.fakeyou.com': + this.environment = Environment.Staging; + break; + case 'dev.fakeyou.com': + this.environment = Environment.Development; + break; + default: + this.environment = Environment.Production; + } + } + + public static getInstance() : FrontendEnvironment { + if (FrontendEnvironment.instance === undefined) { + FrontendEnvironment.instance = new FrontendEnvironment(); + } + return FrontendEnvironment.instance; + } + + public useProductionStripePlans() : boolean { + return this.isProduction() || this.isStaging(); + } + + public isProduction() : boolean { + return this.environment === Environment.Production; + } + + public isStaging() : boolean { + return this.environment === Environment.Staging; + } + + public isDevelopment() : boolean { + return this.environment === Environment.Development; + } +} diff --git a/packages/fakeyou/src/v2/view/premium/PricingPage.tsx b/packages/fakeyou/src/v2/view/premium/PricingPage.tsx index 80f789f1be..58da3dd28c 100644 --- a/packages/fakeyou/src/v2/view/premium/PricingPage.tsx +++ b/packages/fakeyou/src/v2/view/premium/PricingPage.tsx @@ -15,6 +15,7 @@ import { CreateStripePortalRedirectIsError, CreateStripePortalRedirectIsSuccess, } from "@storyteller/components/src/api/premium/CreateStripePortalRedirect"; +import { FrontendEnvironment } from "../_common/FrontendEnvironment"; interface Props { sessionWrapper: SessionWrapper; @@ -54,14 +55,17 @@ function PricingPage(props: Props) { } }; - const hasPaidPremium = props.sessionSubscriptionsWrapper.hasPaidFeatures(); + const environment = FrontendEnvironment.getInstance(); + const planKey = environment.useProductionStripePlans() ? "production" : "development"; + + const userHasPaidPremium = props.sessionSubscriptionsWrapper.hasPaidFeatures(); let freeButtonText = "Use for free"; let plusButtonText = "Buy Plus"; let proButtonText = "Buy Pro"; let eliteButtonText = "Buy Elite"; - if (hasPaidPremium) { + if (userHasPaidPremium) { freeButtonText = "Unsubscribe"; plusButtonText = "Switch to Plus"; proButtonText = "Switch to Pro"; @@ -251,7 +255,7 @@ function PricingPage(props: Props) {

{FYP.plus.tier}