import { ApplicationConfig, provideBrowserGlobalErrorListeners ,
  provideAppInitializer} from '@angular/core';
import { provideRouter, withComponentInputBinding } from '@angular/router';
import { providePrimeNG } from 'primeng/config';
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { ConfirmationService, MessageService } from 'primeng/api';
import { routes } from './app.routes';
import MyPreset from './mythem';
import { JwtInterceptor, ErrorInterceptor, initializeApp } from './shares';

import { provideStore } from '@ngrx/store';
import { provideStoreDevtools } from '@ngrx/store-devtools';
import { isDevMode } from '@angular/core';
import { provideEffects } from '@ngrx/effects';
import { staffEffects,staffsReducer } from './state';

export const appConfig: ApplicationConfig = {
  providers: [
    provideStore({
        myStaffs: staffsReducer,
    }),
    provideEffects([staffEffects]),
    provideStoreDevtools({
        maxAge: 30,
        logOnly: !isDevMode()
    }),
    provideBrowserGlobalErrorListeners(),
    MessageService, ConfirmationService,
    provideAppInitializer(initializeApp()),
    provideHttpClient(withInterceptors([JwtInterceptor, ErrorInterceptor])),
    provideRouter(routes, withComponentInputBinding()),
    providePrimeNG({
        theme: {
            preset: MyPreset,
            options: {
                cssLayer: {
                    name: 'primeng',
                    order: 'theme, base, primeng'
                }
            }
        }
    }),
    
]
};

/*
$) ng build --base-href "/FamilyTreeUI/" -c production
*/

/*
 
import { Store } from '@ngrx/store'; 
 private readonly store = inject(Store);
 protected books = this.store.selectSignal(selectBooks);
 protected onAdd(id: number) {
    this.store.dispatch(StaffsActions.addStaff({ id }));
  }

  protected onRemove(id: number) {
    this.store.dispatch(StaffsActions.removeStaff({ id }));
  }
 on ngOnInit() {
 use it normal get from API first
and subscribe( (x) => this.store.dispatch(StaffApiAction.LoadStaffList({x})))
}
*/