upgrade: Show user/month plurals based on their count.

This commit is contained in:
Aman Agrawal 2023-11-11 12:45:16 +00:00 committed by Tim Abbott
parent b516ae75db
commit 2a70143050
2 changed files with 12 additions and 3 deletions

View File

@ -90,8 +90,10 @@
{% else %} {% else %}
<span class="due-today-license-count">{{ seat_count }}</span> <span class="due-today-license-count">{{ seat_count }}</span>
{% endif %} {% endif %}
users x <span class="due-today-license-count-user-plural">
<span class="due-today-duration"></span> month {{ 'user' if seat_count == 1 else 'users' }}
</span> x
<span class="due-today-duration"></span>
<h1>$<span class="due-today-price"></span></h1> <h1>$<span class="due-today-price"></span></h1>
</div> </div>
</div> </div>

View File

@ -27,7 +27,7 @@ export const initialize = (): void => {
if (schedule === "monthly") { if (schedule === "monthly") {
num_months = 1; num_months = 1;
} }
$("#due-today .due-today-duration").text(num_months); $("#due-today .due-today-duration").text(num_months === 1 ? "1 month" : "12 months");
const schedule_typed = helpers.schedule_schema.parse(schedule); const schedule_typed = helpers.schedule_schema.parse(schedule);
$(".due-today-price").text( $(".due-today-price").text(
helpers.format_money(current_license_count * prices[schedule_typed]), helpers.format_money(current_license_count * prices[schedule_typed]),
@ -59,6 +59,13 @@ export const initialize = (): void => {
return; return;
} }
$("#due-today .due-today-license-count").text(license_count); $("#due-today .due-today-license-count").text(license_count);
const $user_plural = $("#due-today .due-today-license-count-user-plural");
if (license_count === 1) {
$user_plural.text("user");
} else {
$user_plural.text("users");
}
current_license_count = license_count; current_license_count = license_count;
update_due_today(selected_schedule); update_due_today(selected_schedule);
}); });