🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Enhance PerformanceChart and Subscribe components for improved functionality and readability
Bill Yangd37e0d9a4ac4
diff --git a/client/src/app/[site]/performance/components/PerformanceChart.tsx b/client/src/app/[site]/performance/components/PerformanceChart.tsxindex c21889235..671dbb8ff 100644--- a/client/src/app/[site]/performance/components/PerformanceChart.tsx+++ b/client/src/app/[site]/performance/components/PerformanceChart.tsx@@ -293,6 +293,7 @@ export function PerformanceChart() {enableSlices="x"enableArea={false}markers={markers}+ lineWidth={1}sliceTooltip={({ slice }: any) => {const currentTime = DateTime.fromJSDate(new Date(slice.points[0].data.x));diff --git a/client/src/app/subscribe/components/PricingCard.tsx b/client/src/app/subscribe/components/PricingCard.tsxindex 5f448f777..2968b036f 100644--- a/client/src/app/subscribe/components/PricingCard.tsx+++ b/client/src/app/subscribe/components/PricingCard.tsx@@ -5,13 +5,7 @@ import { cn } from "@/lib/utils";import { toast } from "sonner";import { BACKEND_URL } from "@/lib/const";import { authClient } from "@/lib/auth";-import {- EVENT_TIERS,- PRO_FEATURES,- StripePrice,- findPriceForTier,- formatEventTier,-} from "./utils";+import { EVENT_TIERS, PRO_FEATURES, StripePrice, findPriceForTier, formatEventTier } from "./utils";interface PricingCardProps {stripePrices: StripePrice[];@@ -46,11 +40,7 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {return;}- const selectedTierPrice = findPriceForTier(- eventLimit,- isAnnual ? "year" : "month",- stripePrices- );+ const selectedTierPrice = findPriceForTier(eventLimit, isAnnual ? "year" : "month", stripePrices);if (!selectedTierPrice) {toast.error("Selected pricing plan not found. Please adjust the slider.");@@ -61,25 +51,22 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {try {// Use NEXT_PUBLIC_BACKEND_URL if available, otherwise use relative path for same-origin requestsconst baseUrl = window.location.origin;- const successUrl = `${baseUrl}/organization/subscription?session_id={CHECKOUT_SESSION_ID}`;+ const successUrl = `${baseUrl}/settings/organization/subscription?session_id={CHECKOUT_SESSION_ID}`;const cancelUrl = `${baseUrl}/subscribe`;- const response = await fetch(- `${BACKEND_URL}/stripe/create-checkout-session`,- {- method: "POST",- headers: {- "Content-Type": "application/json",- },- credentials: "include", // Send cookies- body: JSON.stringify({- priceId: selectedTierPrice.priceId,- successUrl: successUrl,- cancelUrl: cancelUrl,- organizationId: activeOrg.id,- }),- }- );+ const response = await fetch(`${BACKEND_URL}/stripe/create-checkout-session`, {+ method: "POST",+ headers: {+ "Content-Type": "application/json",+ },+ credentials: "include", // Send cookies+ body: JSON.stringify({+ priceId: selectedTierPrice.priceId,+ successUrl: successUrl,+ cancelUrl: cancelUrl,+ organizationId: activeOrg.id,+ }),+ });const data = await response.json();@@ -104,10 +91,8 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {}// Get pricing information- const monthlyPrice =- findPriceForTier(eventLimit, "month", stripePrices)?.price || 0;- const annualPrice =- findPriceForTier(eventLimit, "year", stripePrices)?.price || 0;+ const monthlyPrice = findPriceForTier(eventLimit, "month", stripePrices)?.price || 0;+ const annualPrice = findPriceForTier(eventLimit, "year", stripePrices)?.price || 0;const isCustomTier = eventLimit === "Custom";return (@@ -120,9 +105,7 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {<div><h3 className="font-semibold mb-2">Events per month</h3><div className="text-3xl font-bold text-emerald-400">- {typeof eventLimit === "number"- ? eventLimit.toLocaleString()- : eventLimit}+ {typeof eventLimit === "number" ? eventLimit.toLocaleString() : eventLimit}</div></div><div className="flex flex-col items-end">@@ -158,8 +141,7 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {) : (<><span className="text-3xl font-bold">- $- {isAnnual ? Math.round(annualPrice / 12) : monthlyPrice}+ ${isAnnual ? Math.round(annualPrice / 12) : monthlyPrice}</span><span className="ml-1 text-neutral-400">/month</span></>@@ -179,12 +161,7 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {<div className="flex justify-between text-xs text-neutral-400">{EVENT_TIERS.map((tier, index) => (- <span- key={index}- className={cn(- eventLimitIndex === index && "font-bold text-emerald-400"- )}- >+ <span key={index} className={cn(eventLimitIndex === index && "font-bold text-emerald-400")}>{formatEventTier(tier)}</span>))}@@ -205,17 +182,11 @@ export function PricingCard({ stripePrices, isLoggedIn }: PricingCardProps) {className="w-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium px-5 py-3 rounded-xl shadow-lg shadow-emerald-900/20 transform hover:-translate-y-0.5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-opacity-50 disabled:opacity-50 disabled:pointer-events-none cursor-pointer"disabled={isLoading}>- {isLoading- ? "Processing..."- : isCustomTier- ? "Contact us"- : "Subscribe Now"}+ {isLoading ? "Processing..." : isCustomTier ? "Contact us" : "Subscribe Now"}</button><p className="text-center text-sm text-neutral-400 mt-4">- {isCustomTier- ? "Email us at [email protected] for custom pricing"- : "Secure checkout powered by Stripe."}+ {isCustomTier ? "Email us at [email protected] for custom pricing" : "Secure checkout powered by Stripe."}</p></div></div>diff --git a/client/src/app/subscribe/page.tsx b/client/src/app/subscribe/page.tsxindex 084fa4b14..10f10ffb1 100644--- a/client/src/app/subscribe/page.tsx+++ b/client/src/app/subscribe/page.tsx@@ -21,7 +21,7 @@ export default function Subscribe() {// Redirect if already subscribedif (subscription?.status === "active") {- router.push("/organization/subscription");+ router.push("/settings/organization/subscription");}// Get the active organization ID@@ -40,8 +40,7 @@ export default function Subscribe() {});// Calculate total events over the past 30 days- const totalEvents =- eventCountData?.data?.reduce((sum, day) => sum + day.event_count, 0) || 0;+ const totalEvents = eventCountData?.data?.reduce((sum, day) => sum + day.event_count, 0) || 0;return (<StandardPage>@@ -49,10 +48,7 @@ export default function Subscribe() {<PricingHeader />{/* Pricing Card */}- <PricingCard- stripePrices={getStripePrices()}- isLoggedIn={!!sessionData?.user}- />+ <PricingCard stripePrices={getStripePrices()} isLoggedIn={!!sessionData?.user} />{/* Usage Stats and Chart */}{organizationId && (@@ -61,24 +57,16 @@ export default function Subscribe() {<div className="flex items-center justify-between mb-4"><div className="flex items-center gap-2"><TrendingUp className="h-5 w-5 text-blue-400" />- <h3 className="font-semibold text-lg">- Your Usage (Last 30 Days)- </h3>+ <h3 className="font-semibold text-lg">Your Usage (Last 30 Days)</h3></div><div className="text-right">- <p className="text-2xl font-bold text-blue-300">- {totalEvents.toLocaleString()}- </p>+ <p className="text-2xl font-bold text-blue-300">{totalEvents.toLocaleString()}</p><p className="text-xs text-neutral-400">total events</p></div></div><div className="p-1">- <UsageChart- organizationId={organizationId}- startDate={startDate}- endDate={endDate}- />+ <UsageChart organizationId={organizationId} startDate={startDate} endDate={endDate} /></div></div></div>