diff --git a/src/api/tariff.ts b/src/api/tariff.ts index a1b4ea3d..a0be6e70 100644 --- a/src/api/tariff.ts +++ b/src/api/tariff.ts @@ -12,7 +12,7 @@ export const getTariffs = async ( try { const tariffs = await makeRequest({ method: "GET", - url: `${API_URL}?page=${page}&limit=100`, + url: `${API_URL}/getList?page=${page}&limit=100`, }); return [tariffs]; } catch (nativeError) { diff --git a/src/pages/IntegrationsPage/IntegrationsModal/Amo/useAmoIntegration.ts b/src/pages/IntegrationsPage/IntegrationsModal/Amo/useAmoIntegration.ts index 6afafbd2..e420f921 100644 --- a/src/pages/IntegrationsPage/IntegrationsModal/Amo/useAmoIntegration.ts +++ b/src/pages/IntegrationsPage/IntegrationsModal/Amo/useAmoIntegration.ts @@ -128,10 +128,6 @@ export const useAmoIntegration = ({ isModalOpen, isTryRemoveAccount, quizID, que }) } - console.log("got questions") - console.log(gottenQuestions) - console.log("settingsResponse") - console.log(settingsResponse.FieldsRule) if (key === "Contact") { const MAP = settingsResponse.FieldsRule[key as QuestionKeys].ContactRuleMap diff --git a/src/pages/Tariffs/Tariffs.tsx b/src/pages/Tariffs/Tariffs.tsx index 24f1bc0e..49b63c1e 100644 --- a/src/pages/Tariffs/Tariffs.tsx +++ b/src/pages/Tariffs/Tariffs.tsx @@ -74,7 +74,7 @@ function TariffPage() { const tariffsList: Tariff[] = []; let page = 2 const [tariffsResponse, tariffsResponseError] = await getTariffs(page - 1); - +console.log(tariffsResponse) if (tariffsResponseError || !tariffsResponse) { return tariffsList; } @@ -182,7 +182,7 @@ function TariffPage() { inCart(); }; - const filteredTariffs = tariffs.filter((tariff) => { + const filteredTariffs = tariffs.filter((tariff, i) => { return ( tariff.privileges[0].serviceKey === "squiz" && !tariff.isDeleted && diff --git a/src/pages/Tariffs/tariffsUtils/createTariffElements.tsx b/src/pages/Tariffs/tariffsUtils/createTariffElements.tsx index 704dd138..7aad4952 100644 --- a/src/pages/Tariffs/tariffsUtils/createTariffElements.tsx +++ b/src/pages/Tariffs/tariffsUtils/createTariffElements.tsx @@ -17,6 +17,8 @@ export const createTariffElements = ( cc?: boolean, icon?: ReactNode ) => { + console.log("start work createTariffElements") + console.log("filteredTariffs ", filteredTariffs) const tariffElements = filteredTariffs .filter((tariff) => tariff.privileges.length > 0) .map((tariff, index) => { diff --git a/src/utils/handleComponentError.ts b/src/utils/handleComponentError.ts new file mode 100644 index 00000000..b914b518 --- /dev/null +++ b/src/utils/handleComponentError.ts @@ -0,0 +1,42 @@ +import { ErrorInfo } from "react"; + +interface ComponentError { + timestamp: number; + message: string; + callStack: string | undefined; + componentStack: string | null | undefined; +} + +export function handleComponentError(error: Error, info: ErrorInfo) { + const componentError: ComponentError = { + timestamp: Math.floor(Date.now() / 1000), + message: error.message, + callStack: error.stack, + componentStack: info.componentStack, + }; + + queueErrorRequest(componentError); +} + +let errorsQueue: ComponentError[] = []; +let timeoutId: ReturnType; + +function queueErrorRequest(error: ComponentError) { + errorsQueue.push(error); + + clearTimeout(timeoutId); + timeoutId = setTimeout(() => { + sendErrorsToServer(); + }, 1000); +} + +async function sendErrorsToServer() { + // makeRequest({ + // url: "", + // method: "POST", + // body: errorsQueue, + // useToken: true, + // }); + console.log(`Fake-sending ${errorsQueue.length} errors to server`, errorsQueue); + errorsQueue = []; +}