react-code-dataset / wp-calypso /client /state /data-layer /wpcom /sites /stats /module-toggles /index.ts
react-code-dataset / wp-calypso /client /state /data-layer /wpcom /sites /stats /module-toggles /index.ts
Download wp-calypso/client/state/data-layer/wpcom/sites/stats/module-toggles/index.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/sites/stats/module-toggles/index.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/data-layer/wpcom/sites/stats/module-toggles/index.ts
-
curl -L -o index.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/sites/stats/module-toggles/index.ts
1.54 kB
| import { | |
| STATS_MODULE_TOGGLES_REQUEST, | |
| STATS_MODULE_TOGGLES_UPDATE, | |
| } from 'calypso/state/action-types'; | |
| import { registerHandlers } from 'calypso/state/data-layer/handler-registry'; | |
| import { http } from 'calypso/state/data-layer/wpcom-http/actions'; | |
| import { dispatchRequest } from 'calypso/state/data-layer/wpcom-http/utils'; | |
| import { receiveModuleToggles } from 'calypso/state/stats/module-toggles/actions'; | |
| import type { AnyAction } from 'redux'; | |
| export const doUpdateModuleToggles = ( action: AnyAction ) => { | |
| const { siteId } = action; | |
| return [ | |
| http( | |
| { | |
| method: 'POST', | |
| apiNamespace: 'wpcom/v2', | |
| path: `/sites/${ siteId }/jetpack-stats-dashboard/modules`, | |
| body: action.payload, | |
| }, | |
| action | |
| ), | |
| ]; | |
| }; | |
| export const fetch = ( action: AnyAction ) => { | |
| const { siteId } = action; | |
| return [ | |
| http( | |
| { | |
| method: 'GET', | |
| apiNamespace: 'wpcom/v2', | |
| path: `/sites/${ siteId }/jetpack-stats-dashboard/modules`, | |
| body: { | |
| dismissed: true, | |
| }, | |
| }, | |
| action | |
| ), | |
| ]; | |
| }; | |
| export const onSuccess = ( { siteId }: AnyAction, data: object ) => | |
| receiveModuleToggles( siteId, data ); | |
| registerHandlers( 'state/data-layer/wpcom/sites/stats/module-toggles/index.js', { | |
| [ STATS_MODULE_TOGGLES_REQUEST ]: [ | |
| dispatchRequest( { | |
| fetch, | |
| onSuccess, | |
| onError: () => null, | |
| // fromApi, | |
| } ), | |
| ], | |
| [ STATS_MODULE_TOGGLES_UPDATE ]: [ | |
| dispatchRequest( { | |
| fetch: doUpdateModuleToggles, | |
| onSuccess: () => null, | |
| onError: () => null, | |
| // fromApi, | |
| } ), | |
| ], | |
| } ); | |
| export default {}; | |