import {Routes} from '@angular/router';
import {LoginComponent} from './pages/login/login.component';
import {HomeComponent} from './pages/home/home.component';
import {LogoutComponent} from './pages/logout/logout.component';
import {NotFoundComponent} from './pages/not-found/not-found.component';
import {authGuard} from './guards/auth.guard';
import {ProfileComponent} from './pages/profile/profile.component';
import {NewPostComponent} from './pages/new-post/new-post.component';
import {writerGuard} from './guards/writer.guard';
import {PostComponent} from './pages/post/post.component';
import {MyPostsComponent} from './pages/my-posts/my-posts.component';
import {RegisterComponent} from './pages/register/register.component';
import {AdminPostsComponent} from './pages/admin-posts/admin-posts.component';
import {adminGuard} from './guards/admin.guard';
import {AdminAuthorsComponent} from './pages/admin-authors/admin-authors.component';

export const routes: Routes = [
  {path: '', component: HomeComponent},
  {path: 'login', component: LoginComponent, canActivate: [authGuard]},
  {path: 'register', component: RegisterComponent, canActivate: [authGuard]},
  {path: 'logout', component: LogoutComponent},
  {path: 'profile/:authorId', component: ProfileComponent},
  {path: 'post/:postId', component: PostComponent},
  {path: 'my-posts', component: MyPostsComponent, canActivate: [writerGuard]},
  {path: 'new-post', component: NewPostComponent, canActivate: [writerGuard]},
  {path: 'admin/posts', component: AdminPostsComponent, canActivate: [adminGuard]},
  {path: 'admin/authors', component: AdminAuthorsComponent, canActivate: [adminGuard]},
  {path: '**', component: NotFoundComponent}
];
