import { ActionTypes, Message } from '../actions' import { BreadcrumbParams } from '../breadcrumbs' import { ToastParams } from '../toasts' export const ACTIONS = { START_LOADING: (): Message => ({ action: { type: ActionTypes.START_LOADING }, }), STOP_LOADING: (): Message => ({ action: { type: ActionTypes.STOP_LOADING }, }), INSERT_BREADCRUMB_EXTRA_LEVELS: (params: BreadcrumbParams[]): Message => ({ action: { type: ActionTypes.INSERT_BREADCRUMB_EXTRA_LEVELS, breadcrumbs: params.map( ({ newLevelId, newLevelName, newLevelUrl }, index) => ({ newLevelId: newLevelId ?? `${index}-${newLevelName}`, newLevelName, newLevelUrl: newLevelUrl ?? window.location.pathname, }) ), }, }), CLEAR_BREADCRUMB_EXTRA_LEVELS: (): Message => ({ action: { type: ActionTypes.CLEAR_BREADCRUMB_EXTRA_LEVELS, }, }), SHOW_TOAST: ({ payload }: ToastParams): Message => ({ action: { type: ActionTypes.SHOW_TOAST, payload, }, }), HIDE_TOAST: (): Message => ({ action: { type: ActionTypes.HIDE_TOAST, }, }), }