import CommonActionCreator from "../models/client/CommonActionCreator" ; import { AnyAction as Action } from "redux" ; import { getToast as toast } from "../shared/toast" ; import { INVALID_TOKEN_ERROR } from "../shared/constants" ; import EnUS from "../shared/translations/en-us" ; import FabAction from "../models/client/FabAction" ; import moment from "moment" ; export const RESET_REDIRECT = "RESET_REDIRECT" ; export const SET_LOCALE = "SET_LOCALE" ; export const SET_FAB_ACTIONS = "SET_FAB_ACTIONS" ; export const ADD_FAB_ACTION = "ADD_FAB_ACTION" ; export const REMOVE_FAB_ACTION = "REMOVE_FAB_ACTION" ; const actions = { handleFetchError ( type , error ) { if ( error . message === INVALID_TOKEN_ERROR ) { return { type } ; } if ( error . message === EnUS . messages [ "app.connect_error" ] ) { toast ( ) . error ( "app.connect_error" ) ; } else if ( error . message ) { toast ( ) . error ( error . message ) ; } else if ( error . name ) { toast ( ) . error ( error . name ) ; } return { type } ; } , resetRedirectTask ( ) { return { type : RESET_REDIRECT } ; } , setLocale ( locale ) { moment . locale ( locale ) ; return { type : SET_LOCALE , locale : locale } ; } , setFabActions ( fabActions ) { return { type : SET_FAB_ACTIONS , fabActions : fabActions } ; } , addFabAction ( fabAction ) { return { type : ADD_FAB_ACTION , fabAction : fabAction } ; } , removeFabAction ( iconName ) { return { type : REMOVE_FAB_ACTION , iconName : iconName } ; } } ; export default actions ;