diff options
| author | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-26 17:07:40 +0700 |
|---|---|---|
| committer | Rafi Zadanly <rafizadanly@gmail.com> | 2022-12-26 17:07:40 +0700 |
| commit | 1e12cbcedbb8eaf52982cef89e35a29b0e555537 (patch) | |
| tree | 8409ab9f0606491ac7d3b8d4d5bbc8a40fccd90f /src/helpers | |
| parent | f2dad674f9096ca2423cbbdc0228576f094f064c (diff) | |
save state cart to process
Diffstat (limited to 'src/helpers')
| -rw-r--r-- | src/helpers/apiOdoo.js | 2 | ||||
| -rw-r--r-- | src/helpers/cart.js | 9 |
2 files changed, 3 insertions, 8 deletions
diff --git a/src/helpers/apiOdoo.js b/src/helpers/apiOdoo.js index 8009a302..22fd1920 100644 --- a/src/helpers/apiOdoo.js +++ b/src/helpers/apiOdoo.js @@ -27,7 +27,7 @@ const apiOdoo = async (method, url, data = {}, headers = {}) => { if (Object.keys(data).length > 0) axiosParameter.data = new URLSearchParams(Object.entries(data)).toString(); let res = await axios(axiosParameter); - if (res.data.status.code == 401 && connectionTry <= 3) { + if (res.data.status.code == 401 && connectionTry < 15) { await renewToken(); return apiOdoo(method, url, data, headers); } diff --git a/src/helpers/cart.js b/src/helpers/cart.js index 8712c03a..2cd8da7b 100644 --- a/src/helpers/cart.js +++ b/src/helpers/cart.js @@ -14,14 +14,9 @@ const getItemCart = (product_id) => { return cart[product_id]; } -const createOrUpdateItemCart = (product_id, quantity) => { +const createOrUpdateItemCart = (product_id, quantity, to_process = false) => { let cart = getCart(); - let isFoundInCart = cart[product_id]; - if (isFoundInCart) { - cart[product_id].quantity = quantity; - } else { - cart[product_id] = { product_id, quantity }; - } + cart[product_id] = { product_id, quantity, to_process }; setCart(cart); return true; } |
