import axios from "axios";
const API_KEY = 'AIzaSyDQcTlxfd5IyjbeSJooRtNt6OF04DLykqc'
import { getMonth } from "./utils";

export const getEmployees = async(apiDomain: string, _dataMode: string = 'month', monthTab: string) => {
  let idGoogle = apiDomain.split("/")[5]
  let URL = `https://sheets.googleapis.com/v4/spreadsheets/${idGoogle}/values`
  try {
    const response = await axios({
      url: `${URL}/${monthTab}?key=${API_KEY}`
    });
    return response;
  } catch (error) {
    console.error(error);
    return error;
  }
}

export const getEmployeesYearly = (apiDomain: string, numberMonth: number) => {
  let monthTab = getMonth(numberMonth)
  let idGoogle = apiDomain.split("/")[5]
  let URL = `https://sheets.googleapis.com/v4/spreadsheets/${idGoogle}/values`
  try {
    const response = axios({
      url: `${URL}/${monthTab}?key=${API_KEY}`
    });
    return response;
  } catch (error) {
    console.error(error);
    return error;
  }
}

