File size: 882 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import {
MEMBERSHIPS_SUBSCRIPTIONS_LIST_REQUEST,
MEMBERSHIPS_SUBSCRIPTIONS_RECEIVE,
} 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';
const noop = () => {};
export const handleSubscribedMembershipsList = dispatchRequest( {
fetch: ( action ) =>
http(
{
method: 'GET',
path: '/me/memberships/subscriptions',
},
action
),
onSuccess: ( action, { subscriptions, total } ) => ( {
type: MEMBERSHIPS_SUBSCRIPTIONS_RECEIVE,
subscriptions,
total,
} ),
onError: noop,
} );
registerHandlers( 'state/data-layer/wpcom/sites/memberships/subscriptions/index.js', {
[ MEMBERSHIPS_SUBSCRIPTIONS_LIST_REQUEST ]: [ handleSubscribedMembershipsList ],
} );
|