fix(division-detail): handle errors when fetching division and employee data

Add try-catch block to handle potential errors during API calls for division details and employee list. Show toast notification when errors occur to improve user feedback.
This commit is contained in:
Khafid Prayoga
2025-10-27 13:32:56 +07:00
parent ddb9058969
commit 16a4fc5d7f
+15 -4
View File
@@ -115,11 +115,22 @@ const headerPrep: HeaderPrep = {
// #region Lifecycle Hooks
onMounted(async () => {
const result = await getDetailDivision(props.divisionId)
if (result.success) {
division.value = result.body.data || {}
try {
const result = await getDetailDivision(props.divisionId)
if (result.success) {
division.value = result.body.data || {}
}
const res = await getEmployeeLabelList({ sort: 'createdAt:asc', 'page-size': 100, includes: 'person' })
employees.value = res
} catch (err) {
// show toast
toast({
title: 'Terjadi Kesalahan',
description: 'Terjadi kesalahan saat memuat data',
variant: 'destructive',
})
}
employees.value = await getEmployeeLabelList({ sort: 'createdAt:asc', 'page-size': 100, includes: 'person' })
})
// #endregion