import { LOCALE_ID, NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { HttpClientModule } from "@angular/common/http";
import { JwtModule } from "@auth0/angular-jwt";
import { ToastrModule } from "ngx-toastr";
import { registerLocaleData } from "@angular/common";
import localeId from "@angular/common/locales/id";
import { HttpInterceptors } from "./cores/interceptors";
import { LightboxModule } from "ngx-lightbox";
import { FormsModule } from "@angular/forms";

registerLocaleData(localeId, "id");

export function tokenGetter(): any {
  return localStorage.getItem("access_jwt_token");
}

export const allowedDomains = ["localhost", "pisdev.my.id"];

@NgModule({
  declarations: [AppComponent],
  imports: [
    LightboxModule,
    BrowserModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    HttpClientModule,
    JwtModule.forRoot({
      config: {
        tokenGetter,
        allowedDomains,
      },
    }),
    ToastrModule.forRoot({
      timeOut: 2500,
      positionClass: "toast-bottom-center",
      preventDuplicates: true,
      progressBar: true,
    }),
    FormsModule,
  ],
  providers: [
    {
      provide: LOCALE_ID,
      useValue: "id-ID",
    },
    HttpInterceptors,
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}
