Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix frontend tier handling #416

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions frontend/app/(authenticated)/user/billing/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) || 1,
tier_id:
Number(process.env.NEXT_PUBLIC_PREMIUM_TIER_ID) || JippyTierID.Free,
});
},
price: TierPrice.Premium,
Expand Down Expand Up @@ -116,7 +117,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
Expand Down
4 changes: 2 additions & 2 deletions frontend/types/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export enum JippyTier {

export enum JippyTierID {
Free = 1,
Premium = 2,
Enterprise = 3,
Premium = 3,
Enterprise = 5,
}

export enum JippyTierStatus {
Expand Down
Loading