import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { AuthGuardAdmin } from '../services/auth-guard-admin.service';
import { AdminComponent, PostsComponent, DashboardComponent, AccountComponent, PostFormComponent } from '.';

const routes: Routes = [
  { path: '',
    component: AdminComponent,
    data: { title: 'Admin' },
    canActivate: [AuthGuardAdmin],
    children: [
      {
        path: '',
        component: DashboardComponent
      },
      {
        path: 'dashboard',
        component: DashboardComponent,
        data: { title: 'Dashboard' },
      },
      {
        path: 'posts',
        component: PostsComponent,
        data: { title: 'Posts' },
      },
      {
        path: 'posts/add',
        component: PostFormComponent,
        data: { title: 'Posts add' },
      },
      {
        path: 'posts/edit/:id',
        component: PostFormComponent,
        data: { title: 'Posts edit' },
      },
      {
        path: 'account',
        component: AccountComponent,
        data: { title: 'Account' },
      },
    ]
  },
];

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

AdminRoutingModule