diff --git a/src/api/account.ts b/src/api/account.ts index 3548446..05e9c9a 100644 --- a/src/api/account.ts +++ b/src/api/account.ts @@ -30,13 +30,13 @@ export type Account = { wallet: Wallet; }; -const API_URL = process.env.REACT_APP_DOMAIN + "/customer"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/customer`; export const getAccountInfo = async (id: string): Promise<[Account | null, string?]> => { try { const accountInfoResponse = await makeRequest({ - url: `${API_URL}/account/${id}`, method: "GET", + url: `${API_URL}/account/${id}`, useToken: true, }); @@ -48,13 +48,13 @@ export const getAccountInfo = async (id: string): Promise<[Account | null, strin } }; -export const editAccount = async (userId: string, status: "org" | "nko"): Promise<[unknown | null, string?]> => { +export const editAccount = async (userId: string, status: "org" | "nko"): Promise<[Account | null, string?]> => { try { - const editResponse = await makeRequest<{ status: "org" | "nko" }, unknown>({ - method: "patch", - useToken: true, + const editResponse = await makeRequest<{ status: "org" | "nko" }, Account>({ + method: "PATCH", url: `${API_URL}/account/${userId}`, body: { status }, + useToken: true, }); return [editResponse]; diff --git a/src/api/auth.ts b/src/api/auth.ts index 7612c99..a5d129a 100644 --- a/src/api/auth.ts +++ b/src/api/auth.ts @@ -4,12 +4,12 @@ import { parseAxiosError } from "@root/utils/parse-error"; import type { LoginRequest, RegisterRequest, RegisterResponse } from "@frontend/kitui"; -const baseUrl = process.env.REACT_APP_DOMAIN + "/auth"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/auth`; export const signin = async (login: string, password: string): Promise<[RegisterResponse | null, string?]> => { try { const signinResponse = await makeRequest({ - url: baseUrl + "/login", + url: `${API_URL}/login`, body: { login, password }, useToken: false, }); @@ -29,7 +29,7 @@ export const register = async ( ): Promise<[RegisterResponse | null, string?]> => { try { const registerResponse = await makeRequest({ - url: baseUrl + "/register", + url: `${API_URL}/register`, body: { login, password, phoneNumber }, useToken: false, }); @@ -42,11 +42,11 @@ export const register = async ( } }; -export const logout = async (): Promise<[unknown, string?]> => { +export const logout = async (): Promise<[unknown | null, string?]> => { try { const logoutResponse = await makeRequest({ - url: baseUrl + "/logout", - method: "post", + method: "POST", + url: `${API_URL}/logout`, contentType: true, }); diff --git a/src/api/discounts.ts b/src/api/discounts.ts index 2f4e00d..902f0c4 100644 --- a/src/api/discounts.ts +++ b/src/api/discounts.ts @@ -7,7 +7,7 @@ import type { CreateDiscountBody, DiscountType, GetDiscountResponse } from "@roo import useSWR from "swr"; import { enqueueSnackbar } from "notistack"; -const baseUrl = process.env.REACT_APP_DOMAIN + "/price"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/price`; interface CreateDiscountParams { purchasesAmount: number; @@ -108,10 +108,10 @@ export function createDiscountObject({ export const changeDiscount = async (discountId: string, discount: Discount): Promise<[unknown, string?]> => { try { const changeDiscountResponse = await makeRequest({ - url: baseUrl + "/discount/" + discountId, - method: "patch", - useToken: true, + method: "PATCH", + url: `${API_URL}/discount/${discountId}`, body: discount, + useToken: true, }); return [changeDiscountResponse]; @@ -127,10 +127,10 @@ export const createDiscount = async (discountParams: CreateDiscountParams): Prom try { const createdDiscountResponse = await makeRequest({ - url: baseUrl + "/discount", - method: "post", - useToken: true, + method: "POST", + url: `${API_URL}/discount`, body: discount, + useToken: true, }); return [createdDiscountResponse]; @@ -144,8 +144,8 @@ export const createDiscount = async (discountParams: CreateDiscountParams): Prom export const deleteDiscount = async (discountId: string): Promise<[Discount | null, string?]> => { try { const deleteDiscountResponse = await makeRequest({ - url: baseUrl + "/discount/" + discountId, - method: "delete", + method: "DELETE", + url: `${API_URL}/discount/${discountId}`, useToken: true, }); @@ -165,10 +165,10 @@ export const patchDiscount = async ( try { const patchDiscountResponse = await makeRequest({ - url: baseUrl + "/discount/" + discountId, - method: "patch", - useToken: true, + method: "PATCH", + url: `${API_URL}/discount/${discountId}`, body: discount, + useToken: true, }); return [patchDiscountResponse]; @@ -182,8 +182,8 @@ export const patchDiscount = async ( export const requestDiscounts = async (): Promise<[GetDiscountResponse | null, string?]> => { try { const discountsResponse = await makeRequest({ - url: baseUrl + "/discounts", - method: "get", + method: "GET", + url: `${API_URL}/discounts`, useToken: true, }); @@ -198,8 +198,8 @@ export const requestDiscounts = async (): Promise<[GetDiscountResponse | null, s async function getDiscounts() { try { const discountsResponse = await makeRequest({ - url: baseUrl + "/discounts", - method: "get", + method: "GET", + url: `${API_URL}/discounts`, useToken: true, }); diff --git a/src/api/history/requests.ts b/src/api/history/requests.ts index c3ed448..bd9ecae 100644 --- a/src/api/history/requests.ts +++ b/src/api/history/requests.ts @@ -23,13 +23,13 @@ type HistoryResponse = { totalPages: number; }; -const baseUrl = process.env.REACT_APP_DOMAIN + "/customer"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/customer`; const getUserHistory = async (accountId: string, page: number): Promise<[HistoryResponse | null, string?]> => { try { const historyResponse = await makeRequest({ method: "GET", - url: baseUrl + `/history?page=${page}&limit=${100}&accountID=${accountId}&type=payCart`, + url: `${API_URL}/history?page=${page}&limit=${100}&accountID=${accountId}&type=payCart`, }); return [historyResponse]; diff --git a/src/api/privilegies.ts b/src/api/privilegies.ts index c67df33..a8817d6 100644 --- a/src/api/privilegies.ts +++ b/src/api/privilegies.ts @@ -11,13 +11,13 @@ type SeverPrivilegesResponse = { squiz: CustomPrivilege[]; }; -const baseUrl = process.env.REACT_APP_DOMAIN + "/strator"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/strator`; export const getRoles = async (): Promise<[TMockData | null, string?]> => { try { const rolesResponse = await makeRequest({ - method: "get", - url: baseUrl + "/role", + method: "GET", + url: `${API_URL}/role`, }); return [rolesResponse]; @@ -28,11 +28,13 @@ export const getRoles = async (): Promise<[TMockData | null, string?]> => { } }; -export const putPrivilege = async (body: Omit): Promise<[unknown, string?]> => { +export const putPrivilege = async ( + body: Omit +): Promise<[CustomPrivilege | null, string?]> => { try { - const putedPrivilege = await makeRequest, unknown>({ - url: baseUrl + "/privilege", - method: "put", + const putedPrivilege = await makeRequest, CustomPrivilege>({ + method: "PUT", + url: `${API_URL}/privilege`, body, }); @@ -47,8 +49,8 @@ export const putPrivilege = async (body: Omit): export const requestServicePrivileges = async (): Promise<[SeverPrivilegesResponse | null, string?]> => { try { const privilegesResponse = await makeRequest({ - url: baseUrl + "/privilege/service", - method: "get", + method: "GET", + url: `${API_URL}/privilege/service`, }); return [privilegesResponse]; @@ -62,8 +64,8 @@ export const requestServicePrivileges = async (): Promise<[SeverPrivilegesRespon export const requestPrivileges = async (signal: AbortSignal | undefined): Promise<[CustomPrivilege[], string?]> => { try { const privilegesResponse = await makeRequest({ - url: baseUrl + "/privilege", - method: "get", + method: "GET", + url: `${API_URL}/privilege`, useToken: true, signal, }); diff --git a/src/api/promocode/requests.ts b/src/api/promocode/requests.ts index 2be9e07..11afbc7 100644 --- a/src/api/promocode/requests.ts +++ b/src/api/promocode/requests.ts @@ -1,24 +1,30 @@ import makeRequest from "@root/api/makeRequest"; import type { - CreatePromocodeBody, + CreatePromocodeBody, EditPromocodeBody, - GetPromocodeListBody, - Promocode, - PromocodeList, - PromocodeStatistics, + GetPromocodeListBody, + Promocode, + PromocodeList, + PromocodeStatistics, } from "@root/model/promocodes"; import { parseAxiosError } from "@root/utils/parse-error"; import { isAxiosError } from "axios"; -const baseUrl = process.env.REACT_APP_DOMAIN + "/codeword/promocode"; +type PromocodeStatisticsBody = { + id: string; + from: number; + to: number; +}; + +const API_URL = `${process.env.REACT_APP_DOMAIN}/codeword/promocode`; const getPromocodeList = async (body: GetPromocodeListBody) => { try { const promocodeListResponse = await makeRequest({ - url: baseUrl + "/getList", method: "POST", + url: `${API_URL}/getList`, body, useToken: false, }); @@ -32,7 +38,7 @@ const getPromocodeList = async (body: GetPromocodeListBody) => { const createFastlink = async (id: string) => { try { return await makeRequest<{ id: string }, { fastlink: string }>({ - url: baseUrl + "/fastlink", + url: `${API_URL}/fastlink`, method: "POST", body: { id }, }); @@ -70,37 +76,37 @@ export const getAllPromocodes = async () => { }; export const getNotActivePromocodes = async () => { - try { - const promocodes: Promocode[] = []; + try { + const promocodes: Promocode[] = []; - let page = 0; - while (true) { - const promocodeList = await getPromocodeList({ - limit: 100, - filter: { - active: false, - }, - page, - }); + let page = 0; + while (true) { + const promocodeList = await getPromocodeList({ + limit: 100, + filter: { + active: false, + }, + page, + }); - if (promocodeList.items.length === 0) break; + if (promocodeList.items.length === 0) break; - promocodes.push(...promocodeList.items); - page++; - } + promocodes.push(...promocodeList.items); + page++; + } - return promocodes; - } catch (nativeError) { - const [error] = parseAxiosError(nativeError); - throw new Error(`Ошибка при получении списка промокодов. ${error}`); - } + return promocodes; + } catch (nativeError) { + const [error] = parseAxiosError(nativeError); + throw new Error(`Ошибка при получении списка промокодов. ${error}`); + } }; const createPromocode = async (body: CreatePromocodeBody) => { try { const createPromocodeResponse = await makeRequest({ - url: baseUrl + "/create", method: "POST", + url: `${API_URL}/create`, body, useToken: false, }); @@ -117,24 +123,24 @@ const createPromocode = async (body: CreatePromocodeBody) => { }; const editPromocode = async (body: EditPromocodeBody) => { - try { - const editPromocodeResponse = await makeRequest({ - url: process.env.REACT_APP_DOMAIN + "/codeword/promocode" + "/edit", - method: "PUT", - body, - }); - return [editPromocodeResponse]; - } catch (nativeError) { - const [error] = parseAxiosError(nativeError); - return [null, `Ошибка редактирования промокода. ${error}`]; - } + try { + const editPromocodeResponse = await makeRequest({ + method: "PUT", + url: `${API_URL}/codeword/promocode/edit`, + body, + }); + return [editPromocodeResponse]; + } catch (nativeError) { + const [error] = parseAxiosError(nativeError); + return [null, `Ошибка редактирования промокода. ${error}`]; + } }; const deletePromocode = async (id: string): Promise => { try { await makeRequest({ - url: `${baseUrl}/${id}`, method: "DELETE", + url: `${API_URL}/${id}`, useToken: false, }); } catch (nativeError) { @@ -145,14 +151,10 @@ const deletePromocode = async (id: string): Promise => { const getPromocodeStatistics = async (id: string, from: number, to: number) => { try { - const promocodeStatisticsResponse = await makeRequest({ - url: baseUrl + `/stats`, - body: { - id: id, - from: from, - to: to, - }, + const promocodeStatisticsResponse = await makeRequest({ method: "POST", + url: `${API_URL}/stats`, + body: { id, from, to }, useToken: false, }); return promocodeStatisticsResponse; @@ -163,12 +165,12 @@ const getPromocodeStatistics = async (id: string, from: number, to: number) => { }; export const promocodeApi = { - getPromocodeList, - createPromocode, - editPromocode, - deletePromocode, - getAllPromocodes, - getNotActivePromocodes, - getPromocodeStatistics, - createFastlink, + getPromocodeList, + createPromocode, + editPromocode, + deletePromocode, + getAllPromocodes, + getNotActivePromocodes, + getPromocodeStatistics, + createFastlink, }; diff --git a/src/api/quiz.ts b/src/api/quiz.ts index b4064a3..8f88959 100644 --- a/src/api/quiz.ts +++ b/src/api/quiz.ts @@ -9,10 +9,10 @@ type MoveQuizBody = { AccountID: string; }; -export const moveQuiz = async (quizId: string, userId: string): Promise<[unknown | null, string?]> => { +export const moveQuiz = async (quizId: string, userId: string): Promise<[string | null, string?]> => { try { - const moveResponse = await makeRequest({ - method: "post", + const moveResponse = await makeRequest({ + method: "POST", url: `${API_URL}/move`, body: { Qid: quizId, AccountID: userId }, }); diff --git a/src/api/quizStatistics/index.ts b/src/api/quizStatistics/index.ts index 13cec85..c2d1d04 100644 --- a/src/api/quizStatistics/index.ts +++ b/src/api/quizStatistics/index.ts @@ -18,10 +18,12 @@ type TRequest = { from: number; }; +const API_URL = process.env.REACT_APP_DOMAIN; + export const getStatistic = async (to: number, from: number): Promise => { try { const generalResponse = await makeRequest({ - url: `${process.env.REACT_APP_DOMAIN}/squiz/statistic`, + url: `${API_URL}/squiz/statistic`, body: { to, from }, }); return generalResponse; @@ -32,18 +34,18 @@ export const getStatistic = async (to: number, from: number): Promise => { try { - const StatisticResponse = await makeRequest({ - url: process.env.REACT_APP_DOMAIN + "/customer/quizlogo/stat", - method: "post", - useToken: true, + const statisticResponse = await makeRequest({ + method: "POST", + url: `${API_URL}/customer/quizlogo/stat`, body: { to, from, page: 0, limit: 100 }, + useToken: true, }); - if (!StatisticResponse) { + if (!statisticResponse) { throw new Error("Статистика не найдена"); } - return StatisticResponse; + return statisticResponse; } catch (nativeError) { return [ { @@ -56,19 +58,19 @@ export const getStatisticSchild = async (from: number, to: number): Promise> => { try { - const StatisticPromo = await makeRequest>({ - url: process.env.REACT_APP_DOMAIN + "/customer/promocode/ltv", - method: "post", - useToken: true, + const statisticsPromocode = await makeRequest>({ + method: "POST", + url: `${API_URL}/customer/promocode/ltv`, body: { to, from }, + useToken: true, }); - return StatisticPromo; + return statisticsPromocode; } catch (nativeError) { console.log(nativeError); diff --git a/src/api/roles.ts b/src/api/roles.ts index a99c242..e79dc51 100644 --- a/src/api/roles.ts +++ b/src/api/roles.ts @@ -35,7 +35,7 @@ export type UserType = { updatedAt: string; }; -const baseUrl = process.env.REACT_APP_DOMAIN + "/role"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/role`; export const getRoles_mock = (): Promise => { return new Promise((resolve) => { @@ -48,8 +48,8 @@ export const getRoles_mock = (): Promise => { export const deleteRole = async (id: string): Promise<[unknown, string?]> => { try { const deleteRoleResponse = await makeRequest({ - url: `${baseUrl}/${id}`, - method: "delete", + method: "DELETE", + url: `${API_URL}/${id}`, }); return [deleteRoleResponse]; diff --git a/src/api/tariffs.ts b/src/api/tariffs.ts index a8a0926..7411736 100644 --- a/src/api/tariffs.ts +++ b/src/api/tariffs.ts @@ -20,13 +20,13 @@ type GetTariffsResponse = { tariffs: Tariff[]; }; -const baseUrl = process.env.REACT_APP_DOMAIN + "/strator"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/strator`; -export const createTariff = async (body: CreateTariffBackendRequest): Promise<[unknown, string?]> => { +export const createTariff = async (body: CreateTariffBackendRequest): Promise<[Tariff | null, string?]> => { try { - const createdTariffResponse = await makeRequest({ - url: baseUrl + "/tariff/", - method: "post", + const createdTariffResponse = await makeRequest({ + method: "POST", + url: `${API_URL}/tariff/`, body, }); @@ -38,11 +38,11 @@ export const createTariff = async (body: CreateTariffBackendRequest): Promise<[u } }; -export const putTariff = async (tariff: Tariff): Promise<[null, string?]> => { +export const putTariff = async (tariff: Tariff): Promise<[Tariff | null, string?]> => { try { - const putedTariffResponse = await makeRequest({ - method: "put", - url: baseUrl + `/tariff/${tariff._id}`, + const putedTariffResponse = await makeRequest({ + method: "PUT", + url: `${API_URL}/tariff/${tariff._id}`, body: { name: tariff.name, price: tariff.price ?? 0, @@ -64,8 +64,8 @@ export const putTariff = async (tariff: Tariff): Promise<[null, string?]> => { export const deleteTariff = async (tariffId: string): Promise<[Tariff | null, string?]> => { try { const deletedTariffResponse = await makeRequest<{ id: string }, Tariff>({ - method: "delete", - url: baseUrl + "/tariff", + method: "DELETE", + url: `${API_URL}/tariff`, body: { id: tariffId }, }); @@ -80,8 +80,8 @@ export const deleteTariff = async (tariffId: string): Promise<[Tariff | null, st export const requestTariffs = async (page: number): Promise<[GetTariffsResponse | null, string?]> => { try { const tariffsResponse = await makeRequest({ - url: baseUrl + `/tariff/?page=${page}&limit=${100}`, - method: "get", + method: "GET", + url: `${API_URL}/tariff/?page=${page}&limit=${100}`, }); return [tariffsResponse]; diff --git a/src/api/tickets.ts b/src/api/tickets.ts index d7ca441..95dfbc3 100644 --- a/src/api/tickets.ts +++ b/src/api/tickets.ts @@ -4,15 +4,23 @@ import { parseAxiosError } from "@root/utils/parse-error"; import type { SendTicketMessageRequest } from "@root/model/ticket"; -const API_URL = process.env.REACT_APP_DOMAIN + "/heruvym"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/heruvym`; -export const sendTicketMessage = async (body: SendTicketMessageRequest): Promise<[unknown, string?]> => { +type CloseTicketBody = { + ticket: string; +}; + +type SendFileResponse = { + message: string; +}; + +export const sendTicketMessage = async (body: SendTicketMessageRequest): Promise<[null, string?]> => { try { - const sendTicketMessageResponse = await makeRequest({ - url: `${API_URL}/send`, + const sendTicketMessageResponse = await makeRequest({ method: "POST", - useToken: true, + url: `${API_URL}/send`, body, + useToken: true, }); return [sendTicketMessageResponse]; @@ -23,13 +31,13 @@ export const sendTicketMessage = async (body: SendTicketMessageRequest): Promise } }; -export const closeTicket = async (ticketId: string): Promise<[unknown, string?]> => { +export const closeTicket = async (ticketId: string): Promise<[CloseTicketBody | null, string?]> => { try { - const ticketCloseResponse = await makeRequest({ + const ticketCloseResponse = await makeRequest({ + method: "POST", url: `${API_URL}/close`, - method: "post", - useToken: true, body: { ticket: ticketId }, + useToken: true, }); return [ticketCloseResponse]; @@ -40,13 +48,13 @@ export const closeTicket = async (ticketId: string): Promise<[unknown, string?]> } }; -export const sendFile = async (file: File, ticketId: string): Promise<[unknown | null, string?]> => { +export const sendFile = async (file: File, ticketId: string): Promise<[SendFileResponse | null, string?]> => { try { const body = new FormData(); body.append(file.name, file); body.append("ticket", ticketId); - const sendFileRespose = await makeRequest({ + const sendFileRespose = await makeRequest({ method: "POST", url: `${API_URL}/sendFiles`, body, diff --git a/src/api/user/requests.ts b/src/api/user/requests.ts index 42a2a33..408256b 100644 --- a/src/api/user/requests.ts +++ b/src/api/user/requests.ts @@ -9,13 +9,13 @@ export type UsersListResponse = { users: UserType[]; }; -const baseUrl = process.env.REACT_APP_DOMAIN + "/user"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/user`; const getUserInfo = async (id: string): Promise<[UserType | null, string?]> => { try { const userInfoResponse = await makeRequest({ - url: `${baseUrl}/${id}`, method: "GET", + url: `${API_URL}/${id}`, useToken: true, }); @@ -30,8 +30,8 @@ const getUserInfo = async (id: string): Promise<[UserType | null, string?]> => { const getUserList = async (page = 1, limit = 10): Promise<[UsersListResponse | null, string?]> => { try { const userResponse = await makeRequest({ - method: "get", - url: baseUrl + `/?page=${page}&limit=${limit}`, + method: "GET", + url: `${API_URL}/?page=${page}&limit=${limit}`, }); return [userResponse]; @@ -45,8 +45,8 @@ const getUserList = async (page = 1, limit = 10): Promise<[UsersListResponse | n const getManagerList = async (page = 1, limit = 10): Promise<[UsersListResponse | null, string?]> => { try { const managerResponse = await makeRequest({ - method: "get", - url: baseUrl + `/?page=${page}&limit=${limit}`, + method: "GET", + url: `${API_URL}/?page=${page}&limit=${limit}`, }); return [managerResponse]; @@ -60,8 +60,8 @@ const getManagerList = async (page = 1, limit = 10): Promise<[UsersListResponse const getAdminList = async (page = 1, limit = 10): Promise<[UsersListResponse | null, string?]> => { try { const adminResponse = await makeRequest({ - method: "get", - url: baseUrl + `/?page=${page}&limit=${limit}`, + method: "GET", + url: `${API_URL}/?page=${page}&limit=${limit}`, }); return [adminResponse]; diff --git a/src/api/verification.ts b/src/api/verification.ts index b1c39d8..7771059 100644 --- a/src/api/verification.ts +++ b/src/api/verification.ts @@ -25,13 +25,13 @@ type PatchVerificationBody = { taxnumber?: string; }; -const baseUrl = process.env.REACT_APP_DOMAIN + "/verification"; +const API_URL = `${process.env.REACT_APP_DOMAIN}/verification`; export const verification = async (userId: string): Promise<[Verification | null, string?]> => { try { const verificationResponse = await makeRequest({ - method: "get", - url: baseUrl + `/verification/${userId}`, + method: "GET", + url: `${API_URL}/verification/${userId}`, }); return [verificationResponse]; @@ -42,13 +42,13 @@ export const verification = async (userId: string): Promise<[Verification | null } }; -export const patchVerification = async (body: PatchVerificationBody): Promise<[unknown, string?]> => { +export const patchVerification = async (body: PatchVerificationBody): Promise<[string | null, string?]> => { try { - const patchedVerificationResponse = await makeRequest({ - method: "patch", - useToken: true, - url: baseUrl + `/verification`, + const patchedVerificationResponse = await makeRequest({ + method: "PATCH", + url: `${API_URL}/verification`, body, + useToken: true, }); return [patchedVerificationResponse]; diff --git a/src/pages/dashboard/ModalUser/VerificationTab.tsx b/src/pages/dashboard/ModalUser/VerificationTab.tsx index d8b6b55..789ca7a 100644 --- a/src/pages/dashboard/ModalUser/VerificationTab.tsx +++ b/src/pages/dashboard/ModalUser/VerificationTab.tsx @@ -54,7 +54,7 @@ export const VerificationTab = ({ userId }: VerificationTabProps) => { }, []); const verify = async (accepted: boolean) => { - if (!verificationInfo) { + if (!verificationInfo) { return; } diff --git a/src/utils/hooks/usePromocodeStatistics.ts b/src/utils/hooks/usePromocodeStatistics.ts index 52f81cd..b8a0f6b 100644 --- a/src/utils/hooks/usePromocodeStatistics.ts +++ b/src/utils/hooks/usePromocodeStatistics.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { getStatisticPromocode } from "@root/api/quizStatistics"; +import { getStatisticsPromocode } from "@root/api/quizStatistics"; import type { Moment } from "moment"; import type { AllPromocodeStatistics } from "@root/api/quizStatistics/types"; @@ -18,7 +18,7 @@ export function usePromocodeStatistics({ to, from }: useStatisticProps) { useEffect(() => { const requestStatistics = async () => { - const gottenData = await getStatisticPromocode(Number(formatFrom), Number(formatTo)); + const gottenData = await getStatisticsPromocode(Number(formatFrom), Number(formatTo)); setPromocodeStatistics(gottenData); };