billing helpers: Fix implicit use of any.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-05-04 23:58:56 -07:00 committed by Tim Abbott
parent d1e2fefad2
commit fbfdc19cc0
1 changed files with 6 additions and 5 deletions

View File

@ -97,17 +97,18 @@ export function create_ajax_request(
},
error(xhr) {
$(form_loading).hide();
if (xhr.responseJSON?.msg) {
$(form_error).show().text(xhr.responseJSON.msg);
const parsed = z.object({msg: z.string()}).safeParse(xhr.responseJSON);
if (parsed.success) {
$(form_error).show().text(parsed.data.msg);
}
$(form_input_section).show();
error_callback(xhr);
if (xhr.status === 401) {
// User session timed out, we need to login again.
const login_url = JSON.parse(xhr.responseText)?.login_url;
if (login_url !== undefined) {
window.location.href = login_url;
const parsed = z.object({login_url: z.string()}).safeParse(xhr.responseJSON);
if (parsed.success) {
window.location.href = parsed.data.login_url;
}
}
},