woocommerce/plugins/woocommerce-admin/client/marketing/data-multichannel/actions.ts

45 lines
1002 B
TypeScript
Raw Normal View History

/**
* Internal dependencies
*/
import { TYPES } from './action-types';
2023-01-19 11:33:51 +00:00
import { ApiFetchError, Channel, RecommendedPlugin } from './types';
export const receiveChannelsSuccess = ( channels: Array< Channel > ) => {
return {
type: TYPES.RECEIVE_CHANNELS_SUCCESS,
payload: channels,
};
};
export const receiveChannelsError = ( error: ApiFetchError ) => {
return {
type: TYPES.RECEIVE_CHANNELS_ERROR,
payload: error,
error: true,
};
};
2023-01-19 11:33:51 +00:00
export const receiveRecommendedChannelsSuccess = (
channels: Array< RecommendedPlugin >
) => {
return {
type: TYPES.RECEIVE_RECOMMENDED_CHANNELS_SUCCESS,
payload: channels,
};
};
export const receiveRecommendedChannelsError = ( error: ApiFetchError ) => {
return {
type: TYPES.RECEIVE_RECOMMENDED_CHANNELS_ERROR,
payload: error,
error: true,
};
};
export type Action = ReturnType<
2023-01-19 11:33:51 +00:00
| typeof receiveChannelsSuccess
| typeof receiveChannelsError
| typeof receiveRecommendedChannelsSuccess
| typeof receiveRecommendedChannelsError
>;