mirror of
https://github.com/vercel/commerce.git
synced 2025-03-14 22:42:33 +00:00
Progress
This commit is contained in:
parent
d03df631ce
commit
017218c155
@ -15,13 +15,14 @@ const CartSidebarView: FC = () => {
|
||||
|
||||
const { price: subTotal } = usePrice(
|
||||
data && {
|
||||
amount: data.base_amount,
|
||||
amount: data.subTotal,
|
||||
currencyCode: data.currency?.code || 'USD',
|
||||
}
|
||||
)
|
||||
|
||||
const { price: total } = usePrice(
|
||||
data && {
|
||||
amount: data.cart_amount,
|
||||
amount: data.total,
|
||||
currencyCode: data.currency?.code || 'USD',
|
||||
}
|
||||
)
|
||||
|
@ -75,10 +75,12 @@ export function normalizeProduct(productNode: any): Product {
|
||||
})
|
||||
}
|
||||
|
||||
export function normalizeCart(cart: any): Cart {
|
||||
return update(cart, {
|
||||
export function normalizeCart(data: any): Cart {
|
||||
return update(data, {
|
||||
$auto: {
|
||||
products: { $set: cart?.line_items?.physical_items?.map(itemsToProducts)}
|
||||
products: { $set: data?.line_items?.physical_items?.map(itemsToProducts)},
|
||||
subTotal: { $set: data.base_amount },
|
||||
total: { $set: data.cart_amount }
|
||||
},
|
||||
$unset: ['created_time', 'coupons', 'line_items']
|
||||
})
|
||||
|
3
framework/types.d.ts
vendored
3
framework/types.d.ts
vendored
@ -49,8 +49,9 @@ interface Cart extends Entity {
|
||||
id: string | undefined
|
||||
currency: { code: string }
|
||||
taxIncluded?: boolean
|
||||
totalAmmount: number | string
|
||||
products: Pick<Product, 'id' | 'name' | 'prices'> & CartItem[]
|
||||
subTotal: number | string
|
||||
total: number | string
|
||||
}
|
||||
|
||||
interface CartItem extends Entity {
|
||||
|
Loading…
x
Reference in New Issue
Block a user