47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { Routes } from '@angular/router';
|
|
import { brandInfoRoutes, brandLegalRoutes } from './brands/brand-routes';
|
|
import { languageGuard } from './guards/language.guard';
|
|
|
|
// Core routes (same across all brands)
|
|
const coreRoutes: Routes = [
|
|
{
|
|
path: '',
|
|
loadComponent: () => import('./pages/home/home.component').then(m => m.HomeComponent)
|
|
},
|
|
{
|
|
path: 'category/:id',
|
|
loadComponent: () => import('./pages/category/subcategories.component').then(m => m.SubcategoriesComponent)
|
|
},
|
|
{
|
|
path: 'category/:id/items',
|
|
loadComponent: () => import('./pages/category/category.component').then(m => m.CategoryComponent)
|
|
},
|
|
{
|
|
path: 'item/:id',
|
|
loadComponent: () => import('./pages/item-detail/item-detail.component').then(m => m.ItemDetailComponent)
|
|
},
|
|
{
|
|
path: 'search',
|
|
loadComponent: () => import('./pages/search/search.component').then(m => m.SearchComponent)
|
|
},
|
|
{
|
|
path: 'cart',
|
|
loadComponent: () => import('./pages/cart/cart.component').then(m => m.CartComponent)
|
|
}
|
|
];
|
|
|
|
// All routes sit under a :lang prefix (e.g. /ru/cart, /en/item/5)
|
|
export const routes: Routes = [
|
|
{
|
|
path: ':lang',
|
|
canActivate: [languageGuard],
|
|
children: [
|
|
...coreRoutes,
|
|
...brandInfoRoutes,
|
|
...brandLegalRoutes,
|
|
{ path: '**', redirectTo: '' }
|
|
]
|
|
},
|
|
// URLs without a language prefix → redirect to default language
|
|
{ path: '**', redirectTo: 'ru' }
|
|
]; |