From df4dfba31d47bb3df9c1736d84d02f95fb30d623 Mon Sep 17 00:00:00 2001 From: BennyKok Date: Thu, 25 Jan 2024 10:57:13 +0800 Subject: [PATCH 1/3] chore: migrate sign in to domain relative path with clerk, add .env.example as well --- web/.env.example | 11 +++++++++++ .../app/(app)/auth/sign-in/[[...sign-in]]/page.tsx | 9 +++++++++ .../app/(app)/auth/sign-up/[[...sign-up]]/page.tsx | 9 +++++++++ 3 files changed, 29 insertions(+) create mode 100644 web/src/app/(app)/auth/sign-in/[[...sign-in]]/page.tsx create mode 100644 web/src/app/(app)/auth/sign-up/[[...sign-up]]/page.tsx diff --git a/web/.env.example b/web/.env.example index 008df45..2e8e47a 100644 --- a/web/.env.example +++ b/web/.env.example @@ -20,3 +20,14 @@ PLAUSIBLE_DOMAIN= NEXT_PUBLIC_POSTHOG_KEY="your-api-key" NEXT_PUBLIC_POSTHOG_HOST="your-ph-address" + +NEXT_PUBLIC_CLERK_SIGN_IN_URL=/auth/sign-in +NEXT_PUBLIC_CLERK_SIGN_UP_URL=/auth/sign-up +NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/ +NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/ + +STRIPE_API_KEY="sk_test_" +STRIPE_PR_PRO="price_" +STRIPE_PR_ENTERPRISE="price_" +STRIPE_PR_API="price_" +STRIPE_WEBHOOK_SECRET="whsec_" diff --git a/web/src/app/(app)/auth/sign-in/[[...sign-in]]/page.tsx b/web/src/app/(app)/auth/sign-in/[[...sign-in]]/page.tsx new file mode 100644 index 0000000..635f96d --- /dev/null +++ b/web/src/app/(app)/auth/sign-in/[[...sign-in]]/page.tsx @@ -0,0 +1,9 @@ +import { SignIn } from "@clerk/nextjs"; + +export default function Page() { + return ( +
+ +
+ ); +} diff --git a/web/src/app/(app)/auth/sign-up/[[...sign-up]]/page.tsx b/web/src/app/(app)/auth/sign-up/[[...sign-up]]/page.tsx new file mode 100644 index 0000000..6118593 --- /dev/null +++ b/web/src/app/(app)/auth/sign-up/[[...sign-up]]/page.tsx @@ -0,0 +1,9 @@ +import { SignUp } from "@clerk/nextjs"; + +export default function Page() { + return ( +
+ +
+ ); +} From 85e4219ea7c9fa8b36b301c96dd898d4b92938d1 Mon Sep 17 00:00:00 2001 From: BennyKok Date: Thu, 25 Jan 2024 11:16:41 +0800 Subject: [PATCH 2/3] fix: remove unused import, fix build --- web/src/app/(app)/api/stripe/checkout/route.tsx | 1 - web/src/app/(app)/api/stripe/dashboard/route.tsx | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/web/src/app/(app)/api/stripe/checkout/route.tsx b/web/src/app/(app)/api/stripe/checkout/route.tsx index 9ccd287..34c5572 100644 --- a/web/src/app/(app)/api/stripe/checkout/route.tsx +++ b/web/src/app/(app)/api/stripe/checkout/route.tsx @@ -1,5 +1,4 @@ import { stripe } from "@/server/stripe"; -import { createCheckout } from "@/server/linkToPricing"; import { auth, clerkClient } from "@clerk/nextjs"; import { redirect } from "next/navigation"; import { getUrlServerSide } from "@/server/getUrlServerSide"; diff --git a/web/src/app/(app)/api/stripe/dashboard/route.tsx b/web/src/app/(app)/api/stripe/dashboard/route.tsx index 95fe442..89c075c 100644 --- a/web/src/app/(app)/api/stripe/dashboard/route.tsx +++ b/web/src/app/(app)/api/stripe/dashboard/route.tsx @@ -1,11 +1,7 @@ import { stripe } from "@/server/stripe"; -import { createCheckout } from "@/server/linkToPricing"; -import { auth, clerkClient } from "@clerk/nextjs"; +import { auth } from "@clerk/nextjs"; import { redirect } from "next/navigation"; import { getUrlServerSide } from "@/server/getUrlServerSide"; -import { db } from "@/db/db"; -import { and, eq, isNull } from "drizzle-orm"; -import { subscriptionStatusTable } from "@/db/schema"; import { getCurrentPlan } from "@/server/getCurrentPlan"; export async function GET(req: Request) { From 3d2eacccc99a081b2b5309b3332ba852219bab58 Mon Sep 17 00:00:00 2001 From: BennyKok Date: Thu, 25 Jan 2024 12:08:09 +0800 Subject: [PATCH 3/3] fix: build --- web/src/components/PricingPlan.tsx | 50 ++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/web/src/components/PricingPlan.tsx b/web/src/components/PricingPlan.tsx index 2845de4..6f38569 100644 --- a/web/src/components/PricingPlan.tsx +++ b/web/src/components/PricingPlan.tsx @@ -8,7 +8,6 @@ import { Check, Info, Minus } from "lucide-react"; import { Fragment } from "react"; import { auth } from "@clerk/nextjs"; -import { subscriptionPlanStatus } from "@/db/schema"; import { getCurrentPlan } from "../server/getCurrentPlan"; const tiers = [ @@ -38,7 +37,22 @@ const tiers = [ mostPopular: true, }, ]; -const sections = [ +type TierFeature = { + Basic?: string | JSX.Element | boolean; + Pro?: string | JSX.Element | boolean; + Enterprise?: string | JSX.Element | boolean; +}; + +type Feature = { + name: string; + tiers: TierFeature; +}; + +type Section = { + name: string; + features: Feature[]; +}; +const sections: Section[] = [ { name: "Features", features: [ @@ -212,7 +226,7 @@ export default async function PricingList() {
    • {section.features.map((feature) => - feature.tiers[tier.name] ? ( + feature.tiers[tier.name as keyof TierFeature] ? (
    • {feature.name}{" "} - {typeof feature.tiers[tier.name] === "string" ? ( + {typeof feature.tiers[ + tier.name as keyof TierFeature + ] === "string" ? ( - ({feature.tiers[tier.name]}) + ( + { + feature.tiers[ + tier.name as keyof TierFeature + ] + } + ) ) : null} @@ -338,14 +360,20 @@ export default async function PricingList() { {tiers.map((tier) => ( - {typeof feature.tiers[tier.name] === "string" || - typeof feature.tiers[tier.name] === "object" ? ( + {typeof feature.tiers[ + tier.name as keyof TierFeature + ] === "string" || + typeof feature.tiers[ + tier.name as keyof TierFeature + ] === "object" ? (
      - {feature.tiers[tier.name]} + {feature.tiers[tier.name as keyof TierFeature]}
      ) : ( <> - {feature.tiers[tier.name] === true ? ( + {feature.tiers[ + tier.name as keyof TierFeature + ] === true ? (