File size: 1,824 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import { Card } from '@automattic/components';
import { useTranslate } from 'i18n-calypso';
import PropTypes from 'prop-types';
import { Fragment } from 'react';
import CardHeading from 'calypso/components/card-heading';
import { useLocalizedMoment } from 'calypso/components/localized-moment';
import './style.scss';
export default function PaymentMethodSidebar( { purchase } ) {
const translate = useTranslate();
return (
<Fragment>
<MainCard purchase={ purchase } />
<Card className="payment-method-sidebar__security-card">
<CardHeading tagName="h1" size={ 16 } isBold className="payment-method-sidebar__title">
{ translate( 'Security' ) }
</CardHeading>
<p className="payment-method-sidebar__paragraph">
{ translate(
'Your payment details are safe. We will transfer them over an encrypted connection and store them on a certified payment processing server.'
) }
</p>
</Card>
</Fragment>
);
}
function MainCard( { purchase } ) {
const translate = useTranslate();
const moment = useLocalizedMoment();
if ( purchase ) {
const purchaseMessaging = purchase.renewDate
? translate( 'Next payment on %s', { args: moment( purchase.renewDate ).format( 'LL' ) } )
: translate( 'Expires on %s', { args: moment( purchase.expiryDate ).format( 'LL' ) } );
return (
<Card className="payment-method-sidebar__details-card">
<CardHeading tagName="h1" size={ 16 } isBold className="payment-method-sidebar__title">
{ translate( 'Purchase Details' ) }
</CardHeading>
<p className="payment-method-sidebar__paragraph">
{ purchase.productName } <br />
<span className="payment-method-sidebar__date">{ purchaseMessaging }</span>
</p>
</Card>
);
}
return null;
}
PaymentMethodSidebar.propTypes = {
purchase: PropTypes.object,
};
|