diff --git a/frontend-web/src/components/ui/use-toast.jsx b/frontend-web/src/components/ui/use-toast.jsx index a200e225..5ad1caad 100644 --- a/frontend-web/src/components/ui/use-toast.jsx +++ b/frontend-web/src/components/ui/use-toast.jsx @@ -96,6 +96,7 @@ function dispatch(action) { async function createNotification(title, description, variant) { try { const user = await krowSDK.auth.me(); + if (!user) { console.warn("Cannot create notification: user not authenticated."); return; diff --git a/frontend-web/src/pages/StaffDirectory.jsx b/frontend-web/src/pages/StaffDirectory.jsx index 88ce6f0c..4751c3e2 100644 --- a/frontend-web/src/pages/StaffDirectory.jsx +++ b/frontend-web/src/pages/StaffDirectory.jsx @@ -52,7 +52,7 @@ export default function StaffDirectory() { if (!krowUser || !staff) return []; const userRole = krowUser.user_role || krowUser.role; - if (['admin', 'procurement', 'operator', 'sector'].includes(userRole)) { + if (['admin', 'procurement', 'operator', 'sector'].includes(userRole.toLowerCase())) { return staff; } @@ -109,7 +109,7 @@ export default function StaffDirectory() { return matchesSearch && matchesDepartment && matchesLocation; }); - const canAddStaff = krowUser && ['admin', 'procurement', 'operator', 'sector', 'vendor'].includes(krowUser.user_role || krowUser.role); + const canAddStaff = krowUser && ['admin', 'procurement', 'operator', 'sector', 'vendor'].includes((krowUser.user_role || krowUser.role || '').toLowerCase()); const isLoading = isLoadingStaff || isLoadingUser; const getPageTitle = () => {