File size: 609 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import type { Language } from "@reactive-resume/utils";
import { useQuery } from "@tanstack/react-query";

import { LANGUAGES_KEY } from "@/client/constants/query-keys";
import { axios } from "@/client/libs/axios";

export const fetchLanguages = async () => {
  const response = await axios.get<Language[]>(`/translation/languages`);

  return response.data;
};

export const useLanguages = () => {
  const {
    error,
    isPending: loading,
    data: languages,
  } = useQuery({
    queryKey: [LANGUAGES_KEY],
    queryFn: fetchLanguages,
  });

  return { languages: languages ?? [], loading, error };
};