diff --git a/reminder-dashboard/src/components/Guild/GuildReminders.tsx b/reminder-dashboard/src/components/Guild/GuildReminders.tsx index f67dfe6..d4dcb0e 100644 --- a/reminder-dashboard/src/components/Guild/GuildReminders.tsx +++ b/reminder-dashboard/src/components/Guild/GuildReminders.tsx @@ -4,6 +4,7 @@ import { fetchGuildChannels, fetchGuildReminders } from "../../api"; import { EditReminder } from "../Reminder/EditReminder"; import { CreateReminder } from "../Reminder/CreateReminder"; import { useState } from "preact/hooks"; +import { Loader } from "../Loader"; enum Sort { Time = "time", @@ -14,7 +15,12 @@ enum Sort { export const GuildReminders = () => { const { guild } = useParams(); - const { isSuccess, isFetching, data: guildReminders } = useQuery(fetchGuildReminders(guild)); + const { + isSuccess, + isFetching, + isFetched, + data: guildReminders, + } = useQuery(fetchGuildReminders(guild)); const { data: channels } = useQuery(fetchGuildChannels(guild)); const [collapsed, setCollapsed] = useState(false); @@ -23,108 +29,114 @@ export const GuildReminders = () => { let prevReminder = null; return ( -
- Create Reminder -
- -
-

-
-
-
- Reminders -
-
-
-
- -
-
- + <> + {!isFetched && } +
+ Create Reminder +
+ +
+

+
+
+
+ Reminders +
+
+
+
+ +
+
+ +
-
-
-
-
- -
-
- +
+
+
+ +
+
+ +
-
-
- {isSuccess && - guildReminders - .sort((r1, r2) => { - if (sort === Sort.Time) { - return r1.utc_time > r2.utc_time ? 1 : -1; - } else if (sort === Sort.Name) { - return r1.name > r2.name ? 1 : -1; - } else { - return r1.channel > r2.channel ? 1 : -1; - } - }) - .map((reminder) => { - let breaker = <>; - if (sort === Sort.Channel && channels) { - if ( - prevReminder === null || - prevReminder.channel !== reminder.channel - ) { - const channel = channels.find( - (ch) => ch.id === reminder.channel, - ); - breaker =
#{channel.name}
; +
+ {isSuccess && + guildReminders + .sort((r1, r2) => { + if (sort === Sort.Time) { + return r1.utc_time > r2.utc_time ? 1 : -1; + } else if (sort === Sort.Name) { + return r1.name > r2.name ? 1 : -1; + } else { + return r1.channel > r2.channel ? 1 : -1; + } + }) + .map((reminder) => { + let breaker = <>; + if (sort === Sort.Channel && channels) { + if ( + prevReminder === null || + prevReminder.channel !== reminder.channel + ) { + const channel = channels.find( + (ch) => ch.id === reminder.channel, + ); + breaker =
#{channel.name}
; + } } - } - prevReminder = reminder; + prevReminder = reminder; - return ( - <> - {breaker} - - - ); - })} + return ( + <> + {breaker} + + + ); + })} +
-
+ ); }; diff --git a/reminder-dashboard/src/components/Loader/index.tsx b/reminder-dashboard/src/components/Loader/index.tsx new file mode 100644 index 0000000..6e95999 --- /dev/null +++ b/reminder-dashboard/src/components/Loader/index.tsx @@ -0,0 +1,8 @@ +export const Loader = () => ( +
+
+

Loading...

+ +
+
+); diff --git a/web/static/css/style.css b/web/static/css/style.css index 71d329d..477d506 100644 --- a/web/static/css/style.css +++ b/web/static/css/style.css @@ -714,6 +714,24 @@ li.highlight { pointer-events: none; } +.load-screen { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background-color: rgba(255, 255, 255, 0.8); + pointer-events: none; + z-index: 999; + font-size: 2rem; + font-weight: bolder; + text-align: center; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; +} + /* END */ div.reminderError {