diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-06-19 15:46:03 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-06-19 15:46:03 +0700 |
| commit | 637c22f1886cecf7307ced88dc951134d466a3fa (patch) | |
| tree | 7f00f63e13b3f5e56f3da06da1f98010937cd3cc /src/core/utils | |
| parent | e4b4f2c09ebd819acc204c2e58288fe9fc6294ea (diff) | |
checkout
Diffstat (limited to 'src/core/utils')
| -rw-r--r-- | src/core/utils/cart.js | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/core/utils/cart.js b/src/core/utils/cart.js index ad7894b5..6575f6d0 100644 --- a/src/core/utils/cart.js +++ b/src/core/utils/cart.js @@ -14,13 +14,6 @@ const getCart = () => { return {} } -const getCartnew = async () => { - const id = getAuth()?.id - const cart = await odooApi('GET', `/api/v1/user/${id}/cart`) - - return cart -} - /** * Saves cart data to localStorage, if available. * @@ -51,6 +44,22 @@ const addCart = async (product_id, qty, selected) => { ) } +const getCartApi = async () => { + const id = getAuth()?.id + const cart = await odooApi('GET', `/api/v1/user/${id}/cart`) + + return cart +} + +const getCountCart = async () => { + const id = getAuth()?.id + if(id){ + const cart = await odooApi('GET', `/api/v1/user/${id}/cart/count`) + return cart + } + return +} + const deleteCart = async (product_id) => { const id = getAuth()?.id const cartDelete = await odooApi( @@ -85,7 +94,7 @@ const updateItemCart = ({ productId, quantity, selected = false }) => { quantity = parseInt(quantity) cart[productId] = { productId, quantity, selected } setCart(cart) - addCart(productId, quantity) + addCart(productId, quantity, selected) return true } @@ -104,4 +113,4 @@ const deleteItemCart = ({ productId }) => { return true } -export { getCart, getItemCart, updateItemCart, deleteItemCart, getCartnew } +export { getCart, getItemCart, updateItemCart, deleteItemCart, addCart, getCartApi, getCountCart} |
