feat(dashboard): handle API errors and enhance translations
This commit is contained in:
@@ -4,6 +4,7 @@ import DashboardData = App.Features.Dashboard.Data.DashboardData;
|
||||
|
||||
export default function useDashboardViewModel() {
|
||||
const isLoading = ref<boolean>(false);
|
||||
const error = ref<string>();
|
||||
const dashboardData = ref<DashboardData>();
|
||||
|
||||
function getDashboardData() {
|
||||
@@ -15,8 +16,11 @@ export default function useDashboardViewModel() {
|
||||
.then((res) => {
|
||||
dashboardData.value = res.data;
|
||||
})
|
||||
.catch((err) => {
|
||||
error.value = err.response.data.message;
|
||||
})
|
||||
.finally(() => (isLoading.value = false));
|
||||
}
|
||||
|
||||
return { isLoading, dashboardData, getDashboardData };
|
||||
return { isLoading, dashboardData, error, getDashboardData };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user