From 937ac87c9dee7f1b2a6628d1fa585c77a317a7eb Mon Sep 17 00:00:00 2001 From: Nastya Date: Sat, 20 Jul 2024 16:19:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BC=D0=BE=D0=BA=D0=BE?= =?UTF-8?q?=D0=B4=D1=8B=20=D0=B7=D0=B0=D0=BF=D1=80=D0=B0=D1=88=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D1=81=20=D1=82=D0=BE=D0=BA?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=BC,=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=87=D0=BD=D1=8B=D0=B9=20=D1=86=D0=B8=D0=BA=D0=BB?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=BC=D0=BE=D0=BA=D0=BE=D0=B4=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/promocode/requests.ts | 12 +++++------- src/api/promocode/swr.ts | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/api/promocode/requests.ts b/src/api/promocode/requests.ts index c080076..829eac9 100644 --- a/src/api/promocode/requests.ts +++ b/src/api/promocode/requests.ts @@ -26,7 +26,6 @@ const getPromocodeList = async (body: GetPromocodeListBody): Promise<[PromocodeL method: "POST", url: `${API_URL}/getList`, body, - useToken: false, }); return [promocodeListResponse]; @@ -57,7 +56,7 @@ export const getAllPromocodes = async (): Promise<[Promocode[] | null, string?]> const promocodes: Promocode[] = []; let page = 0; - while (true) { + // while (true) { const [promocodeList] = await getPromocodeList({ limit: 100, filter: { @@ -67,12 +66,14 @@ export const getAllPromocodes = async (): Promise<[Promocode[] | null, string?]> }); if (promocodeList) { - if (promocodeList.items.length === 0) break; + // if (promocodeList.items.length === 0) break; + if (promocodeList.items.length > 0) { promocodes.push(...promocodeList.items); page++; + } } - } + // } return [promocodes]; } catch (nativeError) { @@ -118,7 +119,6 @@ const createPromocode = async (body: CreatePromocodeBody): Promise<[Promocode | method: "POST", url: `${API_URL}/create`, body, - useToken: false, }); return [createPromocodeResponse]; @@ -154,7 +154,6 @@ const deletePromocode = async (id: string): Promise<[null, string?]> => { await makeRequest({ method: "DELETE", url: `${API_URL}/${id}`, - useToken: false, }); return [null]; @@ -175,7 +174,6 @@ const getPromocodeStatistics = async ( method: "POST", url: `${API_URL}/stats`, body: { id, from, to }, - useToken: false, }); return [promocodeStatisticsResponse]; diff --git a/src/api/promocode/swr.ts b/src/api/promocode/swr.ts index 230113a..ab15c9d 100644 --- a/src/api/promocode/swr.ts +++ b/src/api/promocode/swr.ts @@ -180,7 +180,7 @@ export function usePromocodes( export function useAllPromocodes() { const { data } = useSwr( - "allPromocodes", + ["allPromocodes"], async () => { const [promocodes, promocodesError] = await promocodeApi.getAllPromocodes();