From 6460224b3f52e7eda940c1a5cb1c01ac639033e4 Mon Sep 17 00:00:00 2001 From: Wang Haoyang Date: Mon, 11 Nov 2024 21:20:39 +0800 Subject: [PATCH 1/3] Fix tier IDs -Update frontend tier IDs to match backend tier IDs for the respective tiers -This fixes incorrect display of Jippy Tier on frontend --- frontend/types/billing.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/types/billing.ts b/frontend/types/billing.ts index ae5881f3..5f806fb4 100644 --- a/frontend/types/billing.ts +++ b/frontend/types/billing.ts @@ -8,8 +8,8 @@ export enum JippyTier { export enum JippyTierID { Free = 1, - Premium = 2, - Enterprise = 3, + Premium = 3, + Enterprise = 5, } export enum JippyTierStatus { From 05949b1e770b8c1397428f977375a88991ab069f Mon Sep 17 00:00:00 2001 From: Wang Haoyang Date: Mon, 11 Nov 2024 21:21:24 +0800 Subject: [PATCH 2/3] Remove hardcoded values -Replace hardcoded tier ID values on frontend with enum in frontend/types/ --- frontend/app/(authenticated)/user/billing/page.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/app/(authenticated)/user/billing/page.tsx b/frontend/app/(authenticated)/user/billing/page.tsx index 94964e0a..a72517fd 100644 --- a/frontend/app/(authenticated)/user/billing/page.tsx +++ b/frontend/app/(authenticated)/user/billing/page.tsx @@ -26,7 +26,7 @@ const getPriceButtonText = ( priceTierId: number, user: UserPublic | undefined, ) => { - const userTierId = user?.tier_id || 1; + const userTierId = user?.tier_id || JippyTierID.Free; const isUserUnverified = user?.verified === false || userTierId === UNVERIFIED_TIER_ID; if (isUserUnverified) { @@ -84,7 +84,7 @@ const Page = () => { onClickBuy: () => { stripeCheckoutMutation.mutate({ price_id: process.env.NEXT_PUBLIC_STRIPE_PREMIUM_TIER_PRICE_ID || "", - tier_id: Number(process.env.NEXT_PUBLIC_PREMIUM_TIER_ID) || 1, + tier_id: Number(process.env.NEXT_PUBLIC_PREMIUM_TIER_ID) || JippyTierID.Free, }); }, price: TierPrice.Premium, @@ -116,7 +116,7 @@ const Page = () => { // Display toast to notify the user that payment got cancelled toast({ title: "Payment Cancelled", - description: `Unable to upgrade your tier, you remain at ${tierIDToTierName(user?.tier_id || 1)} Tier`, + description: `Unable to upgrade your tier, you remain at ${tierIDToTierName(user?.tier_id || JippyTierID.Free)} Tier`, }); // Remove query parameters from the URL after showing the toast From b78a55b19cbd4e4f56fcf2c55eee91f4f437757a Mon Sep 17 00:00:00 2001 From: Wang Haoyang Date: Mon, 11 Nov 2024 21:26:46 +0800 Subject: [PATCH 3/3] Fix frontend code styling --- frontend/app/(authenticated)/user/billing/page.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/app/(authenticated)/user/billing/page.tsx b/frontend/app/(authenticated)/user/billing/page.tsx index a72517fd..f2329cc0 100644 --- a/frontend/app/(authenticated)/user/billing/page.tsx +++ b/frontend/app/(authenticated)/user/billing/page.tsx @@ -84,7 +84,8 @@ const Page = () => { onClickBuy: () => { stripeCheckoutMutation.mutate({ price_id: process.env.NEXT_PUBLIC_STRIPE_PREMIUM_TIER_PRICE_ID || "", - tier_id: Number(process.env.NEXT_PUBLIC_PREMIUM_TIER_ID) || JippyTierID.Free, + tier_id: + Number(process.env.NEXT_PUBLIC_PREMIUM_TIER_ID) || JippyTierID.Free, }); }, price: TierPrice.Premium,