Download wp-calypso/client/state/ui/checkout/reducer.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 872 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/checkout/reducer.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/ui/checkout/reducer.js
-
curl -L -o reducer.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/checkout/reducer.js
872 Bytes
| import { SECTION_SET } from 'calypso/state/action-types'; | |
| import { combineReducers, withSchemaValidation } from 'calypso/state/utils'; | |
| export const upgradeIntent = withSchemaValidation( { type: 'string' }, ( state = '', action ) => { | |
| if ( action.type !== SECTION_SET ) { | |
| return state; | |
| } | |
| if ( action.isLoading || ! action.section?.name ) { | |
| // Leave the intent alone until the new section is fully loaded | |
| return state; | |
| } | |
| if ( | |
| [ 'checkout', 'checkout-pending', 'checkout-thank-you', 'plans' ].includes( | |
| action.section.name | |
| ) | |
| ) { | |
| // Leave the intent alone for sections that should not clear it | |
| return state; | |
| } | |
| if ( [ 'plugins', 'themes', 'hosting' ].includes( action.section.name ) ) { | |
| return action.section.name; | |
| } | |
| // Clear the intent when any other section is loaded | |
| return ''; | |
| } ); | |
| export default combineReducers( { | |
| upgradeIntent, | |
| } ); | |