From 40633349537447d920e1204749785904157fb789 Mon Sep 17 00:00:00 2001 From: jude Date: Tue, 9 Apr 2024 21:21:46 +0100 Subject: [PATCH] More work on todo list --- reminder-dashboard/src/api.ts | 18 +-- .../src/components/Guild/index.tsx | 9 +- .../src/components/Todo/CreateTodo.tsx | 70 +++++++++- src/web/mod.rs | 23 ++- src/web/routes/dashboard/api/guild/mod.rs | 3 +- src/web/routes/dashboard/api/guild/todos.rs | 132 ++++++++++++++++-- src/web/routes/dashboard/mod.rs | 36 +++-- 7 files changed, 242 insertions(+), 49 deletions(-) diff --git a/reminder-dashboard/src/api.ts b/reminder-dashboard/src/api.ts index 086b7bc..bb336c3 100644 --- a/reminder-dashboard/src/api.ts +++ b/reminder-dashboard/src/api.ts @@ -54,6 +54,11 @@ export type Todo = { value: string; }; +export type CreateTodo = { + channel_id: string; + value: string; +}; + export type ChannelInfo = { id: string; name: string; @@ -209,17 +214,12 @@ export const patchGuildTodo = (guild: string) => ({ }); export const postGuildTodo = (guild: string) => ({ - mutationFn: (reminder: Reminder) => - axios.post(`/dashboard/api/guild/${guild}/todos`, reminder).then((resp) => resp.data), + mutationFn: (todo: CreateTodo) => + axios.post(`/dashboard/api/guild/${guild}/todos`, todo).then((resp) => resp.data), }); -export const deleteGuildTodo = () => ({ - mutationFn: (todo: Todo) => - axios.delete(`/dashboard/api/todos`, { - data: { - id: todo.id, - }, - }), +export const deleteGuildTodo = (guild: string) => ({ + mutationFn: (todoId: number) => axios.delete(`/dashboard/api/guild/${guild}/todos/${todoId}`), }); export const fetchUserReminders = () => ({ diff --git a/reminder-dashboard/src/components/Guild/index.tsx b/reminder-dashboard/src/components/Guild/index.tsx index 957f6cd..631d0c2 100644 --- a/reminder-dashboard/src/components/Guild/index.tsx +++ b/reminder-dashboard/src/components/Guild/index.tsx @@ -5,6 +5,7 @@ import { createPortal, PropsWithChildren } from "preact/compat"; import { Import } from "../Import"; import { useGuild } from "../App/useGuild"; import { Link } from "wouter"; +import { usePathname } from "wouter/use-browser-location"; import "./index.scss"; @@ -18,13 +19,14 @@ export const Guild = ({ children }: PropsWithChildren) => { return ; } else { const importModal = createPortal(, document.getElementById("bottom-sidebar")); + const path = usePathname(); return ( <> {importModal}