// imports

import { useQuery } from "@tanstack/vue-query";
import { API_ENDPOINTS, QUERY_KEYS } from "~/constants";

// types

export type GetAllAddressResponse = Address[];

const useGetAllAddress = () => {
    // state

    const { $axios: axios } = useNuxtApp();

    // methods

    const handleGetAllAddress = async () => {
        const { data } = await axios.get<GetAllAddressResponse>(
            API_ENDPOINTS.account.address.get_all
        );
        return data;
    };

    return useQuery({
        queryKey: [QUERY_KEYS.addresses],
        queryFn: () => handleGetAllAddress(),
    });
};

export default useGetAllAddress;
