Add SelectCountryComponent and adjust app routing

Created a new SelectCountryComponent to allow users to select their country. The new component includes buttons for each country and is displayed by default at the application start. The application routing was updated accordingly to redirect to the new component when no specific URL is entered or a redirection is required.
This commit is contained in:
Kenta420 2023-12-08 16:28:00 +07:00
parent 332f5bb604
commit 872f0f2383
6 changed files with 68 additions and 19 deletions

View file

@ -72,7 +72,7 @@ const loginGuard: CanActivateFn = (
// redirect to redirectUrl query param
console.log(route.queryParams['redirectUrl']);
return router.createUrlTree([
router.parseUrl(route.queryParams['redirectUrl'] ?? '/recipes'),
router.parseUrl(route.queryParams['redirectUrl'] ?? 'select-country'),
]);
// return false;
})
@ -94,15 +94,15 @@ const routes: Routes = [
),
},
{
path: '',
path: 'select-country',
loadComponent: () => import('./core/department/select-country.component').then(m => m.SelectCountryComponent),
canActivate: [authGuard]
},
{
path: ':department',
loadComponent: () =>
import('./core/layout/layout.component').then((m) => m.LayoutComponent),
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'recipes',
},
{
path: 'recipes',
loadComponent: () =>
@ -126,20 +126,25 @@ const routes: Routes = [
// (m) => m.ChangelogComponent
// ),
// },
{
path: 'unauthorized',
loadComponent: () => import('./core/auth/unauthorized.component').then((m) => m.UnauthorizedComponent)
},
{
path: 'notfound',
loadComponent: () => import('./core/notfound.component').then((m) => m.NotfoundComponent)
},
{
path: '**',
redirectTo: 'notfound',
},
],
},
{
path: 'unauthorized',
loadComponent: () => import('./core/auth/unauthorized.component').then((m) => m.UnauthorizedComponent)
},
{
path: 'notfound',
loadComponent: () => import('./core/notfound.component').then((m) => m.NotfoundComponent)
},
{
path: '',
pathMatch: 'full',
redirectTo: 'select-country'
},
{
path: '**',
redirectTo: 'notfound',
},
];
@NgModule({