Initial DDC release
This commit is contained in:
commit
434f6441da
57 files changed
+4606
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
||||
import { api } from "./api.js";
|
||||
|
||||
export function setupLogin(form, errorElement, onSuccess) {
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
errorElement.textContent = "";
|
||||
const formData = new FormData(form);
|
||||
|
||||
try {
|
||||
await api.login(formData.get("username"), formData.get("password"));
|
||||
form.reset();
|
||||
await onSuccess();
|
||||
} catch (error) {
|
||||
errorElement.textContent = error.message;
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user