import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { RouterModule } from '@angular/router';

// Dependencies
import { MDBBootstrapModule } from 'angular-bootstrap-md';

// Router
import { appRoutes } from './app.routing';

// Guard
import { AuthGuard } from './core/guards/auth.guard';

// Interceptor
import { UnauthorizedInterceptor } from './core/interceptors/unauthorized.interceptor';

// Components
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { FooterComponent } from './footer/footer.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
import { DisconnectionComponent } from './disconnection/disconnection.component';
import { PostComponent } from './posts/post.component';
import { ByCategoryComponent } from './posts/byCategory/by-category.component';
import { MyPostsComponent } from './posts/myPosts/my-posts.component';
import { AccountSettingsComponent } from './account-settings/account-settings.component';
import { ChangePasswordComponent } from './account-settings/change-password/change-password.component';
import { ProfilEditionComponent } from './account-settings/profil-edition/profil-edition.component';
import { CreateUpdatePostComponent } from './posts/create-update/create-update-post.component';
import { ForbiddenComponent } from './forbidden/forbidden.component';
import { SearchComponent } from './search/search.component';
import { SigninComponent } from './signin/signin.component';
import { VersionRevisionComponent } from './version-revisions/version-revisions.component';

// Reusable components
import { PostCardComponent } from './core/post-card/post-card.component';
import { SpinnerComponent } from './core/directives/spinner/spinner.component';
import { SearchBarComponent } from './core/directives/search-bar/search-bar.component';
import { ProgressBarComponent } from './core/directives/progress-bar/progress-bar.component';

// Services
import { AuthService } from './core/services/auth.service';
import { LoginService } from './login/login.service';
import { HomeService } from './home/home.service';
import { PostService } from './posts/post.service';
import { ByCategoryService } from './posts/byCategory/by-category.service';
import { MyPostsService } from './posts/myPosts/my-posts.service';
import { ChangePasswordService } from './account-settings/change-password/change-password.service';
import { ProfilEditionService } from './account-settings/profil-edition/profil-edition.service';
import { HeaderService } from './header/header.service';
import { CreateUpdatePostService } from './posts/create-update/create-update-post.service';
import { SearchService } from './search/search.service';
import { SigninService } from './signin/signin.service';
import { VersionRevisionService } from './version-revisions/version-revisions.service';

@NgModule({
	declarations: [
		AppComponent,
		HeaderComponent,
		FooterComponent,
		LoginComponent,
		SigninComponent,
		DisconnectionComponent,
		HomeComponent,
		PostCardComponent,
		SpinnerComponent,
		MyPostsComponent,
		AccountSettingsComponent,
		ChangePasswordComponent,
		ProfilEditionComponent,
		PostComponent,
		NotFoundComponent,
		ByCategoryComponent,
		CreateUpdatePostComponent,
		VersionRevisionComponent,
		SearchComponent,
		SearchBarComponent,
		ProgressBarComponent,
		ForbiddenComponent
	],
	imports: [
		BrowserModule,
		FormsModule,
		HttpModule,
		HttpClientModule,
		MDBBootstrapModule.forRoot(),
		RouterModule.forRoot(
			appRoutes,
			// { enableTracing: true }, // Enabling tracing
			{ onSameUrlNavigation: 'reload'}
		)
	],
	providers: [
		AuthGuard,
		HeaderService,
		AuthService,
		HomeService,
		LoginService,
		SigninService,
		MyPostsService,
		ChangePasswordService,
		ProfilEditionService,
		PostService,
		ByCategoryService,
		CreateUpdatePostService,
		VersionRevisionService,
		SearchService,
		{ provide: HTTP_INTERCEPTORS, useClass: UnauthorizedInterceptor, multi: true }
	],
	bootstrap: [AppComponent]
})
export class AppModule { }
