refactor: requests

This commit is contained in:
IlyaDoronin 2024-05-22 16:48:38 +03:00
parent dc23829a49
commit 2264fef8aa
15 changed files with 173 additions and 159 deletions

@ -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<never, Account>({
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];

@ -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<LoginRequest, RegisterResponse>({
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<RegisterRequest, RegisterResponse>({
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<never, unknown>({
url: baseUrl + "/logout",
method: "post",
method: "POST",
url: `${API_URL}/logout`,
contentType: true,
});

@ -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<Discount, unknown>({
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<CreateDiscountBody, Discount>({
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<never, Discount>({
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<CreateDiscountBody, Discount>({
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<never, GetDiscountResponse>({
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<never, GetDiscountResponse>({
url: baseUrl + "/discounts",
method: "get",
method: "GET",
url: `${API_URL}/discounts`,
useToken: true,
});

@ -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<never, HistoryResponse>({
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];

@ -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<never, TMockData>({
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<Privilege, "_id" | "updatedAt">): Promise<[unknown, string?]> => {
export const putPrivilege = async (
body: Omit<Privilege, "_id" | "updatedAt">
): Promise<[CustomPrivilege | null, string?]> => {
try {
const putedPrivilege = await makeRequest<Omit<Privilege, "_id" | "updatedAt">, unknown>({
url: baseUrl + "/privilege",
method: "put",
const putedPrivilege = await makeRequest<Omit<Privilege, "_id" | "updatedAt">, CustomPrivilege>({
method: "PUT",
url: `${API_URL}/privilege`,
body,
});
@ -47,8 +49,8 @@ export const putPrivilege = async (body: Omit<Privilege, "_id" | "updatedAt">):
export const requestServicePrivileges = async (): Promise<[SeverPrivilegesResponse | null, string?]> => {
try {
const privilegesResponse = await makeRequest<never, SeverPrivilegesResponse>({
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<never, CustomPrivilege[]>({
url: baseUrl + "/privilege",
method: "get",
method: "GET",
url: `${API_URL}/privilege`,
useToken: true,
signal,
});

@ -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<GetPromocodeListBody, PromocodeList>({
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<CreatePromocodeBody, Promocode>({
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<unknown, Promocode>({
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<EditPromocodeBody, Promocode>({
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<void> => {
try {
await makeRequest<never, never>({
url: `${baseUrl}/${id}`,
method: "DELETE",
url: `${API_URL}/${id}`,
useToken: false,
});
} catch (nativeError) {
@ -145,14 +151,10 @@ const deletePromocode = async (id: string): Promise<void> => {
const getPromocodeStatistics = async (id: string, from: number, to: number) => {
try {
const promocodeStatisticsResponse = await makeRequest<unknown, PromocodeStatistics>({
url: baseUrl + `/stats`,
body: {
id: id,
from: from,
to: to,
},
const promocodeStatisticsResponse = await makeRequest<PromocodeStatisticsBody, PromocodeStatistics>({
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,
};

@ -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<MoveQuizBody, unknown>({
method: "post",
const moveResponse = await makeRequest<MoveQuizBody, string>({
method: "POST",
url: `${API_URL}/move`,
body: { Qid: quizId, AccountID: userId },
});

@ -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<QuizStatisticResponse> => {
try {
const generalResponse = await makeRequest<TRequest, QuizStatisticResponse>({
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<QuizStatis
export const getStatisticSchild = async (from: number, to: number): Promise<QuizStatisticsItem[]> => {
try {
const StatisticResponse = await makeRequest<GetStatisticSchildBody, QuizStatisticsItem[]>({
url: process.env.REACT_APP_DOMAIN + "/customer/quizlogo/stat",
method: "post",
useToken: true,
const statisticResponse = await makeRequest<GetStatisticSchildBody, QuizStatisticsItem[]>({
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<Quiz
}
};
export const getStatisticPromocode = async (
export const getStatisticsPromocode = async (
from: number,
to: number
): Promise<Record<string, AllPromocodeStatistics>> => {
try {
const StatisticPromo = await makeRequest<GetPromocodeStatisticsBody, Record<string, AllPromocodeStatistics>>({
url: process.env.REACT_APP_DOMAIN + "/customer/promocode/ltv",
method: "post",
useToken: true,
const statisticsPromocode = await makeRequest<GetPromocodeStatisticsBody, Record<string, AllPromocodeStatistics>>({
method: "POST",
url: `${API_URL}/customer/promocode/ltv`,
body: { to, from },
useToken: true,
});
return StatisticPromo;
return statisticsPromocode;
} catch (nativeError) {
console.log(nativeError);

@ -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<TMockData> => {
return new Promise((resolve) => {
@ -48,8 +48,8 @@ export const getRoles_mock = (): Promise<TMockData> => {
export const deleteRole = async (id: string): Promise<[unknown, string?]> => {
try {
const deleteRoleResponse = await makeRequest<never, unknown>({
url: `${baseUrl}/${id}`,
method: "delete",
method: "DELETE",
url: `${API_URL}/${id}`,
});
return [deleteRoleResponse];

@ -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<CreateTariffBackendRequest>({
url: baseUrl + "/tariff/",
method: "post",
const createdTariffResponse = await makeRequest<CreateTariffBackendRequest, Tariff>({
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<EditTariffRequestBody, null>({
method: "put",
url: baseUrl + `/tariff/${tariff._id}`,
const putedTariffResponse = await makeRequest<EditTariffRequestBody, Tariff>({
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<never, GetTariffsResponse>({
url: baseUrl + `/tariff/?page=${page}&limit=${100}`,
method: "get",
method: "GET",
url: `${API_URL}/tariff/?page=${page}&limit=${100}`,
});
return [tariffsResponse];

@ -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<SendTicketMessageRequest, unknown>({
url: `${API_URL}/send`,
const sendTicketMessageResponse = await makeRequest<SendTicketMessageRequest, null>({
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<unknown, unknown>({
const ticketCloseResponse = await makeRequest<CloseTicketBody, CloseTicketBody>({
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<FormData, unknown>({
const sendFileRespose = await makeRequest<FormData, SendFileResponse>({
method: "POST",
url: `${API_URL}/sendFiles`,
body,

@ -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<never, UserType>({
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<never, UsersListResponse>({
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<never, UsersListResponse>({
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<never, UsersListResponse>({
method: "get",
url: baseUrl + `/?page=${page}&limit=${limit}`,
method: "GET",
url: `${API_URL}/?page=${page}&limit=${limit}`,
});
return [adminResponse];

@ -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<never, Verification>({
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<PatchVerificationBody, unknown>({
method: "patch",
useToken: true,
url: baseUrl + `/verification`,
const patchedVerificationResponse = await makeRequest<PatchVerificationBody, string>({
method: "PATCH",
url: `${API_URL}/verification`,
body,
useToken: true,
});
return [patchedVerificationResponse];

@ -54,7 +54,7 @@ export const VerificationTab = ({ userId }: VerificationTabProps) => {
}, []);
const verify = async (accepted: boolean) => {
if (!verificationInfo) {
if (!verificationInfo) {
return;
}

@ -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);
};