diff --git a/db.json b/db.json index ccc7a3b..f3d29c6 100644 --- a/db.json +++ b/db.json @@ -79,7 +79,7 @@ "id": "c06c", "productId": "d317", "userId": "1", - "quantity": 1 + "quantity": 2 } ] } \ No newline at end of file diff --git a/src/apis/core/cart.api.ts b/src/apis/core/cart.api.ts index 102731f..21b79bb 100644 --- a/src/apis/core/cart.api.ts +++ b/src/apis/core/cart.api.ts @@ -12,7 +12,6 @@ export const CartApi = { }, addToCart: async (data: AddToCartDTO) => { let resultExisted = await axios.get(`${import.meta.env.VITE_SV_HOST}/carts?productId=${data.productId}`) - console.log("resultExisted", resultExisted.data) if (!resultExisted.data[0]) { /* thêm mới */ await axios.post(`${import.meta.env.VITE_SV_HOST}/carts`, { @@ -28,6 +27,6 @@ export const CartApi = { quantity: resultExisted.data[0].quantity + 1 }) - console.log("resultUpdate", resultUpdate.data) + return true } } \ No newline at end of file diff --git a/src/pages/home/cart/Cart.tsx b/src/pages/home/cart/Cart.tsx index dc37455..950a7a8 100644 --- a/src/pages/home/cart/Cart.tsx +++ b/src/pages/home/cart/Cart.tsx @@ -2,11 +2,28 @@ import React from 'react' import { useSelector } from 'react-redux' import type { StoreType } from '../../../stores' import type { CartItem } from '../../../types/cart.type' +import { Apis } from '../../../apis' +import type { Product } from '../../../types/product.type' export default function Cart() { const userStore = useSelector((store: StoreType) => store.user) - + // + //đây là api lấy product id let data = Apis.product.findProductById(productId) + // data có interface là Product + // cho bạn interface product luôn + /* + export interface Product { + id: string; + categoryId: string; + price: number; + iconUrl: string; + isActive: boolean; + name: string; + des: string; +} + + */ return (