Add loading state for Campaigns card.
This commit is contained in:
parent
30d316886c
commit
af4f79ab28
|
@ -8,35 +8,60 @@ import { Icon, megaphone } from '@wordpress/icons';
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { CardHeaderTitle } from '~/marketing/components';
|
||||
import { CardHeaderTitle, CenteredSpinner } from '~/marketing/components';
|
||||
import { useCampaigns } from './useCampaigns';
|
||||
import './Campaigns.scss';
|
||||
|
||||
export const Campaigns = () => {
|
||||
return (
|
||||
<Card className="woocommerce-marketing-campaigns-card">
|
||||
<CardHeader>
|
||||
<CardHeaderTitle>
|
||||
{ __( 'Campaigns', 'woocommerce' ) }
|
||||
</CardHeaderTitle>
|
||||
<Button variant="secondary">
|
||||
{ __( 'Create new campaign', 'woocommerce' ) }
|
||||
</Button>
|
||||
</CardHeader>
|
||||
<CardBody className="woocommerce-marketing-campaigns-card-body-empty-content">
|
||||
<Icon icon={ megaphone } size={ 32 } />
|
||||
<div className="woocommerce-marketing-campaigns-card-body-empty-content-title">
|
||||
{ __(
|
||||
'Advertise with marketing campaigns',
|
||||
'woocommerce'
|
||||
) }
|
||||
</div>
|
||||
<div>
|
||||
{ __(
|
||||
'Easily create and manage marketing campaigns without leaving WooCommerce.',
|
||||
'woocommerce'
|
||||
) }
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
const { loading, data } = useCampaigns();
|
||||
|
||||
if ( loading ) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardHeaderTitle>
|
||||
{ __( 'Campaigns', 'woocommerce' ) }
|
||||
</CardHeaderTitle>
|
||||
<Button variant="secondary">
|
||||
{ __( 'Create new campaign', 'woocommerce' ) }
|
||||
</Button>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<CenteredSpinner />
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
if ( data.length === 0 ) {
|
||||
return (
|
||||
<Card className="woocommerce-marketing-campaigns-card">
|
||||
<CardHeader>
|
||||
<CardHeaderTitle>
|
||||
{ __( 'Campaigns', 'woocommerce' ) }
|
||||
</CardHeaderTitle>
|
||||
<Button variant="secondary">
|
||||
{ __( 'Create new campaign', 'woocommerce' ) }
|
||||
</Button>
|
||||
</CardHeader>
|
||||
<CardBody className="woocommerce-marketing-campaigns-card-body-empty-content">
|
||||
<Icon icon={ megaphone } size={ 32 } />
|
||||
<div className="woocommerce-marketing-campaigns-card-body-empty-content-title">
|
||||
{ __(
|
||||
'Advertise with marketing campaigns',
|
||||
'woocommerce'
|
||||
) }
|
||||
</div>
|
||||
<div>
|
||||
{ __(
|
||||
'Easily create and manage marketing campaigns without leaving WooCommerce.',
|
||||
'woocommerce'
|
||||
) }
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
return <div>TODO: campaigns here.</div>;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// TODO: testing for loading state.
|
||||
export const useCampaigns = () => {
|
||||
return {
|
||||
loading: true,
|
||||
data: [],
|
||||
};
|
||||
};
|
||||
|
||||
// TODO: testing for empty data.
|
||||
// export const useCampaigns = () => {
|
||||
// return {
|
||||
// loading: false,
|
||||
// data: [],
|
||||
// };
|
||||
// };
|
Loading…
Reference in New Issue