orgDetailRouteTitle function
Maps an /org/:orgId/<sub> path to the AppBar title used by
OrgDetailScaffold. Centralised here so adding a new detail route
only needs one entry — never per-screen logic.
Visible for testing so the route-coverage test can assert every
detail path resolves to a real title (not the 'Details' fallback).
Implementation
@visibleForTesting
String orgDetailRouteTitle(String location, String orgId) {
final orgPrefix = '/org/$orgId';
final tail = location.startsWith(orgPrefix)
? location.substring(orgPrefix.length)
: location;
if (tail.startsWith('/notifications/preferences')) {
return 'Notification preferences';
}
if (tail.startsWith('/notifications')) return 'Notifications';
if (RegExp(r'^/teams/[^/]+').hasMatch(tail)) return 'Team';
if (tail.startsWith('/teams')) return 'Teams';
if (tail.startsWith('/reports')) return 'Progress report';
if (RegExp(r'^/assignments/[^/]+').hasMatch(tail)) return 'Assignment';
if (RegExp(r'^/members/[^/]+').hasMatch(tail)) return 'Member';
if (RegExp(r'^/paths/[^/]+/progress').hasMatch(tail)) return 'Path progress';
if (RegExp(r'^/paths/[^/]+').hasMatch(tail)) return 'Learning path';
if (tail.startsWith('/paths')) return 'Learning paths';
if (tail.startsWith('/skills/gaps')) return 'Skill gaps';
if (tail.startsWith('/skills')) return 'Skills';
if (tail.startsWith('/roles')) return 'Roles';
if (RegExp(r'^/certificates/[^/]+').hasMatch(tail)) return 'Certificate';
if (tail.startsWith('/certifications')) return 'Certifications';
if (tail.startsWith('/compliance')) return 'Compliance';
if (tail.startsWith('/leaderboard')) return 'Leaderboard';
if (tail.startsWith('/badges')) return 'Badges';
if (tail.startsWith('/gamification-settings')) return 'Gamification';
if (tail.startsWith('/sso')) return 'SSO';
if (tail.startsWith('/api-keys')) return 'API keys';
if (tail.startsWith('/webhooks')) return 'Webhooks';
if (tail.startsWith('/billing')) return 'Billing';
return 'Details';
}