import useAxios from "axios-hooks";

const useLanguages = () => {
  const [{ ...languageData }, getLanguages] = useAxios(
    {},
    {
      manual: true,
    },
  );

  const handleGetLanguages = async () => {
    await getLanguages({ method: "get", url: "/iam/v1/accounts/languages/" });
  };

  const [{ ...translateLangData }, translateLang] = useAxios(
    {},
    { manual: true },
  );

  const handleTranslate = async (data) => {
    return await translateLang({
      method: "post",
      url: "/iam/v1/accounts/batch-translate/",
      data,
    });
  };

  return {
    handleTranslate,
    translateLangData,
    languageData,
    handleGetLanguages,
  };
};
export default useLanguages;
