25 lines
691 B
TypeScript

import {onMounted, ref} from "vue";
import {ProfileService} from "@/infrastructure/api/ProfileService";
import {GetProfile} from "@/domain/usecases/GetProfile";
const profileService = new ProfileService();
const getProfileUseCase = new GetProfile(profileService);
export function useProfile() {
const profile = ref<any>(null);
const loading = ref(false);
const error = ref<string | null>(null);
onMounted(async () => {
loading.value = true;
try {
profile.value = await getProfileUseCase.execute();
} catch (err: any) {
error.value = err.message;
} finally {
loading.value = false;
}
});
return {profile, loading};
}