fix: some minor fixes

This commit is contained in:
Victor Gerbrands 2023-05-05 12:57:50 +02:00
parent cce421c418
commit 2e1ca6eabc
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { isEmpty } from '../utils';
import { MedusaProductVariant, RegionInfo } from './types';
import { MedusaProductVariant, Money, RegionInfo } from './types';
type ComputeAmountParams = {
amount: number;
@ -20,7 +20,10 @@ export const computeAmount = ({ amount, region, includeTaxes = true }: ComputeAm
return amountWithTaxes;
};
export const calculateVariantAmount = (variant: MedusaProductVariant) => {
/**
* Takes a product variant, and returns the amount as a decimal including or excluding taxes and the currency code
*/
export const calculateVariantAmount = (variant: MedusaProductVariant): Money => {
const currencyCode = variant.prices?.[0]?.currency_code ?? 'USD';
const amount = convertToDecimal(variant.prices?.[0]?.amount || 0, currencyCode).toString();
return {

View File

@ -414,10 +414,7 @@ export type CartItem = MedusaLineItem & {
title: string;
};
cost: {
totalAmount: {
amount: string;
currencyCode: string;
};
totalAmount: Money;
};
quantity: number;
};