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:
@@ -115,11 +115,22 @@ const headerPrep: HeaderPrep = {
|
|||||||
|
|
||||||
// #region Lifecycle Hooks
|
// #region Lifecycle Hooks
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const result = await getDetailDivision(props.divisionId)
|
try {
|
||||||
if (result.success) {
|
const result = await getDetailDivision(props.divisionId)
|
||||||
division.value = result.body.data || {}
|
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
|
// #endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user