fix(app): re-check the sales-expert flag on every dashboard visit
The "سفارش مشتریان" / "مشتریان من" entries are shown from session.isSalesExpert, which was fetched from /expert/whoami only once, at sign-in. A slow or failed request (silently swallowed) left the flag false until the next login, so an expert saw a customer-only menu. The dashboard now asks again on mount and on every re-activation, and keeps the current value when the request fails. Rebuilds user-app and user-app-v2 dist. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
d8b6d36c1b
commit
0b973f9e46
@@ -320,10 +320,27 @@ async function onRefresh() {
|
||||
}
|
||||
}
|
||||
|
||||
// D21 — the expert flag used to be fetched once, at sign-in, and a slow or
|
||||
// failed whoami left it false for good (the expert entries stayed hidden until
|
||||
// the next login). Ask again on every dashboard visit; a failed request keeps
|
||||
// whatever the flag already is.
|
||||
async function syncExpertFlag() {
|
||||
if (!session.isLoggedIn) return
|
||||
try {
|
||||
const who = await api.getExpertIdentity()
|
||||
session.setSalesExpert(who.isSalesExpert)
|
||||
} catch {
|
||||
/* keep the current flag */
|
||||
}
|
||||
}
|
||||
|
||||
let activatedOnce = false
|
||||
onActivated(() => {
|
||||
// Kept alive by MasterLayout, so every later visit lands here, not in onMounted.
|
||||
if (activatedOnce) void loadDashboard()
|
||||
if (activatedOnce) {
|
||||
void loadDashboard()
|
||||
void syncExpertFlag()
|
||||
}
|
||||
activatedOnce = true
|
||||
})
|
||||
|
||||
@@ -332,6 +349,7 @@ onActivated(() => {
|
||||
const { revealed, revealDelay, reveal } = useReveal('dashboard')
|
||||
|
||||
onMounted(async () => {
|
||||
void syncExpertFlag()
|
||||
await loadDashboard()
|
||||
reveal()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user