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

84 lines
1.6 KiB
TypeScript
Raw Normal View History

/**
* Internal dependencies
*/
import { TYPES } from './action-types';
import {
ApiFetchError,
RegisteredChannel,
RecommendedChannel,
Campaign,
} from './types';
export const receiveRegisteredChannelsSuccess = (
channels: Array< RegisteredChannel >
) => {
return {
type: TYPES.RECEIVE_REGISTERED_CHANNELS_SUCCESS,
payload: channels,
};
};
export const receiveRegisteredChannelsError = ( error: ApiFetchError ) => {
return {
type: TYPES.RECEIVE_REGISTERED_CHANNELS_ERROR,
payload: error,
error: true,
};
};
2023-01-19 11:33:51 +00:00
export const receiveRecommendedChannelsSuccess = (
2023-01-20 18:14:36 +00:00
channels: Array< RecommendedChannel >
2023-01-19 11:33:51 +00:00
) => {
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,
};
};
2023-02-24 10:32:33 +00:00
export const receiveCampaignsSuccess = ( success: {
2023-02-23 18:10:37 +00:00
payload: Array< Campaign >;
error: boolean;
meta: {
page: number;
perPage: number;
total?: number;
2023-02-23 18:10:37 +00:00
};
} ) => {
return {
type: TYPES.RECEIVE_CAMPAIGNS_SUCCESS,
2023-02-24 10:32:33 +00:00
...success,
};
};
2023-02-24 10:32:33 +00:00
export const receiveCampaignsError = ( error: {
payload: ApiFetchError;
error: boolean;
meta: {
page: number;
perPage: number;
total?: number;
};
} ) => {
return {
type: TYPES.RECEIVE_CAMPAIGNS_ERROR,
2023-02-24 10:32:33 +00:00
...error,
};
};
export type Action = ReturnType<
| typeof receiveRegisteredChannelsSuccess
| typeof receiveRegisteredChannelsError
2023-01-19 11:33:51 +00:00
| typeof receiveRecommendedChannelsSuccess
| typeof receiveRecommendedChannelsError
| typeof receiveCampaignsSuccess
| typeof receiveCampaignsError
>;