refactor: rename getCreditPackages to useCreditPackages for improved clarity and consistency
This commit is contained in:
parent
c94784e711
commit
ba7b950c01
@ -8,7 +8,7 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
import { getCreditPackages } from '@/config/credits-config';
|
||||
import { useCreditPackages } from '@/config/credits-config';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { useCurrentUser } from '@/hooks/use-current-user';
|
||||
import { useCurrentPlan } from '@/hooks/use-payment';
|
||||
@ -38,7 +38,7 @@ export function CreditPackages() {
|
||||
|
||||
// Get credit packages with translations - must be called here to maintain hook order
|
||||
// This function contains useTranslations hook, so it must be called before any conditional returns
|
||||
const creditPackages = Object.values(getCreditPackages()).filter(
|
||||
const creditPackages = Object.values(useCreditPackages()).filter(
|
||||
(pkg) => !pkg.disabled && pkg.price.priceId
|
||||
);
|
||||
|
||||
|
@ -16,7 +16,7 @@ import { websiteConfig } from './website';
|
||||
*
|
||||
* @returns The credit packages with translated content
|
||||
*/
|
||||
export function getCreditPackages(): Record<string, CreditPackage> {
|
||||
export function useCreditPackages(): Record<string, CreditPackage> {
|
||||
const t = useTranslations('CreditPackages');
|
||||
const creditConfig = websiteConfig.credits;
|
||||
const packages: Record<string, CreditPackage> = {};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getCreditPackages } from '@/config/credits-config';
|
||||
import { useCreditPackages } from '@/config/credits-config';
|
||||
import type { CreditPackage } from './types';
|
||||
|
||||
/**
|
||||
@ -6,7 +6,7 @@ import type { CreditPackage } from './types';
|
||||
* @returns Credit packages
|
||||
*/
|
||||
export function getCreditPackagesInClient(): CreditPackage[] {
|
||||
return Object.values(getCreditPackages());
|
||||
return Object.values(useCreditPackages());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user