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';

// Components
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { LoginComponent } from './login/login.component';
import { DisconnectionComponent } from './disconnection/disconnection.component';
import { HomeComponent } from './home/home.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';

// Reusable components
import { PostCardComponent } from './core/post-card/post-card.component';
import { SpinnerComponent } from './core/directives/spinner/spinner.component';

// Services
import { HeaderService } from './header/header.service';
import { AuthService } from './core/services/auth.service';
import { HomeService } from './home/home.service';
import { LoginService } from './login/login.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 { UnauthorizedInterceptor } from './core/interceptors/unauthorized.interceptor';

@NgModule({
	declarations: [
		AppComponent,
		HeaderComponent,
		LoginComponent,
		DisconnectionComponent,
		HomeComponent,
		PostCardComponent,
		SpinnerComponent,
		MyPostsComponent,
		AccountSettingsComponent,
		ChangePasswordComponent,
		ProfilEditionComponent
	],
	imports: [
		BrowserModule,
		FormsModule,
		HttpModule,
		HttpClientModule,
		MDBBootstrapModule.forRoot(),
		RouterModule.forRoot(
			appRoutes,
			// { enableTracing: true } // Enabling tracing
			{ onSameUrlNavigation: 'reload' }
		)
	],
	providers: [
		AuthGuard,
		HeaderService,
		AuthService,
		HomeService,
		LoginService,
		MyPostsService,
		ChangePasswordService,
		ProfilEditionService,
		{ provide: HTTP_INTERCEPTORS, useClass: UnauthorizedInterceptor, multi: true }
	],
	bootstrap: [AppComponent]
})
export class AppModule { }
