Skip to content

Commit f0bbe8a

Browse files
committed
debug: Add detailed logging to isLocked calculation in BranchContext
1 parent fb25943 commit f0bbe8a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/components/Layout/Navbar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ const Navbar = () => {
1010
const { selectedBranchId, setSelectedBranchId, branches, isLocked } = useBranch();
1111
const navigate = useNavigate();
1212

13+
// Debug logging
14+
console.log('🔍 Navbar Debug:');
15+
console.log(' - user:', user);
16+
console.log(' - user.role:', user?.role);
17+
console.log(' - user.branch_id:', user?.branch_id);
18+
console.log(' - isLocked:', isLocked);
19+
console.log(' - selectedBranchId:', selectedBranchId);
20+
1321
const handleLogout = () => {
1422
logout();
1523
navigate('/login');

src/context/BranchContext.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ export const BranchProvider = ({ children }) => {
8787
const hasBranchId = user?.branch_id !== null && user?.branch_id !== undefined && user?.branch_id !== '';
8888
const isLocked = user && user.role !== 'Admin' && hasBranchId;
8989

90+
console.log('🔐 BranchContext - isLocked calculation:', {
91+
user: user ? 'exists' : 'null',
92+
role: user?.role,
93+
isNotAdmin: user?.role !== 'Admin',
94+
hasBranchId: hasBranchId,
95+
branch_id: user?.branch_id,
96+
isLocked: isLocked
97+
});
98+
9099
const value = {
91100
selectedBranchId,
92101
setSelectedBranchId: handleSetSelectedBranchId,

0 commit comments

Comments
 (0)