add: send invite code generation errors to client
This commit is contained in:
parent
4843688fcf
commit
253f11b00c
2 changed files with 10 additions and 3 deletions
|
@ -539,6 +539,7 @@
|
|||
(div
|
||||
("class" "card flex flex-col gap-2 secondary")
|
||||
(pre ("id" "invite_codes_output") ("class" "hidden") (code))
|
||||
(pre ("id" "invite_codes_error_output") ("class" "hidden") (code ("class" "red")))
|
||||
|
||||
(button
|
||||
("onclick" "generate_invite_codes()")
|
||||
|
@ -576,6 +577,7 @@
|
|||
}
|
||||
|
||||
document.getElementById(\"invite_codes_output\").classList.remove(\"hidden\");
|
||||
document.getElementById(\"invite_codes_error_output\").classList.remove(\"hidden\");
|
||||
document.getElementById(\"invite_codes_output\").children[0].innerText = \"Working...\";
|
||||
|
||||
fetch(`/api/v1/invites/${count}`, {
|
||||
|
@ -589,7 +591,8 @@
|
|||
]);
|
||||
|
||||
if (res.ok) {
|
||||
document.getElementById(\"invite_codes_output\").children[0].innerText = res.payload;
|
||||
document.getElementById(\"invite_codes_output\").children[0].innerText = res.payload[0];
|
||||
document.getElementById(\"invite_codes_error_output\").children[0].innerText = res.payload[1];
|
||||
}
|
||||
});
|
||||
};"))))))
|
||||
|
|
|
@ -852,6 +852,7 @@ pub async fn generate_invite_codes_request(
|
|||
}
|
||||
|
||||
let mut out_string = String::new();
|
||||
let mut errors_string = String::new();
|
||||
|
||||
for _ in 0..count {
|
||||
match data
|
||||
|
@ -859,13 +860,16 @@ pub async fn generate_invite_codes_request(
|
|||
.await
|
||||
{
|
||||
Ok(x) => out_string += &(x.code + "\n"),
|
||||
Err(_) => break,
|
||||
Err(e) => {
|
||||
errors_string = e.to_string();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Json(ApiReturn {
|
||||
ok: true,
|
||||
message: "Success".to_string(),
|
||||
payload: Some(out_string),
|
||||
payload: Some((out_string, errors_string)),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue