diff --git a/reminder-dashboard/src/api.ts b/reminder-dashboard/src/api.ts index 76eca8a..d97ea1a 100644 --- a/reminder-dashboard/src/api.ts +++ b/reminder-dashboard/src/api.ts @@ -129,9 +129,13 @@ export const fetchGuildInfo = (guild: string) => ({ export const fetchGuildChannels = (guild: string) => ({ queryKey: ["GUILD_CHANNELS", guild], queryFn: () => - axios.get(`/dashboard/api/guild/${guild}/channels`).then((resp) => resp.data) as Promise< - ChannelInfo[] - >, + axios + .get(`/dashboard/api/guild/${guild}/channels`) + .then((resp) => + resp.data.sort((a: ChannelInfo, b: ChannelInfo) => + a.name == b.name ? 0 : a.name > b.name ? 1 : -1, + ), + ) as Promise, staleTime: GUILD_INFO_STALE_TIME, }); diff --git a/reminder-dashboard/src/components/Guild/GuildTodos.tsx b/reminder-dashboard/src/components/Guild/GuildTodos.tsx index 8eb9b77..291cd2b 100644 --- a/reminder-dashboard/src/components/Guild/GuildTodos.tsx +++ b/reminder-dashboard/src/components/Guild/GuildTodos.tsx @@ -19,10 +19,6 @@ export const GuildTodos = () => { return ( <> - Create Todo - -
- Todo list

Server

{channels.map((channel) => { return ( @@ -35,6 +31,7 @@ export const GuildTodos = () => { ))} + ); })} diff --git a/reminder-dashboard/src/components/Todo/CreateTodo.tsx b/reminder-dashboard/src/components/Todo/CreateTodo.tsx index a3a0597..224efd1 100644 --- a/reminder-dashboard/src/components/Todo/CreateTodo.tsx +++ b/reminder-dashboard/src/components/Todo/CreateTodo.tsx @@ -1,20 +1,19 @@ -import { useMutation, useQuery, useQueryClient } from "react-query"; -import { fetchGuildChannels, postGuildTodo } from "../../api"; +import { useMutation, useQueryClient } from "react-query"; +import { postGuildTodo } from "../../api"; import { useGuild } from "../App/useGuild"; import { useState } from "preact/hooks"; import { useFlash } from "../App/FlashContext"; import { ICON_FLASH_TIME } from "../../consts"; -export const CreateTodo = () => { +export const CreateTodo = ({ channel }) => { const guild = useGuild(); const [recentlyCreated, setRecentlyCreated] = useState(false); - const [newTodo, setNewTodo] = useState({ value: "", channel_id: null }); + const [newTodo, setNewTodo] = useState({ value: "", channel_id: channel }); const flash = useFlash(); const queryClient = useQueryClient(); - const { isSuccess, data: channels } = useQuery(fetchGuildChannels(guild)); const mutation = useMutation({ ...postGuildTodo(guild), onSuccess: (data) => { @@ -45,26 +44,6 @@ export const CreateTodo = () => { class="input todo-input" onInput={(ev) => setNewTodo((todo) => ({ ...todo, value: ev.currentTarget.value }))} /> -
-
- -
-
- -
-