import { makeRequest } from "@frontend/kitui";
import { parseAxiosError } from "@utils/parse-error";
import type { GetTariffsResponse } from "@frontend/kitui";

const API_URL = `${process.env.REACT_APP_DOMAIN}/strator/tariff`;

export const getTariffs = async (
  page: number = 1,
): Promise<[GetTariffsResponse | null, string?]> => {
  try {
    const tariffs = await makeRequest<never, GetTariffsResponse>({
      method: "GET",
      url: `${API_URL}/getList?page=${page}&limit=100`,
    });
    return [tariffs];
  } catch (nativeError) {
    const [error] = parseAxiosError(nativeError);
    return [null, `Ошибка при получении списка тарифов. ${error}`];
  }
};

import axios from "axios";


const apiUrl = process.env.REACT_APP_DOMAIN + "/requestquiz";

export async function sendContactFormRequest(body: {
    contact: string;
    whoami: string;
}) {
  try {
    const a = await axios(apiUrl + "/callme", {
      method: "POST",
      headers: {
          "Content-Type": "application/json",
      },
      data: body,
  });
  return [a];
  } catch (nativeError) {
    const [error] = parseAxiosError(nativeError);

    return [null, `Ошибка при отправке запроса. ${error}`];
  }
}