1 }
/>
);
} else if ( alerts.length === 0 ) {
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': type === 'error',
'is-alert-update': type === 'update',
}
);
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, isResolving } = select( NOTES_STORE_NAME );
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 ) => note.status === 'unactioned';
const alerts = getNotes( alertsQuery ).filter( filterNotes );
const isLoading = isResolving( 'getNotes', [ alertsQuery ] );
return {
alerts,
isLoading,
};
} ),
withDispatch( ( dispatch ) => {
const { triggerNoteAction, updateNote } = dispatch( 'wc-api' );
return {
triggerNoteAction,
updateNote,
};
} )
)( StoreAlerts );