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

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

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

// 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 { PostCardComponent } from './core/post-card/post-card.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';

// html components
import { ProgressBarComponent } from './core/directives/progress-bar/progress-bar.component';
import { SpinnerComponent } from './core/directives/spinner/spinner.component';
import { SearchBarComponent } from './core/directives/search-bar/search-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';

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

// Interceptors
import { TokenInterceptor } from './core/interceptors/token-interceptor';
import { SigninService } from './signin/signin.service';

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