billing: Show success text after plan change on top after reload.

This commit is contained in:
Aman Agrawal 2023-11-13 15:06:27 +00:00 committed by Tim Abbott
parent 67bddb3d72
commit 637e9c11ee
2 changed files with 26 additions and 7 deletions

View File

@ -179,9 +179,6 @@
{% endif %}
</form>
<input name="status" type="hidden" value="{{ CustomerPlan.DOWNGRADE_AT_END_OF_CYCLE }}" />
<div id="planchange-success" class="alert alert-success billing-page-success">
Plan updated. The page will now reload.
</div>
{% if onboarding %}
<div id="onboarding-go-to-org" class="input-box upgrade-page-field">
<a class="not-editable-realm-field" href="/"><b>Go to your Zulip organization</b></a>

View File

@ -170,11 +170,33 @@ export function initialize(): void {
},
);
$(
"#confirm-cancel-subscription-modal .dialog_submit_button, #reactivate-subscription .reactivate-current-plan-button, #confirm-end-free-trial .dialog_submit_button",
).on("click", (e) => {
$("#confirm-cancel-subscription-modal .dialog_submit_button").on("click", (e) => {
helpers.create_ajax_request("/json/billing/plan", "planchange", [], "PATCH", () =>
window.location.replace("/billing/"),
window.location.replace(
"/billing/?success_message=" +
encodeURIComponent("Your plan has been canceled and will not renew."),
),
);
e.preventDefault();
});
$("#reactivate-subscription .reactivate-current-plan-button").on("click", (e) => {
helpers.create_ajax_request("/json/billing/plan", "planchange", [], "PATCH", () =>
window.location.replace(
"/billing/?success_message=" +
encodeURIComponent(
"Your plan has been reactivated and will renew automatically.",
),
),
);
e.preventDefault();
});
$("#confirm-end-free-trial .dialog_submit_button").on("click", (e) => {
helpers.create_ajax_request("/json/billing/plan", "planchange", [], "PATCH", () =>
window.location.replace(
"/billing/?success_message=" + encodeURIComponent("Successfully ended trial!"),
),
);
e.preventDefault();
});