root.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import { Grid, Row, Col, Button } from 'react-bootstrap'
  2. import moment from 'moment'
  3. import { useTranslation, Trans } from 'react-i18next'
  4. import getMeta from '@/utils/meta'
  5. import { formatCurrencyLocalized } from '@/shared/utils/currency'
  6. function PreviewSubscriptionChange() {
  7. const { t } = useTranslation()
  8. const preview = getMeta('ol-subscriptionChangePreview')
  9. return (
  10. <Grid>
  11. <Row>
  12. <Col md={8} mdOffset={2}>
  13. <div className="card p-5">
  14. {preview.change.type === 'add-on-purchase' && (
  15. <h1>
  16. {t('add_add_on_to_your_plan', {
  17. addOnName: preview.change.addOn.name,
  18. })}
  19. </h1>
  20. )}
  21. <div className="payment-summary-card mt-5">
  22. <h3>{t('payment_summary')}</h3>
  23. <Row>
  24. <Col xs={9}>
  25. <strong>{t('due_today')}:</strong>
  26. </Col>
  27. <Col xs={3} className="text-right">
  28. <strong>
  29. {formatCurrencyLocalized(
  30. preview.immediateCharge,
  31. preview.currency
  32. )}
  33. </strong>
  34. </Col>
  35. </Row>
  36. <hr />
  37. <div>
  38. <strong>{t('future_payments')}:</strong>
  39. </div>
  40. <Row className="mt-1">
  41. <Col xs={9}>{preview.nextInvoice.plan.name}</Col>
  42. <Col xs={3} className="text-right">
  43. {formatCurrencyLocalized(
  44. preview.nextInvoice.plan.amount,
  45. preview.currency
  46. )}
  47. </Col>
  48. </Row>
  49. {preview.nextInvoice.addOns.map(addOn => (
  50. <Row className="mt-1" key={addOn.code}>
  51. <Col xs={9}>
  52. {addOn.name}
  53. {addOn.quantity > 1 ? ` ×${addOn.quantity}` : ''}
  54. </Col>
  55. <Col xs={3} className="text-right">
  56. {formatCurrencyLocalized(addOn.amount, preview.currency)}
  57. </Col>
  58. </Row>
  59. ))}
  60. {preview.nextInvoice.tax.rate > 0 && (
  61. <Row className="mt-1">
  62. <Col xs={9}>
  63. {t('vat')} {preview.nextInvoice.tax.rate * 100}%
  64. </Col>
  65. <Col xs={3} className="text-right">
  66. {formatCurrencyLocalized(
  67. preview.nextInvoice.tax.amount,
  68. preview.currency
  69. )}
  70. </Col>
  71. </Row>
  72. )}
  73. <Row className="mt-1">
  74. <Col xs={9}>{t('total_per_month')}</Col>
  75. <Col xs={3} className="text-right">
  76. {formatCurrencyLocalized(
  77. preview.nextInvoice.total,
  78. preview.currency
  79. )}
  80. </Col>
  81. </Row>
  82. </div>
  83. <div className="mt-5">
  84. <Trans
  85. i18nKey="the_next_payment_will_be_collected_on"
  86. values={{ date: moment(preview.nextInvoice.date).format('LL') }}
  87. components={{ strong: <strong /> }}
  88. shouldUnescape
  89. tOptions={{ interpolation: { escapeValue: true } }}
  90. />{' '}
  91. <Trans
  92. i18nKey="the_payment_method_used_is"
  93. values={{ paymentMethod: preview.paymentMethod }}
  94. components={{ strong: <strong /> }}
  95. shouldUnescape
  96. tOptions={{ interpolation: { escapeValue: true } }}
  97. />
  98. </div>
  99. <div className="mt-5">
  100. <Button bsStyle="primary" bsSize="large">
  101. {t('pay_now')}
  102. </Button>
  103. </div>
  104. </div>
  105. </Col>
  106. </Row>
  107. </Grid>
  108. )
  109. }
  110. export default PreviewSubscriptionChange