import { ref } from "vue";
import type { Skill } from "~/types/Skill";
import type { TransmisionEndpoints } from "~/types/Cliente";
import type { ClienteSinCefResponse, DataSinCef } from "~/types/Cliente";

export const useTransmisionClientes = () => {
  const skills = ref<Skill[]>([]);
  const loading = ref(false);
  const error = ref<string | null>(null);
  const dataSinCef = ref<DataSinCef[] | []>([]);

  const endPoints = ref<TransmisionEndpoints>();

  const direccionesSinCef = async () => {
    try {
      loading.value = true;
      error.value = null;
      const { success, message, data } = await useApiFetch<ClienteSinCefResponse>(
        'transmision/cliente',
        {
          method: "GET",
        },
      );
      if (success) {
        dataSinCef.value = data ?? []
      }
     
    } catch (err: any) {
      error.value = err?.data?.message ?? "Error al obtener skills";

    } finally {
      loading.value = false;
    }
  };

  return {
    direccionesSinCef,
    dataSinCef,
    skills,
    loading,
    error,
    endPoints
  };
};
