From f7c96a0258afed4b94bb6c21dce7aa6d8f49de15 Mon Sep 17 00:00:00 2001 From: PhuocNTB Date: Thu, 9 Oct 2025 08:54:05 +0700 Subject: [PATCH] temp --- db.json | 8 ++++++++ src/apis/core/cart.api.ts | 9 +++++++++ src/apis/index.ts | 4 +++- src/types/cart.type.ts | 6 ++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/apis/core/cart.api.ts create mode 100644 src/types/cart.type.ts diff --git a/db.json b/db.json index 8529753..b76da92 100644 --- a/db.json +++ b/db.json @@ -176,5 +176,13 @@ "des": "

This is the initial content of the editor.

\n

", "isActive": true } + ], + "carts": [ + { + "id": "a", + "userId": "1", + "productId": "aaa", + "quantity": 10 + } ] } \ No newline at end of file diff --git a/src/apis/core/cart.api.ts b/src/apis/core/cart.api.ts new file mode 100644 index 0000000..5fb8134 --- /dev/null +++ b/src/apis/core/cart.api.ts @@ -0,0 +1,9 @@ +import axios from "axios"; + + +export const CartApi = { + getCartByUserId: async (userId: string) => { + let result = await axios.get(`${import.meta.env.VITE_SV_HOST}/carts?userId=${userId}`) + return result.data + } +} \ No newline at end of file diff --git a/src/apis/index.ts b/src/apis/index.ts index 8986f42..a91c4c8 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -1,3 +1,4 @@ +import { CartApi } from "./core/cart.api"; import { CategoryApi } from "./core/category.api"; import { CloudianryApi } from "./core/cloudinary.api"; import { ProductApi } from "./core/product.api"; @@ -7,5 +8,6 @@ export const Apis = { user: UserApi, category: CategoryApi, cloundInary: CloudianryApi, - product: ProductApi + product: ProductApi, + cart: CartApi } \ No newline at end of file diff --git a/src/types/cart.type.ts b/src/types/cart.type.ts new file mode 100644 index 0000000..99ce726 --- /dev/null +++ b/src/types/cart.type.ts @@ -0,0 +1,6 @@ +export interface CartItem { + id: string; + userId: string; + productId: string; + quantity: number +} \ No newline at end of file