Start work on todo list support for dashboard

This commit is contained in:
jude
2024-04-06 14:27:58 +01:00
parent b951db3f55
commit 9989ab3b35
8 changed files with 170 additions and 5 deletions

View File

@ -49,6 +49,12 @@ export type Reminder = {
utc_time: string;
};
export type Todo = {
id: string;
channel_id: string;
value: string;
};
export type ChannelInfo = {
id: string;
name: string;
@ -190,6 +196,33 @@ export const deleteGuildTemplate = (guild: string) => ({
}),
});
export const fetchGuildTodos = (guild: string) => ({
queryKey: ["GUILD_TODOS", guild],
queryFn: () =>
axios.get(`/dashboard/api/guild/${guild}/todos`).then((resp) => resp.data) as Promise<
Todo[]
>,
staleTime: OTHER_STALE_TIME,
});
export const patchGuildTodo = (guild: string) => ({
mutationFn: (todo: Todo) => axios.patch(`/dashboard/api/guild/${guild}/todos`, todo),
});
export const postGuildTodo = (guild: string) => ({
mutationFn: (reminder: Reminder) =>
axios.post(`/dashboard/api/guild/${guild}/todos`, reminder).then((resp) => resp.data),
});
export const deleteGuildTodo = () => ({
mutationFn: (todo: Todo) =>
axios.delete(`/dashboard/api/todos`, {
data: {
id: todo.id,
},
}),
});
export const fetchUserReminders = () => ({
queryKey: ["USER_REMINDERS"],
queryFn: () =>