1 } />;
} else if ( 0 === alerts.length ) {
return null;
}
const { currentIndex } = this.state;
const numberOfAlerts = alerts.length;
const alert = alerts[ currentIndex ];
const type = alert.type;
const className = classnames( 'woocommerce-store-alerts', 'woocommerce-analytics__card', {
'is-alert-error': 'error' === type,
'is-alert-update': 'update' === type,
} );
return (
,
{ alert.title },
] }
className={ className }
action={
numberOfAlerts > 1 && (
{ interpolateComponents( {
mixedString: __( '{{current /}} of {{total /}}', 'woocommerce-admin' ),
components: {
current: { currentIndex + 1 },
total: { numberOfAlerts },
},
} ) }
)
}
>
{ this.renderActions( alert ) }
);
}
}
export default compose(
withSelect( select => {
const { getNotes, isGetNotesRequesting } = select( 'wc-api' );
const alertsQuery = {
page: 1,
per_page: QUERY_DEFAULTS.pageSize,
type: 'error,update',
status: 'unactioned',
};
// Filter out notes that may have been marked actioned or not delayed after the initial request
const filterNotes = note => 'unactioned' === note.status;
const alerts = getNotes( alertsQuery ).filter( filterNotes );
const isLoading = isGetNotesRequesting( alertsQuery );
return {
alerts,
isLoading,
};
} ),
withDispatch( dispatch => {
const { updateNote } = dispatch( 'wc-api' );
return {
updateNote,
};
} )
)( StoreAlerts );