This commit is contained in:
jude
2022-02-11 20:03:53 +00:00
parent 49974b7153
commit 37420b2b1f
5 changed files with 67 additions and 9 deletions

View File

@ -17,6 +17,7 @@ pub struct Reminder {
attachment: Option<Vec<u8>>,
attachment_name: Option<String>,
avatar: Option<String>,
#[serde(with = "string")]
channel: u64,
content: String,
embed_author: String,
@ -43,6 +44,31 @@ pub struct Reminder {
utc_time: NaiveDateTime,
}
// https://github.com/serde-rs/json/issues/329#issuecomment-305608405
mod string {
use std::fmt::Display;
use std::str::FromStr;
use serde::{de, Deserialize, Deserializer, Serializer};
pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
where
T: Display,
S: Serializer,
{
serializer.collect_str(value)
}
pub fn deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
where
T: FromStr,
T::Err: Display,
D: Deserializer<'de>,
{
String::deserialize(deserializer)?.parse().map_err(de::Error::custom)
}
}
#[derive(Deserialize)]
pub struct DeleteReminder {
uid: String,

View File

@ -404,11 +404,16 @@
if (data.error) {
show_error(data.error);
} else {
const $template = document.querySelector('template#personalReminder');
console.log(data);
const $template = document.querySelector('template#guildReminder');
for (let reminder of data) {
let newFrame = $template.content.cloneNode(true);
// populate channels
newFrame.querySelector('select.channel-selector');
for (let prop in reminder) {
if (reminder.hasOwnProperty(prop) && reminder[prop] !== null) {
let $input = newFrame.querySelector(`*[name="${prop}"]`);
@ -642,11 +647,7 @@
}
});
fetch(`/dashboard/api/guild/${$anchor.dataset['guild']}/reminders`)
.then(response => response.json())
.then(data => {
})
fetch_reminders($anchor.dataset['guild']);
document.querySelectorAll('p.pageTitle').forEach((el) => {
el.textContent = $anchor.dataset['name'] + ' Reminders';

View File

@ -111,7 +111,7 @@
<div class="field">
<div class="control">
<label class="label sr-only">Reminder Name</label>
<input class="input" type="text" placeholder="Reminder Name">
<input class="input" type="text" name="name" placeholder="Reminder Name">
</div>
</div>