import * as actions from './actions' import * as helper from './helper' import reducer from './reducer' const reducerName = '@@ORDER_LIB_STATE' export default { actions, reducer, helper, reducerName, } declare global { type GetStateFunction = () => {[reducerName]: IOrderLibState} type ThunkDispatchFunction = (action: IAction | ThunkFunction) => any type ThunkFunction = (dispatch: ThunkDispatchFunction, getState: GetStateFunction) => void interface IAction { type: string payload?: { [key: string]: any } } interface IOrderLibState { // * Menu rootCategory: IAppCategory // single category tree rootSetCategory: IAppCategory // set category tree categories: { [categoryId: string]: IAppCategory } // category map include set and single menus: { [menuId: string]: IAppMenuItem } sets: { [menuId: string]: IAppSet } selectedCategory: IAppCategory selectedSet: IAppSet selectedSetStep: IAppSetStep // * Order selectedOrder: IAppOrder // * Batch selectedBatch: IAppOrderBatch selectedItemKey: string selectedSetItemKey: string | { setMenuIndex: number } | { serial: number } // * Batch (other) menuItemQuantities: IMenuItemQuantity batchStashes: IBatchHistory[] batchHistory: IBatchHistories } type TItemKey = string | null type TSetItemKey = string | { setMenuIndex: number } | { serial: number } | null interface IBatchHistory { selectedItemKey: TItemKey selectedSetItemKey: TSetItemKey batch: IAppOrderBatch menuItemQuantities: IMenuItemQuantity createdAt: Date } interface IBatchHistories { preBatchHistories: IBatchHistory[] pastBatchHistories: IBatchHistory[] } interface IMenuItemQuantity { [menuId: string]: number } }