mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
29 lines
721 B
TypeScript
29 lines
721 B
TypeScript
import type { WishlistItemBody } from '../../types/wishlist'
|
|
import type { CartItemBody, SelectedOption } from '../../types/cart'
|
|
|
|
type BCWishlistItemBody = {
|
|
product_id: number
|
|
variant_id: number
|
|
}
|
|
|
|
type BCCartItemBody = {
|
|
product_id: number
|
|
variant_id: number
|
|
quantity?: number
|
|
option_selections?: SelectedOption[]
|
|
}
|
|
|
|
export const parseWishlistItem = (
|
|
item: WishlistItemBody
|
|
): BCWishlistItemBody => ({
|
|
product_id: Number(item.productId),
|
|
variant_id: Number(item.variantId),
|
|
})
|
|
|
|
export const parseCartItem = (item: CartItemBody): BCCartItemBody => ({
|
|
quantity: item.quantity,
|
|
product_id: Number(item.productId),
|
|
variant_id: Number(item.variantId),
|
|
option_selections: item.optionsSelected,
|
|
})
|