mirror of
https://github.com/vercel/commerce.git
synced 2025-04-29 14:27:50 +00:00
Progress
This commit is contained in:
parent
d03df631ce
commit
017218c155
@ -15,13 +15,14 @@ const CartSidebarView: FC = () => {
|
|||||||
|
|
||||||
const { price: subTotal } = usePrice(
|
const { price: subTotal } = usePrice(
|
||||||
data && {
|
data && {
|
||||||
amount: data.base_amount,
|
amount: data.subTotal,
|
||||||
currencyCode: data.currency?.code || 'USD',
|
currencyCode: data.currency?.code || 'USD',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const { price: total } = usePrice(
|
const { price: total } = usePrice(
|
||||||
data && {
|
data && {
|
||||||
amount: data.cart_amount,
|
amount: data.total,
|
||||||
currencyCode: data.currency?.code || 'USD',
|
currencyCode: data.currency?.code || 'USD',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -75,10 +75,12 @@ export function normalizeProduct(productNode: any): Product {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeCart(cart: any): Cart {
|
export function normalizeCart(data: any): Cart {
|
||||||
return update(cart, {
|
return update(data, {
|
||||||
$auto: {
|
$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']
|
$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
|
id: string | undefined
|
||||||
currency: { code: string }
|
currency: { code: string }
|
||||||
taxIncluded?: boolean
|
taxIncluded?: boolean
|
||||||
totalAmmount: number | string
|
|
||||||
products: Pick<Product, 'id' | 'name' | 'prices'> & CartItem[]
|
products: Pick<Product, 'id' | 'name' | 'prices'> & CartItem[]
|
||||||
|
subTotal: number | string
|
||||||
|
total: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CartItem extends Entity {
|
interface CartItem extends Entity {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user