Fix editor

This commit is contained in:
Christopher Cookman 2024-12-21 02:25:57 -07:00
parent a28f672516
commit 023e4da2f9

View file

@ -6,10 +6,11 @@ const alertBox = (type, message) => {
}; };
// Set expiresTimestamp to the time in const ban.expiresTimestamp (convert from js date number to local time string that conforms with html form values) // Set expiresTimestamp to the time in const ban.expiresTimestamp (convert from js date number to local time string that conforms with html form values)
const expiresTimestamp = document.getElementById('expiresTimestamp').value; if (ban.expiresTimestamp !== null) {
const expiresDate = new Date(ban.expiresTimestamp) const expiresTimestamp = document.getElementById('expiresTimestamp').value;
document.getElementById('expiresTimestamp').value = new Date(expiresDate.getTime() - (expiresDate.getTimezoneOffset() * 60000)).toISOString().slice(0, 16); const expiresDate = new Date(ban.expiresTimestamp)
document.getElementById('expiresTimestamp').value = new Date(expiresDate.getTime() - (expiresDate.getTimezoneOffset() * 60000)).toISOString().slice(0, 16);
}
var reasonFlags = {}; var reasonFlags = {};
@ -24,7 +25,7 @@ fetch('/api/v1/info')
document.getElementById('banForm').addEventListener('submit', function (event) { document.getElementById('banForm').addEventListener('submit', function (event) {
event.preventDefault(); event.preventDefault();
// Combine flag values // Combine flag values
const checkboxes = document.querySelectorAll('.flag-checkbox'); const checkboxes = document.querySelectorAll('.flag-checkbox');
let combinedFlags = 0; let combinedFlags = 0;
@ -53,20 +54,20 @@ document.getElementById('banForm').addEventListener('submit', function (event) {
}, },
body: JSON.stringify(data) body: JSON.stringify(data)
}) })
.then(response => response.json()) .then(response => response.json())
.then(result => { .then(result => {
if (result.success) { if (result.success) {
console.log('Success:', result); console.log('Success:', result);
// Handle success (e.g., show a success message, redirect, etc.) // Handle success (e.g., show a success message, redirect, etc.)
window.location.href = '/admin'; window.location.href = '/admin';
} else { } else {
console.error('Error:', result.message); console.error('Error:', result.message);
alertBox('alert-danger', 'An error has occurred: ' + result.message); alertBox('alert-danger', 'An error has occurred: ' + result.message);
} }
}) })
.catch(error => { .catch(error => {
console.error('Error:', error); console.error('Error:', error);
alertBox('alert-danger', 'An error has occurred. Please contact support.\n' + error); alertBox('alert-danger', 'An error has occurred. Please contact support.\n' + error);
// Handle error (e.g., show an error message) // Handle error (e.g., show an error message)
}); });
}); });