/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; import { Card, CardBody, CardFooter, Flex, FlexItem, FlexBlock, } from '@wordpress/components'; import { Icon, megaphone } from '@wordpress/icons'; import { Pagination, Table } from '@woocommerce/components'; /** * Internal dependencies */ import { CenteredSpinner } from '~/marketing/components'; import { useCampaigns } from './useCampaigns'; import './Campaigns.scss'; import { CampaignsCardHeader } from './CampaignsCardHeader'; export const Campaigns = () => { const [ page, setPage ] = useState( 1 ); const { loading, data } = useCampaigns(); if ( loading ) { return ( ); } if ( data.length === 0 ) { return (
{ __( 'Advertise with marketing campaigns', 'woocommerce' ) }
{ __( 'Easily create and manage marketing campaigns without leaving WooCommerce.', 'woocommerce' ) }
); } const perPage = 5; const total = data.length; const start = ( page - 1 ) * perPage; const pagedData = data.slice( start, start + perPage ); return ( el.id ) } rows={ pagedData.map( ( el ) => { return [ { display: ( { { el.title } { el.description } ), }, { display: el.cost }, ]; } ) } /> { setPage( newPage ); } } /> ); };