Add error handling to async calls in AcctMenu
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -92,18 +92,26 @@ const isAdmin = ref(false);
|
|||||||
|
|
||||||
/** Fetches user data and determines if the current user is an admin. */
|
/** Fetches user data and determines if the current user is an admin. */
|
||||||
const getIsAdminValue = async () => {
|
const getIsAdminValue = async () => {
|
||||||
|
try {
|
||||||
await loginStore.getUserData();
|
await loginStore.getUserData();
|
||||||
loginUserData.value = loginStore.userData;
|
loginUserData.value = loginStore.userData;
|
||||||
await acctMgmtStore.getUserDetail(loginUserData.value.username);
|
await acctMgmtStore.getUserDetail(loginUserData.value.username);
|
||||||
isAdmin.value = acctMgmtStore.currentViewingUser.is_admin;
|
isAdmin.value = acctMgmtStore.currentViewingUser.is_admin;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to fetch admin status:", error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Navigates to the My Account page. */
|
/** Navigates to the My Account page. */
|
||||||
const onBtnMyAccountClick = async () => {
|
const onBtnMyAccountClick = async () => {
|
||||||
|
try {
|
||||||
acctMgmtStore.closeAcctMenu();
|
acctMgmtStore.closeAcctMenu();
|
||||||
await acctMgmtStore.getAllUserAccounts(); // in case we haven't fetched yet
|
await acctMgmtStore.getAllUserAccounts(); // in case we haven't fetched yet
|
||||||
await acctMgmtStore.setCurrentViewingUser(loginUserData.value.username);
|
await acctMgmtStore.setCurrentViewingUser(loginUserData.value.username);
|
||||||
await router.push("/my-account");
|
await router.push("/my-account");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to navigate to My Account:", error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user