Skip to content

Implemented role-based UI handling#54

Merged
ayshadogo merged 1 commit intoDfunder:mainfrom
Kaylahray:role-based-ui
Mar 6, 2026
Merged

Implemented role-based UI handling#54
ayshadogo merged 1 commit intoDfunder:mainfrom
Kaylahray:role-based-ui

Conversation

@Kaylahray
Copy link
Contributor

Implement role-based UI and owner-only campaign actions

Changes Made

1. Created useRole Custom Hook

  • Added src/hooks/useRole.js that returns { isAdmin, isUser } based on current user's role
  • Provides reusable role checking across the application

2. Role-Based Navigation

  • Updated Navbar to hide "Create Campaign" button for admin users
  • Added "Admin Panel" link visible only to admin users
  • Applied to both desktop and mobile navigation menus

3. Campaign Owner Actions

  • Implemented Edit and Delete buttons in CampaignDetails page
  • Buttons only visible to campaign owners (ownership check)
  • Added confirmation dialog for delete action
  • Styled with proper UI/UX considerations

4. Admin Route Protection

  • Created AdminRoute component to protect admin-only routes
  • Non-admin users are redirected to /dashboard
  • Applied to /admin route in AppRouter

Acceptance Criteria Met

✅ Admin-only UI is hidden from regular users
✅ Owner-only actions are hidden from non-owners
✅ Clean separation of role-based vs ownership-based permissions

Closes #50

@ayshadogo ayshadogo merged commit 5741269 into Dfunder:main Mar 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Role-Based UI Handling

2 participants