/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; import { Button, Card, CardHeader, CardBody, CardFooter, Flex, FlexItem, FlexBlock, } from '@wordpress/components'; import { Icon, megaphone } from '@wordpress/icons'; import { Pagination, Table } from '@woocommerce/components'; /** * Internal dependencies */ import { CardHeaderTitle, CenteredSpinner } from '~/marketing/components'; import { useCampaigns } from './useCampaigns'; import './Campaigns.scss'; export const Campaigns = () => { const [ page, setPage ] = useState( 1 ); const { loading, data } = useCampaigns(); if ( loading ) { return ( { __( 'Campaigns', 'woocommerce' ) } { __( 'Create new campaign', 'woocommerce' ) } ); } if ( data.length === 0 ) { return ( { __( 'Campaigns', 'woocommerce' ) } { __( 'Create new campaign', 'woocommerce' ) } { __( '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 ( { __( 'Campaigns', 'woocommerce' ) } { __( 'Create new campaign', 'woocommerce' ) } el.id ) } rows={ pagedData.map( ( el ) => { return [ { display: ( { el.title } { el.description } ), }, { display: el.cost }, ]; } ) } /> { setPage( newPage ); } } /> ); };