/** * External dependencies */ import type { AnyAction } from '@nelio-content/types'; /** * Internal dependencies */ import { INIT } from './config'; import type { FastSpringAction as Action } from './actions'; import type { State } from './config'; export function reducer( state = INIT, action: AnyAction ): State { return actualReducer( state, action as Action ) ?? state; } function actualReducer( state: State, action: Action ): State { switch ( action.type ) { case 'RECEIVE_FS_CURRENCY': return { ...state, currency: action.currency, }; case 'RECEIVE_FS_PRODUCTS': return { ...state, products: action.products, }; } }