2023-08-27 16:41:23 +00:00
|
|
|
function loadErrors() {
|
2023-09-03 14:01:42 +00:00
|
|
|
return fetch(
|
2023-09-03 15:00:49 +00:00
|
|
|
`/dashboard/api/guild/${guildId()}/reminders?status=deleted,sent,failed`
|
2023-09-03 14:01:42 +00:00
|
|
|
).then((response) => response.json());
|
2023-08-27 16:41:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("paneLoad", (ev) => {
|
2023-09-03 14:01:42 +00:00
|
|
|
if (ev.detail.pane !== "errors") {
|
2023-08-27 16:41:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-03 15:00:49 +00:00
|
|
|
document.querySelectorAll(".reminderError").forEach((el) => el.remove());
|
|
|
|
|
|
|
|
const template = document.getElementById("reminderError");
|
|
|
|
const container = document.getElementById("reminderLog");
|
|
|
|
|
2023-09-09 14:34:43 +00:00
|
|
|
loadErrors()
|
|
|
|
.then((res) => {
|
2023-09-16 16:59:03 +00:00
|
|
|
res = res
|
|
|
|
.filter((r) => r.status_change_time !== null)
|
|
|
|
.sort((a, b) => a.status_change_time < b.status_change_time);
|
|
|
|
|
2023-09-09 14:34:43 +00:00
|
|
|
for (const reminder of res) {
|
|
|
|
const newRow = template.content.cloneNode(true);
|
2023-09-03 15:00:49 +00:00
|
|
|
|
2023-09-09 14:34:43 +00:00
|
|
|
newRow.querySelector(".reminderError").dataset["case"] = reminder.status;
|
2023-09-03 15:00:49 +00:00
|
|
|
|
2023-09-09 14:34:43 +00:00
|
|
|
const statusTime = new luxon.DateTime.fromISO(
|
|
|
|
reminder.status_change_time,
|
|
|
|
{ zone: "UTC" }
|
|
|
|
);
|
|
|
|
newRow.querySelector(".reminderName").textContent = reminder.name;
|
2023-09-17 13:09:50 +00:00
|
|
|
newRow.querySelector(".reminderMessage").textContent =
|
|
|
|
reminder.status_message;
|
2023-09-09 14:34:43 +00:00
|
|
|
newRow.querySelector(".reminderTime").textContent = statusTime
|
|
|
|
.toLocal()
|
|
|
|
.toLocaleString(luxon.DateTime.DATETIME_MED);
|
2023-08-27 16:41:23 +00:00
|
|
|
|
2023-09-09 14:34:43 +00:00
|
|
|
container.appendChild(newRow);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
$loader.classList.add("is-hidden");
|
|
|
|
});
|
2023-08-27 16:41:23 +00:00
|
|
|
});
|