import * as BlogCatalog from './reducers/BlogCatalog'
import * as BlogCategories from './reducers/BlogCategories'
import * as BlogFeatured from './reducers/BlogFeatured'
import * as BlogItem from './reducers/BlogItem'

import * as Counter from './reducers/Counter'
import * as Header from './reducers/Header'
import * as Loader from './reducers/Loader'

import * as Content from './reducers/Content'

import * as ShopCatalog from './reducers/ShopCatalog'
import * as ShopCategories from './reducers/ShopCategories'
import * as ShopFeatured from './reducers/ShopFeatured'
import * as ShopItem from './reducers/ShopItem'
import * as ShopRelated from './reducers/ShopRelated'
import * as ShopCart from './reducers/ShopCart'

import * as WeatherForecasts from './reducers/WeatherForecasts'

// The top-level state object
export interface ApplicationState {
  blogCatalog: BlogCatalog.BlogCatalogState | undefined
  blogCategories: BlogCategories.BlogCategoriesState | undefined
  blogFeatured: BlogFeatured.BlogFeaturedState | undefined
  blogItem: BlogItem.BlogItemState | undefined

  content: Content.ContentState | undefined

  counter: Counter.CounterState | undefined
  header: Header.HeaderState | undefined
  loader: Loader.LoaderState | undefined

  shopCatalog: ShopCatalog.ShopCatalogState | undefined
  shopCategories: ShopCategories.ShopCategoriesState | undefined
  shopFeatured: ShopFeatured.ShopFeaturedState | undefined
  shopItem: ShopItem.ShopItemState | undefined
  shopRelated: ShopRelated.ShopRelatedState | undefined
  shopCart: ShopCart.ShopCartState | undefined

  weatherForecasts: WeatherForecasts.WeatherForecastsState | undefined
}

// Whenever an action is dispatched, Redux will update each top-level application state property using
// the reducer with the matching name. It's important that the names match exactly, and that the reducer
// acts on the corresponding ApplicationState property type.
export const reducers = {
  blogCatalog: BlogCatalog.reducer,
  blogCategories: BlogCategories.reducer,
  blogFeatured: BlogFeatured.reducer,
  blogItem: BlogItem.reducer,

  content: Content.reducer,

  counter: Counter.reducer,
  header: Header.reducer,
  loader: Loader.reducer,

  shopCatalog: ShopCatalog.reducer,
  shopCategories: ShopCategories.reducer,
  shopFeatured: ShopFeatured.reducer,
  shopItem: ShopItem.reducer,
  shopRelated: ShopRelated.reducer,
  shopCart: ShopCart.reducer,

  weatherForecasts: WeatherForecasts.reducer
}

// This type can be used as a hint on action creators so that its 'dispatch' and 'getState' params are
// correctly typed to match your store.
export interface AppThunkAction<TAction> {
  (dispatch: (action: TAction) => void, getState: () => ApplicationState): void
}
