Fix toFixed error by converting string prices to numbers
This commit is contained in:
parent
332016317a
commit
544854ec3f
@ -67,9 +67,18 @@ export class PaymentController {
|
||||
ORDER BY quantity ASC
|
||||
`);
|
||||
|
||||
// Convert decimal fields to numbers
|
||||
const packages = Array.isArray(rows) ? rows.map((pkg: any) => ({
|
||||
...pkg,
|
||||
total_price: Number(pkg.total_price),
|
||||
price_per_token: Number(pkg.price_per_token),
|
||||
discount_percentage: Number(pkg.discount_percentage),
|
||||
quantity: Number(pkg.quantity)
|
||||
})) : [];
|
||||
|
||||
return {
|
||||
success: true,
|
||||
packages: Array.isArray(rows) ? rows : []
|
||||
packages
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error getting token packages:', error);
|
||||
|
||||
@ -176,7 +176,7 @@ export default function CustomTokenCalculator({
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="font-medium">€{pkg.total_price.toFixed(2)}</div>
|
||||
<div className="font-medium">€{Number(pkg.total_price).toFixed(2)}</div>
|
||||
<div className="text-sm text-gray-600 dark:text-gray-400">
|
||||
{pkg.discount_percentage}% off
|
||||
</div>
|
||||
|
||||
@ -186,10 +186,10 @@ export default function TokenPurchaseFlow({
|
||||
</div>
|
||||
<div className="text-right">
|
||||
<div className="font-bold text-lg text-gray-900 dark:text-white">
|
||||
€{pkg.total_price.toFixed(2)}
|
||||
€{Number(pkg.total_price).toFixed(2)}
|
||||
</div>
|
||||
<div className="text-sm text-gray-600 dark:text-gray-400">
|
||||
€{pkg.price_per_token.toFixed(2)} per token
|
||||
€{Number(pkg.price_per_token).toFixed(2)} per token
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user