import { Route } from '@angular/router';
import { authGuard } from 'feature-auth';

const homeTitle = $localize`:@@route.home.title:APF Portal Admin`;
const auditTitle = $localize`:@@route.audit.title:Audit log — APF Portal Admin`;
const usersTitle = $localize`:@@route.users.title:Users — APF Portal Admin`;
const userScopesTitle = $localize`:@@route.user-scopes.title:User scopes — APF Portal Admin`;
const profileTitle = $localize`:@@route.profile.title:Profile — APF Portal Admin`;

export const appRoutes: Route[] = [
  {
    path: '',
    pathMatch: 'full',
    loadComponent: () => import('./pages/home/home').then((m) => m.Home),
    title: homeTitle,
  },
  {
    path: 'audit',
    loadComponent: () => import('./pages/audit/audit').then((m) => m.AuditPage),
    title: auditTitle,
  },
  {
    path: 'users',
    loadComponent: () => import('./pages/users/users').then((m) => m.UsersPage),
    title: usersTitle,
  },
  {
    path: 'users/:oid/scopes',
    loadComponent: () => import('./pages/user-scopes/user-scopes').then((m) => m.UserScopesPage),
    title: userScopesTitle,
  },
  {
    path: 'profile',
    canActivate: [authGuard],
    loadComponent: () => import('./pages/profile/profile').then((m) => m.ProfilePage),
    title: profileTitle,
  },
  // Catch-all — unknown paths bounce to home. Same role as the
  // wildcard in portal-shell (per PR #96): in production each locale
  // bundle ships with its own `<base href="/{locale}/">` and the
  // router never sees the locale segment, so this only fires for
  // genuine 404 paths; in dev (`nx serve`) it stops the router from
  // throwing NG04002 when a stray `/fr/`-style URL is typed.
  {
    path: '**',
    redirectTo: '',
  },
];
