refactor: update credit package descriptions and improve component structure
- Revised credit package descriptions in the English JSON file for clarity and consistency. - Refactored CreditPackages component to utilize a more efficient method for retrieving credit packages. - Removed obsolete functions and streamlined the code for better maintainability and performance.
This commit is contained in:
parent
e430a0c319
commit
73ce18f564
@ -114,19 +114,19 @@
|
|||||||
"CreditPackages": {
|
"CreditPackages": {
|
||||||
"basic": {
|
"basic": {
|
||||||
"name": "Basic",
|
"name": "Basic",
|
||||||
"description": "Basic features for personal use"
|
"description": "Basic credits package description"
|
||||||
},
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
"name": "Standard",
|
"name": "Standard",
|
||||||
"description": "Standard features for personal use"
|
"description": "Standard credits package description"
|
||||||
},
|
},
|
||||||
"premium": {
|
"premium": {
|
||||||
"name": "Premium",
|
"name": "Premium",
|
||||||
"description": "Premium features for personal use"
|
"description": "Premium credits package description"
|
||||||
},
|
},
|
||||||
"enterprise": {
|
"enterprise": {
|
||||||
"name": "Enterprise",
|
"name": "Enterprise",
|
||||||
"description": "Enterprise features for personal use"
|
"description": "Enterprise credits package description"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"NotFoundPage": {
|
"NotFoundPage": {
|
||||||
|
@ -19,10 +19,7 @@ import {
|
|||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/components/ui/dialog';
|
} from '@/components/ui/dialog';
|
||||||
import {
|
import { getCreditPackages } from '@/config/credits-config';
|
||||||
getCreditPackageByIdInClient,
|
|
||||||
getCreditPackagesInClient,
|
|
||||||
} from '@/credits/client';
|
|
||||||
import type { CreditPackage } from '@/credits/types';
|
import type { CreditPackage } from '@/credits/types';
|
||||||
import { formatPrice } from '@/lib/formatter';
|
import { formatPrice } from '@/lib/formatter';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
@ -33,6 +30,10 @@ import { useEffect, useState } from 'react';
|
|||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { StripePaymentForm } from './stripe-payment-form';
|
import { StripePaymentForm } from './stripe-payment-form';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Credit packages component
|
||||||
|
* @returns Credit packages component
|
||||||
|
*/
|
||||||
export function CreditPackages() {
|
export function CreditPackages() {
|
||||||
const t = useTranslations('Dashboard.settings.credits.packages');
|
const t = useTranslations('Dashboard.settings.credits.packages');
|
||||||
const [loadingCredits, setLoadingCredits] = useState(true);
|
const [loadingCredits, setLoadingCredits] = useState(true);
|
||||||
@ -50,6 +51,8 @@ export function CreditPackages() {
|
|||||||
clientSecret: null,
|
clientSecret: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const creditPackages = Object.values(getCreditPackages());
|
||||||
|
|
||||||
const fetchCredits = async () => {
|
const fetchCredits = async () => {
|
||||||
try {
|
try {
|
||||||
setLoadingCredits(true);
|
setLoadingCredits(true);
|
||||||
@ -122,7 +125,7 @@ export function CreditPackages() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getPackageInfo = (packageId: string): CreditPackage | undefined => {
|
const getPackageInfo = (packageId: string): CreditPackage | undefined => {
|
||||||
return getCreditPackageByIdInClient(packageId);
|
return creditPackages.find((pkg) => pkg.id === packageId);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -158,7 +161,7 @@ export function CreditPackages() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-4">
|
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-4">
|
||||||
{getCreditPackagesInClient().map((pkg) => (
|
{creditPackages.map((pkg) => (
|
||||||
<Card
|
<Card
|
||||||
key={pkg.id}
|
key={pkg.id}
|
||||||
className={cn(
|
className={cn(
|
||||||
@ -177,10 +180,6 @@ export function CreditPackages() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* <CardHeader className="text-center">
|
|
||||||
<CardTitle className="text-lg capitalize">{pkg.id}</CardTitle>
|
|
||||||
</CardHeader> */}
|
|
||||||
|
|
||||||
<CardContent className="space-y-3">
|
<CardContent className="space-y-3">
|
||||||
{/* Price and Credits - Left/Right Layout */}
|
{/* Price and Credits - Left/Right Layout */}
|
||||||
<div className="flex items-center justify-between py-2">
|
<div className="flex items-center justify-between py-2">
|
||||||
|
Loading…
Reference in New Issue
Block a user