diff --git a/src/components/Guild/GuildReminders.tsx b/src/components/Guild/GuildReminders.tsx
index 1b330e4..7d3aaa4 100644
--- a/src/components/Guild/GuildReminders.tsx
+++ b/src/components/Guild/GuildReminders.tsx
@@ -1,13 +1,26 @@
import { useParams } from "wouter";
import { useQuery } from "react-query";
-import { fetchGuildReminders } from "../../api";
+import { fetchGuildChannels, fetchGuildReminders } from "../../api";
import { EditReminder } from "../Reminder/EditReminder";
import { CreateReminder } from "../Reminder/CreateReminder";
+import { useState } from "preact/hooks";
+
+enum Sort {
+ Time = "time",
+ Name = "name",
+ Channel = "channel",
+}
export const GuildReminders = () => {
const { guild } = useParams();
const { isSuccess, data: guildReminders } = useQuery(fetchGuildReminders(guild));
+ const { data: channels } = useQuery(fetchGuildChannels(guild));
+
+ const [collapsed, setCollapsed] = useState(false);
+ const [sort, setSort] = useState(Sort.Time);
+
+ let prevReminder = null;
return (
@@ -24,12 +37,21 @@ export const GuildReminders = () => {
-
@@ -40,7 +62,16 @@ export const GuildReminders = () => {
-
);
diff --git a/src/components/Reminder/ButtonRow/EditButtonRow.tsx b/src/components/Reminder/ButtonRow/EditButtonRow.tsx
index 8500966..a47b74f 100644
--- a/src/components/Reminder/ButtonRow/EditButtonRow.tsx
+++ b/src/components/Reminder/ButtonRow/EditButtonRow.tsx
@@ -16,24 +16,33 @@ export const EditButtonRow = () => {
const iconFlashTimeout = useRef(0);
- console.log(reminder.enabled);
- console.log(reminder.content);
-
+ const flash = useFlash();
const mutation = useMutation({
...patchGuildReminder(guild),
- onSuccess: () => {
+ onSuccess: (response) => {
queryClient.invalidateQueries({
queryKey: ["GUILD_REMINDERS", guild],
});
- setRecentlySaved(true);
if (iconFlashTimeout.current !== null) {
clearTimeout(iconFlashTimeout.current);
}
- iconFlashTimeout.current = setTimeout(() => {
+ if (response.data.errors.length > 0) {
setRecentlySaved(false);
- }, ICON_FLASH_TIME);
+
+ for (const error of response.data.errors) {
+ flash({ message: error, type: "error" });
+ }
+ } else {
+ setRecentlySaved(true);
+
+ iconFlashTimeout.current = setTimeout(() => {
+ setRecentlySaved(false);
+ }, ICON_FLASH_TIME);
+
+ setReminder(response.data.reminder);
+ }
},
});
@@ -64,10 +73,6 @@ export const EditButtonRow = () => {