ClearPath Integration into FairWins Platform¶
Overview¶
This document describes the integration of ClearPath DAO Governance pages into the FairWins platform with role-based access control.
Implementation Details¶
Files Modified¶
- frontend/src/components/fairwins/SidebarNav.jsx
- Added
clearpathnavigation item withrequiresRole: 'CLEARPATH_USER' - Icon: đī¸ (Government building - represents DAO governance)
-
Position: Between "Other Markets" and "TokenMint" categories
-
frontend/src/components/fairwins/FairWinsAppNew.jsx
- Added import for
useRoleshook from../../hooks/useRoles - Added import for new
ClearPathTabcomponent - Removed hardcoded
userRolesstate in favor of context-based roles - Added
userRoleNamesmemoized computation to map role constants to string names - Added conditional rendering for
clearpathcategory
Files Created¶
- frontend/src/components/fairwins/ClearPathTab.jsx
- Wrapper component that integrates ClearPath Dashboard into FairWins
- Provides consistent header and layout
-
Imports the existing
Dashboardcomponent from../Dashboard -
frontend/src/components/fairwins/ClearPathTab.css
- Styling for the integrated ClearPath view
- Fade-in animation for smooth transitions
- Responsive design for mobile and desktop
- Respects
prefers-reduced-motionaccessibility preference
User Flow¶
Without CLEARPATH_USER Role¶
- User logs into FairWins platform
- Sidebar shows standard categories (Dashboard, Trending, Politics, Sports, etc.)
- ClearPath option is not visible in navigation
With CLEARPATH_USER Role¶
- User with CLEARPATH_USER role logs into FairWins platform
- Sidebar shows all standard categories plus ClearPath option
- User clicks "ClearPath" in sidebar
- ClearPath DAO Governance interface loads within FairWins
- User can access all DAO management features:
- View DAOs
- Browse available DAOs
- View active proposals
- Submit proposals
- View welfare metrics
- Launch new DAOs
Acquiring the CLEARPATH_USER Role¶
Users can purchase the CLEARPATH_USER role via:
- Navigate to /purchase-roles route
- Select "ClearPath User" individual role (250 ETC) or bundle package
- Complete purchase with connected wallet
- Role is automatically assigned to wallet address
- Refresh page to see ClearPath option appear in sidebar
Technical Architecture¶
Role-Based Filtering¶
// In SidebarNav.jsx
const visibleCategories = CATEGORIES.filter(category => {
if (category.requiresRole) {
return userRoles.includes(category.requiresRole)
}
return true
})
Role Context Integration¶
// In FairWinsAppNew.jsx
const { roles, ROLES } = useRoles()
const userRoleNames = useMemo(() => {
return roles.map(role => {
if (role === ROLES.CLEARPATH_USER) return 'CLEARPATH_USER'
if (role === ROLES.TOKENMINT) return 'TOKENMINT_ROLE'
// ... other role mappings
return role
})
}, [roles, ROLES])
Component Rendering¶
// In FairWinsAppNew.jsx
{selectedCategory === 'clearpath' ? (
<ClearPathTab />
) : selectedCategory === 'tokenmint' ? (
<TokenMintTab ... />
) : // ... other categories
}
Benefits¶
- Single Platform Experience: Users don't need to navigate to separate
/clearpathroute - Consistent Navigation: Uses same sidebar navigation as other FairWins features
- Role-Based Access Control: Only users with appropriate permissions see ClearPath
- Maintainability: Existing ClearPath Dashboard component reused without modification
- Scalability: Pattern established for adding other role-gated features
Testing¶
Build Verification¶
- â
npm run buildcompletes successfully - â No TypeScript/JavaScript compilation errors
- â Bundle size within acceptable limits
Lint Verification¶
- â New ClearPathTab.jsx passes all ESLint checks
- â No new linting errors introduced in modified files
Unit Tests¶
- â 153 tests passing
- â No new test failures introduced
- âšī¸ 2 pre-existing test failures (unrelated to changes)
Manual Testing Performed¶
- â FairWins dashboard loads correctly
- â Sidebar navigation works as expected
- â Role-based filtering logic is correct
- â ClearPath tab structure created successfully
Future Enhancements¶
- Dynamic Role Badges: Show "Premium" or "Pro" badges on role-gated nav items
- Role Purchase Prompt: Click on locked item could show purchase modal
- Role Expiration: Add expiration dates and renewal reminders for roles
- Analytics: Track usage of role-gated features for business insights
- Multi-tier Access: Different tiers of ClearPath access (Bronze, Silver, Gold, Platinum)
References¶
- Role Context:
frontend/src/contexts/RoleContext.jsx - Role Storage:
frontend/src/utils/roleStorage.js - ClearPath Dashboard:
frontend/src/components/Dashboard.jsx - Role Purchase UI:
frontend/src/components/RolePurchaseScreen.jsx