refactor: enhance child route management in ClientPaths and StaffPaths; ensure proper handling of empty child paths
This commit is contained in:
@@ -48,7 +48,7 @@ extension ClientNavigator on IModularNavigator {
|
||||
/// This is typically called after successful authentication or when
|
||||
/// returning to the main application from a deep feature.
|
||||
///
|
||||
/// Uses absolute navigation to ensure proper routing from any context.
|
||||
/// Uses pushNamed to avoid trailing slash issues with navigate().
|
||||
void toClientHome() {
|
||||
navigate(ClientPaths.home);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,21 @@ class ClientPaths {
|
||||
/// Generate child route based on the given route and parent route
|
||||
///
|
||||
/// This is useful for creating nested routes within modules.
|
||||
static String childRoute(String parent, String child) => child.replaceFirst(parent, '');
|
||||
static String childRoute(String parent, String child) {
|
||||
final String childPath = child.replaceFirst(parent, '');
|
||||
|
||||
// check if the child path is empty
|
||||
if (childPath.isEmpty) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
// ensure the child path starts with a '/'
|
||||
if (!childPath.startsWith('/')) {
|
||||
return '/$childPath';
|
||||
}
|
||||
|
||||
return childPath;
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// AUTHENTICATION
|
||||
|
||||
@@ -16,8 +16,22 @@ class StaffPaths {
|
||||
/// Generate child route based on the given route and parent route
|
||||
///
|
||||
/// This is useful for creating nested routes within modules.
|
||||
static String childRoute(String parent, String child) => child.replaceFirst(parent, '');
|
||||
static String childRoute(String parent, String child) {
|
||||
final String childPath = child.replaceFirst(parent, '');
|
||||
|
||||
// check if the child path is empty
|
||||
if (childPath.isEmpty) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
// ensure the child path starts with a '/'
|
||||
if (!childPath.startsWith('/')) {
|
||||
return '/$childPath';
|
||||
}
|
||||
|
||||
return childPath;
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// AUTHENTICATION
|
||||
// ==========================================================================
|
||||
@@ -93,7 +107,8 @@ class StaffPaths {
|
||||
/// Personal information onboarding.
|
||||
///
|
||||
/// Collect basic personal information during staff onboarding.
|
||||
static const String onboardingPersonalInfo = '/worker-main/onboarding/personal-info';
|
||||
static const String onboardingPersonalInfo =
|
||||
'/worker-main/onboarding/personal-info';
|
||||
|
||||
/// Emergency contact information.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user