/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { useState } from '@wordpress/element'; import { 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' ) } ); } // TODO: error message here. if ( ! data ) { return
error
; } if ( data.length === 0 ) { return ( { __( 'Campaigns', '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' ) } { return [ { display: ( { { el.title } { el.description && ( { el.description } ) } ), }, { display: el.cost }, ]; } ) } /> { setPage( newPage ); } } /> ); };