Download wp-calypso/client/state/google-my-business/reducer.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/google-my-business/reducer.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/google-my-business/reducer.js
-
curl -L -o reducer.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/google-my-business/reducer.js
1.4 kB
| import { withStorageKey } from '@automattic/state-utils'; | |
| import { | |
| GOOGLE_MY_BUSINESS_STATS_FAILURE, | |
| GOOGLE_MY_BUSINESS_STATS_RECEIVE, | |
| GOOGLE_MY_BUSINESS_STATS_REQUEST, | |
| } from 'calypso/state/action-types'; | |
| import { statsInterval } from 'calypso/state/google-my-business/ui/reducer'; | |
| import { combineReducers, keyedReducer } from 'calypso/state/utils'; | |
| const stats = ( state = null, action ) => { | |
| switch ( action.type ) { | |
| case GOOGLE_MY_BUSINESS_STATS_RECEIVE: { | |
| const { data } = action; | |
| return data; | |
| } | |
| case GOOGLE_MY_BUSINESS_STATS_REQUEST: | |
| return null; | |
| case GOOGLE_MY_BUSINESS_STATS_FAILURE: | |
| return null; | |
| } | |
| return state; | |
| }; | |
| const statsError = ( state = null, action ) => { | |
| switch ( action.type ) { | |
| case GOOGLE_MY_BUSINESS_STATS_RECEIVE: | |
| return null; | |
| case GOOGLE_MY_BUSINESS_STATS_REQUEST: | |
| return null; | |
| case GOOGLE_MY_BUSINESS_STATS_FAILURE: { | |
| const { error } = action; | |
| return error; | |
| } | |
| } | |
| return state; | |
| }; | |
| const combinedReducer = keyedReducer( | |
| 'siteId', | |
| combineReducers( { | |
| stats: keyedReducer( | |
| 'statType', | |
| keyedReducer( 'interval', keyedReducer( 'aggregation', stats ) ) | |
| ), | |
| statsError: keyedReducer( | |
| 'statType', | |
| keyedReducer( 'interval', keyedReducer( 'aggregation', statsError ) ) | |
| ), | |
| statsInterval: keyedReducer( 'statType', statsInterval ), | |
| } ) | |
| ); | |
| export default withStorageKey( 'googleMyBusiness', combinedReducer ); | |