Commit 37d75a97 authored by Aral Balkan's avatar Aral Balkan

Display patronage status in the “at a glance” section

parent a2f53081
......@@ -41,6 +41,7 @@
<h2>At a glance</h2>
<ul>
<li><strong>Status:</strong> <span id='patronage-status'>${patronageStatus}</span></li>
<li><strong>Patron since:</strong> ${patronSinceRelative} (${patronSinceAbsolute})</strong>
<li><strong>Amount:</strong><span id='patronageAmountDisplay'>${patronageAmount}</span>/month</li>
<li><strong>Last payment:</strong> ${currentPeriodStartRelative} (${currentPeriodStartAbsolute})</li>
......@@ -78,6 +79,7 @@
<script>
const subscriptionId = '${subscriptionId}'
const subscriptionStatus = '${subscriptionStatus}'
const planId = '${planId}'
const itemId = '${itemId}'
const currentAmount = ${patronageAmount}
......
......@@ -14,11 +14,7 @@ window.addEventListener('load', _ => {
response = JSON.parse(message.data)
if (response.error) {
Modal.fire(
'Error',
error,
'error'
)
Modal.fire('Error', error, 'error')
return
}
......@@ -41,6 +37,7 @@ window.addEventListener('load', _ => {
$('#pauseButton').value = 'Pause my patronage'
$('#pauseButton').disabled = false
$('#resume-your-patronage').hidden = false
$('#patronage-status').innerHTML = 'paused'
Modal.fire(
'Patronage paused',
`Your patronage has been paused effective immediately. You can resume it again at any time. Thank you for supporting us.`,
......@@ -53,6 +50,7 @@ window.addEventListener('load', _ => {
$('#resumeButton').value = 'Resume my patronage'
$('#resumeButton').disabled = false
$('#pause-your-patronage').hidden = false
$('#patronage-status').innerHTML = 'active'
Modal.fire(
'Patronage resumed',
`Your patronage has been resumed effective immediately. You can pause it again at any time. Thank you for supporting us.`,
......
......@@ -62,8 +62,8 @@ module.exports = async (request, response, next) => {
const currentPeriodEndAbsolute = lowercaseFirstLetter(currentPeriodEndMoment.calendar())
const patronageAmount = subscription.quantity
const isPaused = subscription.discount !== null
const patronageStatus = subscriptionStatus === 'active' ? (isPaused ? 'paused' : 'active') : subscriptionStatus
// Newly-created?
let newPatronMessage = ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment