import { ExtraOptions, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { PagesLayoutComponent } from './frontcraft/pages/pages-layout.component';
import { FrontcraftUserComponent } from './frontcraft/pages/user/user.component';
import { FrontcraftRaidComponent } from './frontcraft/pages/raid/raid.component';
import { FrontcraftArchiveComponent } from './frontcraft/pages/raid/archive.component';
import { FrontcraftRaidsComponent } from './frontcraft/pages/raids/raids.component';
import { FrontcraftCharacterComponent } from './frontcraft/pages/character/character.component';
import { FrontcraftCharactersComponent } from './frontcraft/pages/characters/characters.component';
import { FrontcraftRulesComponent } from './frontcraft/pages/rules/rules.component';
import { FrontcraftArmoryComponent } from './frontcraft/pages/armory/armory.component';
import { RegisterComponent } from './frontcraft/auth/register/register.component';
import { LogoutComponent } from './frontcraft/auth/logout/logout.component';
import { MyLoginComponent } from './frontcraft/auth/login/login.component';
import { AuthComponent } from './frontcraft/auth/auth-layout.component';
import { ChangePermissionsComponent } from './frontcraft/permissions/changePermissions/changePermissions.component';
import { PermissionsComponent } from './frontcraft/permissions/permissions-layout.component';

const routes: Routes = [
  {
    path: 'permissions',
    component: PermissionsComponent,
    children: [
      {
          path: '**',
          component: ChangePermissionsComponent,
      },
    ]
  },
  {
    path: 'auth',
    component: AuthComponent,
        children: [
            {
                path: 'register',
                component: RegisterComponent
            },
            {
                path: 'logout',
                component: LogoutComponent,
            },
            {
                path: '**',
                component: MyLoginComponent,
            },
        ]
  },
  {
    path: 'frontcraft',
    component: PagesLayoutComponent,
    children: [
        {
            path: 'user/:name',
            component: FrontcraftUserComponent
        },
        {
            path: 'raid/:id',
            component: FrontcraftRaidComponent
        },
        {
            path: 'archive/:id',
            component: FrontcraftArchiveComponent
        },
        {
            path: 'raids',
            component: FrontcraftRaidsComponent
        },
        {
            path: 'character/:name',
            component: FrontcraftCharacterComponent
        },
        {
            path: 'characters',
            component: FrontcraftCharactersComponent
        },
        {
            path: 'rules',
            component: FrontcraftRulesComponent
        },
        {
            path: 'armory',
            component: FrontcraftArmoryComponent
        },
        {
            path: '**',
            redirectTo: 'raids'
        },
    ]
  },
  { path: '', redirectTo: 'frontcraft/raids', pathMatch: 'full' },
  { path: '**', redirectTo: 'frontcraft/raids' },     
];

const config: ExtraOptions = {
  useHash: false,
};

@NgModule({
  imports: [RouterModule.forRoot(routes, config)],
  exports: [RouterModule],
})
export class AppRoutingModule {
}
