From 05949b1e770b8c1397428f977375a88991ab069f Mon Sep 17 00:00:00 2001 From: Wang Haoyang Date: Mon, 11 Nov 2024 21:21:24 +0800 Subject: [PATCH] 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