From 7c06409076342b20d053e3832374847887f73929 Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:26:01 +0200 Subject: [PATCH 01/26] rename TierIds to PaymentPlanIds --- template/app/src/client/app/AccountPage.tsx | 4 ++-- template/app/src/client/app/PricingPage.tsx | 16 ++++++++-------- template/app/src/server/actions.ts | 16 ++++++++-------- template/app/src/server/webhooks/stripe.ts | 6 +++--- template/app/src/shared/constants.ts | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/template/app/src/client/app/AccountPage.tsx b/template/app/src/client/app/AccountPage.tsx index 5dd23ac5..31b21c0b 100644 --- a/template/app/src/client/app/AccountPage.tsx +++ b/template/app/src/client/app/AccountPage.tsx @@ -1,7 +1,7 @@ import { Link } from 'wasp/client/router'; import { type User } from 'wasp/entities'; import { logout } from 'wasp/client/auth'; -import { TierIds } from '../../shared/constants'; +import { PaymentPlanIds } from '../../shared/constants'; import { z } from 'zod'; export default function AccountPage({ user }: { user: User }) { @@ -31,7 +31,7 @@ export default function AccountPage({ user }: { user: User }) { <> {user.subscriptionStatus !== 'past_due' ? (
- {user.subscriptionTier === TierIds.HOBBY ? 'Hobby' : 'Pro'} Plan + {user.subscriptionTier === PaymentPlanIds.HOBBY ? 'Hobby' : 'Pro'} Plan
) : (
diff --git a/template/app/src/client/app/PricingPage.tsx b/template/app/src/client/app/PricingPage.tsx index 37ef2dab..77eaabe3 100644 --- a/template/app/src/client/app/PricingPage.tsx +++ b/template/app/src/client/app/PricingPage.tsx @@ -1,6 +1,6 @@ import { useAuth } from 'wasp/client/auth'; import { stripePayment } from 'wasp/client/operations'; -import { TierIds } from '../../shared/constants'; +import { PaymentPlanIds } from '../../shared/constants'; import { AiFillCheckCircle } from 'react-icons/ai'; import { useState } from 'react'; import { useHistory } from 'react-router-dom'; @@ -10,14 +10,14 @@ import { z } from 'zod'; export const tiers = [ { name: 'Hobby', - id: TierIds.HOBBY, + id: PaymentPlanIds.HOBBY, price: '$9.99', description: 'All you need to get started', features: ['Limited monthly usage', 'Basic support'], }, { name: 'Pro', - id: TierIds.PRO, + id: PaymentPlanIds.PRO, price: '$19.99', description: 'Our most popular plan', features: ['Unlimited monthly usage', 'Priority customer support'], @@ -25,7 +25,7 @@ export const tiers = [ }, { name: '10 Credits', - id: TierIds.CREDITS, + id: PaymentPlanIds.CREDITS, price: '$9.99', description: 'One-time purchase of 10 credits for your account', features: ['Use credits for e.g. OpenAI API calls', 'No expiration date'], @@ -39,14 +39,14 @@ const PricingPage = () => { const history = useHistory(); - async function handleBuyNowClick(tierId: string) { + async function handleBuyNowClick(paymentPlanId: PaymentPlanIds) { if (!user) { history.push('/login'); return; } try { - setIsStripePaymentLoading(tierId); - let stripeResults = await stripePayment(tierId); + setIsStripePaymentLoading(paymentPlanId); + let stripeResults = await stripePayment(paymentPlanId); if (stripeResults?.sessionUrl) { window.open(stripeResults.sessionUrl, '_self'); @@ -117,7 +117,7 @@ const PricingPage = () => {

{tier.price} - {tier.id !== TierIds.CREDITS && '/month'} + {tier.id !== PaymentPlanIds.CREDITS && '/month'}