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();