Download wp-calypso/client/state/currency-code/reducer.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 786 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/currency-code/reducer.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/currency-code/reducer.js
-
curl -L -o reducer.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/currency-code/reducer.js
786 Bytes
| import { withStorageKey } from '@automattic/state-utils'; | |
| import { | |
| SITE_PLANS_FETCH_COMPLETED, | |
| PRODUCTS_LIST_RECEIVE, | |
| SITE_PRODUCTS_FETCH_COMPLETED, | |
| } from 'calypso/state/action-types'; | |
| import { withSchemaValidation } from 'calypso/state/utils'; | |
| const schema = { type: [ 'string', 'null' ] }; | |
| function reducer( state = null, action ) { | |
| switch ( action.type ) { | |
| case PRODUCTS_LIST_RECEIVE: | |
| return Object.values( action.productsList )[ 0 ]?.currency_code ?? state; | |
| case SITE_PLANS_FETCH_COMPLETED: | |
| return action.plans[ 0 ]?.currencyCode ?? state; | |
| case SITE_PRODUCTS_FETCH_COMPLETED: | |
| return Object.values( action.products )[ 0 ]?.currency_code ?? state; | |
| } | |
| return state; | |
| } | |
| export default withStorageKey( 'currencyCode', withSchemaValidation( schema, reducer ) ); | |