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
|
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
packages: Array.isArray(rows) ? rows : []
|
packages
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error getting token packages:', error);
|
console.error('Error getting token packages:', error);
|
||||||
|
|||||||
@ -176,7 +176,7 @@ export default function CustomTokenCalculator({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right">
|
<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">
|
<div className="text-sm text-gray-600 dark:text-gray-400">
|
||||||
{pkg.discount_percentage}% off
|
{pkg.discount_percentage}% off
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -186,10 +186,10 @@ export default function TokenPurchaseFlow({
|
|||||||
</div>
|
</div>
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
<div className="font-bold text-lg text-gray-900 dark:text-white">
|
<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>
|
||||||
<div className="text-sm text-gray-600 dark:text-gray-400">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user