Change NewCampaignTypes to CampaignTypes.

This commit is contained in:
Gan Eng Chin 2023-03-09 21:52:11 +08:00
parent 39ce470fe8
commit f19969dacb
No known key found for this signature in database
GPG Key ID: 94D5D972860ADB01
6 changed files with 20 additions and 20 deletions

View File

@ -1,4 +1,4 @@
export { useInstalledPlugins } from './useInstalledPlugins';
export { useRegisteredChannels } from './useRegisteredChannels';
export { useRecommendedChannels } from './useRecommendedChannels';
export { useNewCampaignTypes } from './useNewCampaignTypes';
export { useCampaignTypes } from './useCampaignTypes';

View File

@ -14,7 +14,7 @@ import {
} from '~/marketing/data-multichannel/types';
import { CampaignType } from '~/marketing/types/CampaignType';
type UseNewCampaignTypes = {
type UseCampaignTypes = {
loading: boolean;
data?: Array< CampaignType >;
error?: ApiFetchError;
@ -32,7 +32,7 @@ const convert = ( campaignType: APICampaignType ): CampaignType => {
};
};
export const useNewCampaignTypes = (): UseNewCampaignTypes => {
export const useCampaignTypes = (): UseCampaignTypes => {
return useSelect( ( select ) => {
const { hasFinishedResolution, getCampaignTypes } = select( STORE_KEY );
const campaignTypesState = getCampaignTypes< CampaignTypesState >();

View File

@ -8,7 +8,7 @@ import userEvent from '@testing-library/user-event';
* Internal dependencies
*/
import { useCampaigns } from './useCampaigns';
import { useNewCampaignTypes } from '~/marketing/hooks';
import { useCampaignTypes } from '~/marketing/hooks';
import { Campaigns } from './Campaigns';
jest.mock( './useCampaigns', () => ( {
@ -16,7 +16,7 @@ jest.mock( './useCampaigns', () => ( {
} ) );
jest.mock( '~/marketing/hooks', () => ( {
useNewCampaignTypes: jest.fn(),
useCampaignTypes: jest.fn(),
} ) );
jest.mock( './CreateNewCampaignModal', () => ( {
@ -47,7 +47,7 @@ describe( 'Campaigns component', () => {
data: undefined,
meta: undefined,
} );
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
loading: true,
} );
@ -66,7 +66,7 @@ describe( 'Campaigns component', () => {
data: undefined,
meta: undefined,
} );
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
loading: false,
} );
@ -86,7 +86,7 @@ describe( 'Campaigns component', () => {
total: 0,
},
} );
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
loading: false,
} );
@ -106,7 +106,7 @@ describe( 'Campaigns component', () => {
total: 1,
},
} );
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
loading: false,
} );
@ -135,7 +135,7 @@ describe( 'Campaigns component', () => {
total: 6,
},
} );
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
loading: false,
} );
@ -165,7 +165,7 @@ describe( 'Campaigns component', () => {
total: 1,
},
} );
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
loading: false,
} );

View File

@ -25,7 +25,7 @@ import {
* Internal dependencies
*/
import { CardHeaderTitle } from '~/marketing/components';
import { useNewCampaignTypes } from '~/marketing/hooks';
import { useCampaignTypes } from '~/marketing/hooks';
import { useCampaigns } from './useCampaigns';
import { CreateNewCampaignModal } from './CreateNewCampaignModal';
import './Campaigns.scss';
@ -66,7 +66,7 @@ export const Campaigns = () => {
data,
meta,
} = useCampaigns( page, perPage );
const { loading: loadingNewCampaignTypes } = useNewCampaignTypes();
const { loading: loadingNewCampaignTypes } = useCampaignTypes();
const total = meta?.total;
const getContent = () => {

View File

@ -8,7 +8,7 @@ import userEvent from '@testing-library/user-event';
* Internal dependencies
*/
import {
useNewCampaignTypes,
useCampaignTypes,
useRecommendedChannels,
useRegisteredChannels,
} from '~/marketing/hooks';
@ -25,14 +25,14 @@ jest.mock( '@woocommerce/components', () => {
} );
jest.mock( '~/marketing/hooks', () => ( {
useNewCampaignTypes: jest.fn(),
useCampaignTypes: jest.fn(),
useRecommendedChannels: jest.fn(),
useRegisteredChannels: jest.fn(),
} ) );
describe( 'CreateNewCampaignModal component', () => {
it( 'renders new campaign types with recommended channels', async () => {
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
data: [
{
id: 'google-ads',
@ -118,7 +118,7 @@ describe( 'CreateNewCampaignModal component', () => {
} );
it( 'does not render recommended channels section when there are no recommended channels', async () => {
( useNewCampaignTypes as jest.Mock ).mockReturnValue( {
( useCampaignTypes as jest.Mock ).mockReturnValue( {
data: [
{
id: 'google-ads',

View File

@ -20,7 +20,7 @@ import classnames from 'classnames';
*/
import {
useRecommendedChannels,
useNewCampaignTypes,
useCampaignTypes,
useRegisteredChannels,
} from '~/marketing/hooks';
import { SmartPluginCardBody } from '~/marketing/components';
@ -40,7 +40,7 @@ type CreateCampaignModalProps = Omit< Modal.Props, 'title' | 'children' >;
export const CreateNewCampaignModal = ( props: CreateCampaignModalProps ) => {
const { className, ...restProps } = props;
const [ collapsed, setCollapsed ] = useState( true );
const { data: newCampaignTypes } = useNewCampaignTypes();
const { data: campaignTypes } = useCampaignTypes();
const { data: recommendedChannels } = useRecommendedChannels();
const { refetch } = useRegisteredChannels();
@ -61,7 +61,7 @@ export const CreateNewCampaignModal = ( props: CreateCampaignModalProps ) => {
) }
</div>
<div>
{ newCampaignTypes?.map( ( el ) => {
{ campaignTypes?.map( ( el ) => {
return (
<Flex
key={ el.id }