Download wp-calypso/client/state/data-layer/wpcom/activity-log/share/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/activity-log/share/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/data-layer/wpcom/activity-log/share/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/activity-log/share/index.js
1.46 kB
| import { translate } from 'i18n-calypso'; | |
| import { REWIND_ACTIVITY_SHARE_REQUEST } from 'calypso/state/action-types'; | |
| import { recordTracksEvent, withAnalytics } from 'calypso/state/analytics/actions'; | |
| 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 { errorNotice, successNotice } from 'calypso/state/notices/actions'; | |
| const requestShare = ( action ) => | |
| http( | |
| { | |
| apiNamespace: 'wpcom/v2', | |
| method: 'POST', | |
| path: `/sites/${ action.siteId }/activity/${ action.rewindId }/share`, | |
| body: { email: action.email }, | |
| }, | |
| action | |
| ); | |
| const successfulShare = ( { siteId, rewindId } ) => | |
| withAnalytics( | |
| recordTracksEvent( 'calypso_activity_event_share_success', { | |
| site_id: siteId, | |
| rewind_id: rewindId, | |
| } ), | |
| successNotice( translate( "We've shared the event!" ) ) | |
| ); | |
| const failedShare = ( { siteId, rewindId } ) => | |
| withAnalytics( | |
| recordTracksEvent( 'calypso_activity_event_share_failed', { | |
| site_id: siteId, | |
| rewind_id: rewindId, | |
| } ), | |
| errorNotice( translate( 'The event failed to send, please try again.' ) ) | |
| ); | |
| registerHandlers( 'state/data-layer/wpcom/activity-log/share/index.js', { | |
| [ REWIND_ACTIVITY_SHARE_REQUEST ]: [ | |
| dispatchRequest( { | |
| fetch: requestShare, | |
| onSuccess: successfulShare, | |
| onError: failedShare, | |
| } ), | |
| ], | |
| } ); | |