import { API_BASE } from "../../config/api.config";
import Cookies from "js-cookie";

export const fetchInfo = async () => {
  console.warn("fetchInfo is fetching!");

  const response = await fetch(`${API_BASE}/default/info`);
  const data = await response.json();

  return data;
};

export const confirmUser = async (username: string | null) => {
  if (!username) {
    return;
  }

  console.warn("confirmUser is fetching!");
  const response = await fetch(
    `${API_BASE}/default/confirm-user?username=${username}`,
  );
  const data = await response.json();
  Cookies.set("selectedUser", username);
  return data;
};
