File size: 1,186 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import { useLocale } from '@automattic/i18n-utils';
import { useTranslate } from 'i18n-calypso';
import { useSelector } from 'react-redux';
import Notice from 'calypso/components/notice';
import { getCurrentPartner } from 'calypso/state/partner-portal/partner/selectors';
export default function MissingPaymentNotification() {
const partner = useSelector( getCurrentPartner );
const locale = useLocale();
const translate = useTranslate();
if ( ! partner || ! partner.keys ) {
return null;
}
const firstUnpaidInvoice = partner.keys.find(
( key ) => key.latestInvoice && key.latestInvoice.status === 'open'
)?.latestInvoice;
if ( firstUnpaidInvoice ) {
const warningText = translate(
"The payment for your %s invoice didn't go through. Please take a moment to complete payment.",
{
args: new Date( Number( firstUnpaidInvoice.effectiveAt ) * 1000 ).toLocaleString( locale, {
month: 'long',
} ),
}
);
return (
<Notice className="is-warning" showDismiss={ false } text={ warningText }>
<a href="/partner-portal/invoices" className="calypso-notice__link">
{ translate( 'View Invoice' ) }
</a>
</Notice>
);
}
return null;
}
|