billing: Fix free trial billing page end plan button not working.

This commit is contained in:
Aman Agrawal 2023-11-09 14:15:19 +00:00
parent 0f31f18744
commit df703f847c
2 changed files with 38 additions and 14 deletions

View File

@ -144,11 +144,8 @@
<div id="planchange-error" class="alert alert-danger"></div> <div id="planchange-error" class="alert alert-danger"></div>
<div id="planchange-input-section"> <div id="planchange-input-section">
{% if free_trial %} {% if free_trial %}
<div class="end-free-trail"> <div class="end-free-trial plan-toggle-action input-box billing-page-field no-validation" id="end-free-trial">
<p> <button class="end-free-trial-button plan-toggle-action-button">
End Free Trial and downgrade plan to <strong>Zulip Free</strong>.
</p>
<button class="end-free-trail-button">
<span class="billing-button-text">End free trial</span> <span class="billing-button-text">End free trial</span>
<object class="loader billing-button-loader" type="image/svg+xml" data="{{ static('images/loading/loader-white.svg') }}"></object> <object class="loader billing-button-loader" type="image/svg+xml" data="{{ static('images/loading/loader-white.svg') }}"></object>
</button> </button>
@ -207,6 +204,29 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div id="confirm-end-free-trial" class="micromodal" aria-hidden="true">
<div class="modal__overlay" tabindex="-1">
<div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="dialog_title">
<header class="modal__header">
<h1 class="modal__title dialog_heading">
Confirm end free trial
</h1>
<button class="modal__close" aria-label="{{ _('Close modal') }}" data-micromodal-close></button>
</header>
<main class="modal__content">
<p>
Are you sure you want to end free trial and downgrade plan to <strong>Zulip Free</strong>?
</p>
</main>
<footer class="modal__footer">
<button class="modal__btn dialog_exit_button" aria-label="{{ '(Close this dialog window)' }}" data-micromodal-close>{{ _('Cancel') }}</button>
<button class="modal__btn dialog_submit_button">
<span>{{ _('Confirm') }}</span>
</button>
</footer>
</div>
</div>
</div>
<div id="confirm-licenses-modal-increase" class="micromodal" aria-hidden="true"> <div id="confirm-licenses-modal-increase" class="micromodal" aria-hidden="true">
<div class="modal__overlay" tabindex="-1"> <div class="modal__overlay" tabindex="-1">
<div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="dialog_title"> <div class="modal__container" role="dialog" aria-modal="true" aria-labelledby="dialog_title">

View File

@ -166,21 +166,25 @@ export function initialize(): void {
}, },
); );
$("#confirm-cancel-subscription-modal .dialog_submit_button, #reactivate-subscription").on( $(
"click", "#confirm-cancel-subscription-modal .dialog_submit_button, #reactivate-subscription, #confirm-end-free-trial .dialog_submit_button",
(e) => { ).on("click", (e) => {
helpers.create_ajax_request("/json/billing/plan", "planchange", [], "PATCH", () => helpers.create_ajax_request("/json/billing/plan", "planchange", [], "PATCH", () =>
window.location.replace("/billing/"), window.location.replace("/billing/"),
); );
e.preventDefault(); e.preventDefault();
}, });
);
$("#cancel-subscription").on("click", (e) => { $("#cancel-subscription").on("click", (e) => {
e.preventDefault(); e.preventDefault();
portico_modals.open("confirm-cancel-subscription-modal"); portico_modals.open("confirm-cancel-subscription-modal");
}); });
$("#end-free-trial").on("click", (e) => {
e.preventDefault();
portico_modals.open("confirm-end-free-trial");
});
$("#current-manual-license-count").on("keyup", () => { $("#current-manual-license-count").on("keyup", () => {
const {new_current_manual_license_count, old_current_manual_license_count} = const {new_current_manual_license_count, old_current_manual_license_count} =
get_old_and_new_license_count_for_current_cycle(); get_old_and_new_license_count_for_current_cycle();