New alert service
This commit is contained in:
@@ -42,7 +42,7 @@ export const ROUTES = {
|
||||
FORGOT_PASSWORD: '/forgot-password',
|
||||
RESET_PASSWORD: '/reset-password',
|
||||
VERIFY_EMAIL: '/verify-email',
|
||||
|
||||
|
||||
// Dashboard
|
||||
DASHBOARD: '/app/dashboard',
|
||||
|
||||
@@ -63,21 +63,21 @@ export const ROUTES = {
|
||||
PRODUCTION_QUALITY: '/production/quality',
|
||||
PRODUCTION_REPORTS: '/production/reports',
|
||||
PRODUCTION_ANALYTICS: '/app/analytics/production',
|
||||
|
||||
|
||||
// Sales & Analytics
|
||||
SALES: '/sales',
|
||||
SALES_DATA: '/sales/data',
|
||||
SALES_ANALYTICS: '/sales/analytics',
|
||||
SALES_REPORTS: '/sales/reports',
|
||||
SALES_FORECASTING: '/sales/forecasting',
|
||||
|
||||
|
||||
// Forecasting & ML
|
||||
FORECASTING: '/forecasting',
|
||||
FORECASTING_MODELS: '/forecasting/models',
|
||||
FORECASTING_PREDICTIONS: '/forecasting/predictions',
|
||||
FORECASTING_TRAINING: '/forecasting/training',
|
||||
FORECASTING_ANALYTICS: '/forecasting/analytics',
|
||||
|
||||
|
||||
// Orders Management
|
||||
ORDERS: '/app/database/orders',
|
||||
ORDERS_LIST: '/orders/list',
|
||||
@@ -92,6 +92,9 @@ export const ROUTES = {
|
||||
PROCUREMENT_DELIVERIES: '/procurement/deliveries',
|
||||
PROCUREMENT_ANALYTICS: '/app/analytics/procurement',
|
||||
|
||||
// Distribution
|
||||
DISTRIBUTION: '/app/operations/distribution',
|
||||
|
||||
// Recipes
|
||||
RECIPES: '/app/database/recipes',
|
||||
|
||||
@@ -117,13 +120,13 @@ export const ROUTES = {
|
||||
TRAINING_JOBS: '/training/jobs',
|
||||
TRAINING_EVALUATION: '/training/evaluation',
|
||||
TRAINING_DATASETS: '/training/datasets',
|
||||
|
||||
|
||||
// Notifications
|
||||
NOTIFICATIONS: '/notifications',
|
||||
NOTIFICATIONS_LIST: '/notifications/list',
|
||||
NOTIFICATIONS_TEMPLATES: '/notifications/templates',
|
||||
NOTIFICATIONS_SETTINGS: '/notifications/settings',
|
||||
|
||||
|
||||
// Settings
|
||||
SETTINGS: '/settings',
|
||||
SETTINGS_PROFILE: '/app/settings/profile',
|
||||
@@ -149,7 +152,7 @@ export const ROUTES = {
|
||||
TERMS_OF_SERVICE: '/terms',
|
||||
COOKIE_POLICY: '/cookies',
|
||||
COOKIE_PREFERENCES: '/cookie-preferences',
|
||||
|
||||
|
||||
// Reports
|
||||
REPORTS: '/reports',
|
||||
REPORTS_PRODUCTION: '/reports/production',
|
||||
@@ -157,7 +160,7 @@ export const ROUTES = {
|
||||
REPORTS_SALES: '/reports/sales',
|
||||
REPORTS_FINANCIAL: '/reports/financial',
|
||||
REPORTS_QUALITY: '/reports/quality',
|
||||
|
||||
|
||||
// Help & Support
|
||||
HELP: '/help',
|
||||
HELP_DOCUMENTATION: '/help/docs',
|
||||
@@ -285,6 +288,17 @@ export const routesConfig: RouteConfig[] = [
|
||||
showInNavigation: true,
|
||||
showInBreadcrumbs: true,
|
||||
},
|
||||
{
|
||||
path: '/app/operations/distribution',
|
||||
name: 'Distribution',
|
||||
component: 'DistributionPage',
|
||||
title: 'Distribución',
|
||||
icon: 'truck',
|
||||
requiresAuth: true,
|
||||
showInNavigation: true,
|
||||
showInBreadcrumbs: true,
|
||||
requiredSubscriptionFeature: 'distribution',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -395,17 +409,7 @@ export const routesConfig: RouteConfig[] = [
|
||||
showInNavigation: true,
|
||||
showInBreadcrumbs: true,
|
||||
},
|
||||
{
|
||||
path: '/app/tenants/:tenantId/enterprise',
|
||||
name: 'EnterpriseDashboard',
|
||||
component: 'EnterpriseDashboardPage',
|
||||
title: 'Enterprise Dashboard',
|
||||
icon: 'analytics',
|
||||
requiresAuth: true,
|
||||
requiredSubscriptionFeature: 'multi_location_dashboard',
|
||||
showInNavigation: true,
|
||||
showInBreadcrumbs: true,
|
||||
},
|
||||
|
||||
],
|
||||
},
|
||||
|
||||
@@ -450,7 +454,7 @@ export const routesConfig: RouteConfig[] = [
|
||||
showInNavigation: true,
|
||||
showInBreadcrumbs: true,
|
||||
},
|
||||
{
|
||||
{
|
||||
path: '/app/database/recipes',
|
||||
name: 'Recipes',
|
||||
component: 'RecipesPage',
|
||||
@@ -641,7 +645,7 @@ export const getRouteByPath = (path: string): RouteConfig | undefined => {
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
return findRoute(routesConfig, path);
|
||||
};
|
||||
|
||||
@@ -660,7 +664,7 @@ export const getRouteByName = (name: string): RouteConfig | undefined => {
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
return findRoute(routesConfig, name);
|
||||
};
|
||||
|
||||
@@ -673,14 +677,14 @@ export const getNavigationRoutes = (): RouteConfig[] => {
|
||||
children: route.children ? filterNavRoutes(route.children) : undefined,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
return filterNavRoutes(routesConfig);
|
||||
};
|
||||
|
||||
export const getBreadcrumbs = (path: string): RouteConfig[] => {
|
||||
const breadcrumbs: RouteConfig[] = [];
|
||||
const pathSegments = path.split('/').filter(segment => segment);
|
||||
|
||||
|
||||
let currentPath = '';
|
||||
for (const segment of pathSegments) {
|
||||
currentPath += `/${segment}`;
|
||||
@@ -689,7 +693,7 @@ export const getBreadcrumbs = (path: string): RouteConfig[] => {
|
||||
breadcrumbs.push(route);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return breadcrumbs;
|
||||
};
|
||||
|
||||
@@ -697,13 +701,13 @@ export const hasPermission = (route: RouteConfig, userPermissions: string[]): bo
|
||||
if (!route.requiredPermissions || route.requiredPermissions.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Check for wildcard permission
|
||||
if (userPermissions.includes('*')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return route.requiredPermissions.every(permission =>
|
||||
|
||||
return route.requiredPermissions.every(permission =>
|
||||
userPermissions.includes(permission)
|
||||
);
|
||||
};
|
||||
@@ -712,32 +716,32 @@ export const hasRole = (route: RouteConfig, userRoles: string[]): boolean => {
|
||||
if (!route.requiredRoles || route.requiredRoles.length === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return route.requiredRoles.some(role =>
|
||||
|
||||
return route.requiredRoles.some(role =>
|
||||
userRoles.includes(role)
|
||||
);
|
||||
};
|
||||
|
||||
export const canAccessRoute = (
|
||||
route: RouteConfig,
|
||||
isAuthenticated: boolean,
|
||||
userRoles: string[] = [],
|
||||
route: RouteConfig,
|
||||
isAuthenticated: boolean,
|
||||
userRoles: string[] = [],
|
||||
userPermissions: string[] = []
|
||||
): boolean => {
|
||||
// Check authentication requirement
|
||||
if (route.requiresAuth && !isAuthenticated) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check role requirements
|
||||
if (!hasRole(route, userRoles)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check permission requirements
|
||||
if (!hasPermission(route, userPermissions)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
Reference in New Issue
Block a user