From b079873c50fbe18c9d5e7d2a791ae98ee623a8e9 Mon Sep 17 00:00:00 2001 From: Nastya Date: Sun, 17 Sep 2023 02:54:46 +0300 Subject: [PATCH] =?UTF-8?q?fix=20=D0=BF=D1=80=D0=B8=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D0=B7=D0=B8=D0=BD=D1=83=20=D1=82=D0=B0=D1=80=D0=B8?= =?UTF-8?q?=D1=84=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B0=D0=B5=D0=BC?= =?UTF-8?q?=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F=20=D0=B2?= =?UTF-8?q?=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=20=D0=B0=D0=B9=D0=B4=D0=B8=D1=88=D0=BD=D0=B8=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/cart.ts | 8 ++++---- src/stores/user.ts | 1 + src/utils/hooks/useCart.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/cart.ts b/src/api/cart.ts index f41400d..1c7e03c 100644 --- a/src/api/cart.ts +++ b/src/api/cart.ts @@ -11,13 +11,13 @@ export async function patchCart( tariffId: string ): Promise<[string[], string?]> { try { - const patchCartResponse = await makeRequest({ + const patchCartResponse = await makeRequest({ url: apiUrl + `/cart?id=${tariffId}`, method: "PATCH", useToken: true, }); - return [patchCartResponse]; + return [patchCartResponse.cart]; } catch (nativeError) { const [error] = parseAxiosError(nativeError); @@ -29,13 +29,13 @@ export async function deleteCart( tariffId: string ): Promise<[string[], string?]> { try { - const deleteCartResponse = await makeRequest({ + const deleteCartResponse = await makeRequest({ url: apiUrl + `/cart?id=${tariffId}`, method: "DELETE", useToken: true, }); - return [deleteCartResponse]; + return [deleteCartResponse.cart]; } catch (nativeError) { const [error] = parseAxiosError(nativeError); diff --git a/src/stores/user.ts b/src/stores/user.ts index d9cf619..fb50ade 100644 --- a/src/stores/user.ts +++ b/src/stores/user.ts @@ -277,6 +277,7 @@ export const sendUserData = async () => { export const addTariffToCart = async (tariffId: string) => { const [patchCartResponse, patchCartError] = await patchCart(tariffId); + console.log(patchCartResponse) if (!patchCartError) { setCart(patchCartResponse); diff --git a/src/utils/hooks/useCart.ts b/src/utils/hooks/useCart.ts index d5cb144..8b37bd3 100644 --- a/src/utils/hooks/useCart.ts +++ b/src/utils/hooks/useCart.ts @@ -25,6 +25,7 @@ export function useCart() { function addTariffsToCart() { const knownTariffs: Tariff[] = []; + console.log(cartTariffIds) cartTariffIds?.forEach(async (tariffId) => { if (typeof cartTariffMap[tariffId] === "object") return;