From 6065c4af0691380d10dfe79ad01c3e834703bc4d Mon Sep 17 00:00:00 2001 From: javayhu Date: Fri, 5 Sep 2025 00:05:10 +0800 Subject: [PATCH] refactor: rename getPricePlans to usePricePlans for improved clarity and consistency --- src/components/pricing/pricing-table.tsx | 4 ++-- src/components/settings/billing/billing-card.tsx | 4 ++-- src/config/price-config.tsx | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/pricing/pricing-table.tsx b/src/components/pricing/pricing-table.tsx index 624d000..9e8cba8 100644 --- a/src/components/pricing/pricing-table.tsx +++ b/src/components/pricing/pricing-table.tsx @@ -1,7 +1,7 @@ 'use client'; import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'; -import { getPricePlans } from '@/config/price-config'; +import { usePricePlans } from '@/config/price-config'; import { cn } from '@/lib/utils'; import { PaymentTypes, @@ -36,7 +36,7 @@ export function PricingTable({ const [interval, setInterval] = useState(PlanIntervals.MONTH); // Get price plans with translations - const pricePlans = getPricePlans(); + const pricePlans = usePricePlans(); const plans = Object.values(pricePlans); // Current plan ID for comparison diff --git a/src/components/settings/billing/billing-card.tsx b/src/components/settings/billing/billing-card.tsx index 4a41900..0cd4698 100644 --- a/src/components/settings/billing/billing-card.tsx +++ b/src/components/settings/billing/billing-card.tsx @@ -12,7 +12,7 @@ import { CardTitle, } from '@/components/ui/card'; import { Skeleton } from '@/components/ui/skeleton'; -import { getPricePlans } from '@/config/price-config'; +import { usePricePlans } from '@/config/price-config'; import { useMounted } from '@/hooks/use-mounted'; import { useCurrentPlan } from '@/hooks/use-payment'; import { LocaleLink, useLocaleRouter } from '@/i18n/navigation'; @@ -50,7 +50,7 @@ export default function BillingCard() { const subscription = paymentData?.subscription; // Get price plans with translations - must be called here to maintain hook order - const pricePlans = getPricePlans(); + const pricePlans = usePricePlans(); const plans = Object.values(pricePlans); // Convert current plan to a plan with translations diff --git a/src/config/price-config.tsx b/src/config/price-config.tsx index e9380cd..9ddb720 100644 --- a/src/config/price-config.tsx +++ b/src/config/price-config.tsx @@ -16,7 +16,7 @@ import { websiteConfig } from './website'; * * @returns The price plans with translated content */ -export function getPricePlans(): Record { +export function usePricePlans(): Record { const t = useTranslations('PricePlans'); const priceConfig = websiteConfig.price; const plans: Record = {};