order
This commit is contained in:
@@ -2,12 +2,15 @@ import api from './api';
|
||||
|
||||
export interface CartItem {
|
||||
cartItemId: number;
|
||||
productId: number;
|
||||
productName: string;
|
||||
productImage: string;
|
||||
quantity: number;
|
||||
price: number;
|
||||
subtotal: number;
|
||||
|
||||
product: {
|
||||
productId: number;
|
||||
productName: string;
|
||||
price: number;
|
||||
imageUrl: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface CartResponse {
|
||||
@@ -43,12 +46,20 @@ const cartService = {
|
||||
|
||||
// Lấy danh sách sản phẩm trong giỏ hàng
|
||||
getCart: async (userId: number): Promise<CartResponse> => {
|
||||
console.log('=== GET CART REQUEST ===', { userId });
|
||||
const response = await api.get<CartResponse>(
|
||||
`/cart/${userId}`,
|
||||
{ requireAuth: true }
|
||||
);
|
||||
console.log('=== GET CART RESPONSE ===', response);
|
||||
|
||||
// MAP lại items để UI dùng dễ hơn
|
||||
response.items = response.items.map(item => ({
|
||||
...item,
|
||||
productName: item.product.productName,
|
||||
productImage: item.product.imageUrl,
|
||||
price: Number(item.product.price),
|
||||
subtotal: Number(item.subtotal),
|
||||
}));
|
||||
|
||||
return response;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user