refactor: restructure project to classic MVC pattern
This commit is contained in:
25
src/composables/useProfile.ts
Normal file
25
src/composables/useProfile.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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};
|
||||
}
|
||||
Reference in New Issue
Block a user