From 108730e2aa547c3e3be0e12b6c26119cf458dac7 Mon Sep 17 00:00:00 2001 From: gioelecerati Date: Wed, 28 Jun 2023 15:48:57 +0200 Subject: [PATCH] tmp switch to product id --- packages/api/src/controllers/user.ts | 8 ++++---- packages/www/components/PlanForm/index.tsx | 8 ++++---- packages/www/components/UsageSummary/index.tsx | 4 ++-- packages/www/hooks/use-api/endpoints/user.ts | 6 +++--- packages/www/pages/dashboard/billing/index.tsx | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/api/src/controllers/user.ts b/packages/api/src/controllers/user.ts index 8e9cd23f87..979607ca78 100644 --- a/packages/api/src/controllers/user.ts +++ b/packages/api/src/controllers/user.ts @@ -826,7 +826,7 @@ app.post( stripeCustomerId ); - if ( + /*if ( stripeProductId !== "prod_0" && stripeProductId !== "prod_1" && stripeProductId !== "prod_2" @@ -837,7 +837,7 @@ app.post( }); res.send(subscription); return; - } + }*/ // Update user's product and subscription id in our db await db.user.update(user.id, { @@ -906,7 +906,7 @@ app.post( ); // Temporarily skip updating the subscription if user is selecting a new plan - if ( + /*if ( payload.stripeProductId !== "prod_0" && payload.stripeProductId !== "prod_1" && payload.stripeProductId !== "prod_2" @@ -918,7 +918,7 @@ app.post( }); res.send(subscription); return; - } + }*/ // Get the prices associated with the subscription const subscriptionItems = await req.stripe.subscriptionItems.list({ diff --git a/packages/www/components/PlanForm/index.tsx b/packages/www/components/PlanForm/index.tsx index fd6ca1013a..2bb8866dad 100644 --- a/packages/www/components/PlanForm/index.tsx +++ b/packages/www/components/PlanForm/index.tsx @@ -428,12 +428,12 @@ const PlanForm = ({ You are currently using the{" "} - {products[user.newStripeProductId]?.name || - products[stripeProductId]?.name}{" "} + {products[stripeProductId]?.name || + products[user.newStripeProductId]?.name}{" "} plan. Do you want to{" "} {products[stripeProductId].order < - products[user.newStripeProductId]?.order || - products[stripeProductId]?.order + products[stripeProductId]?.order || + products[user.newStripeProductId]?.order ? "downgrade" : "upgrade"}{" "} to the {products[stripeProductId].name} plan? diff --git a/packages/www/components/UsageSummary/index.tsx b/packages/www/components/UsageSummary/index.tsx index 2fb13f9455..3df5308843 100644 --- a/packages/www/components/UsageSummary/index.tsx +++ b/packages/www/components/UsageSummary/index.tsx @@ -244,8 +244,8 @@ const UsageSummary = () => { variant="neutral" css={{ letterSpacing: 0, mt: "7px" }}> {user?.stripeProductId - ? products[user.newStripeProductId]?.name || - products[user.stripeProductId]?.name + ? products[user.stripeProductId]?.name || + products[user.newStripeProductId]?.name : products["hacker_1"].name}{" "} Plan diff --git a/packages/www/hooks/use-api/endpoints/user.ts b/packages/www/hooks/use-api/endpoints/user.ts index a0763693cd..330ed6fa87 100644 --- a/packages/www/hooks/use-api/endpoints/user.ts +++ b/packages/www/hooks/use-api/endpoints/user.ts @@ -179,11 +179,11 @@ export const getUser = async ( // Get current Stripe product, allowing for development users that don't have any export const getUserProduct = (user: User) => { if (hasStripe) { - return products[user.newStripeProductId] || products[user.stripeProductId]; + return products[user.stripeProductId] || products[user.newStripeProductId]; } return ( - products[user.newStripeProductId] || - products[user.stripeProductId || "prod_O9XuIjn7EqYRVW"] + products[user.stripeProductId] || + products[user.newStripeProductId || "prod_O9XuIjn7EqYRVW"] ); }; diff --git a/packages/www/pages/dashboard/billing/index.tsx b/packages/www/pages/dashboard/billing/index.tsx index 74afdd4276..eba5d17204 100644 --- a/packages/www/pages/dashboard/billing/index.tsx +++ b/packages/www/pages/dashboard/billing/index.tsx @@ -177,8 +177,8 @@ const Billing = () => { variant="neutral" css={{ mx: "$1", fontWeight: 700, letterSpacing: 0 }}> {user?.stripeProductId - ? products[user.newStripeProductId]?.name || - products[user.stripeProductId]?.name + ? products[user.stripeProductId]?.name || + products[user.newStripeProductId]?.name : products["hacker_1"]?.name} plan.