Start adding stuff for user reminders

This commit is contained in:
jude 2024-03-03 21:58:48 +00:00
parent 329492b244
commit 85a114e55c
6 changed files with 25 additions and 4 deletions

View File

@ -175,3 +175,10 @@ export const deleteGuildTemplate = (guild: string) => ({
}, },
}), }),
}); });
export const fetchUserReminders = () => ({
queryKey: ["USER_REMINDERS"],
queryFn: () =>
axios.get(`/dashboard/api/user/reminders`).then((resp) => resp.data) as Promise<Reminder[]>,
staleTime: OTHER_STALE_TIME,
});

View File

@ -5,6 +5,7 @@ import { Welcome } from "../Welcome";
import { Guild } from "../Guild"; import { Guild } from "../Guild";
import { FlashProvider } from "./FlashProvider"; import { FlashProvider } from "./FlashProvider";
import { TimezoneProvider } from "./TimezoneProvider"; import { TimezoneProvider } from "./TimezoneProvider";
import { User } from "../User";
export function App() { export function App() {
const queryClient = new QueryClient(); const queryClient = new QueryClient();
@ -18,6 +19,7 @@ export function App() {
<Sidebar /> <Sidebar />
<div class="column is-main-content"> <div class="column is-main-content">
<Switch> <Switch>
<Route path={"/@me/reminders"} component={User}></Route>
<Route path={"/:guild/reminders"} component={Guild}></Route> <Route path={"/:guild/reminders"} component={Guild}></Route>
<Route> <Route>
<Welcome /> <Welcome />

View File

@ -1,10 +1,10 @@
import { useParams } from "wouter";
import { useQuery } from "react-query"; import { useQuery } from "react-query";
import { fetchGuildChannels, fetchGuildReminders } from "../../api"; import { fetchGuildChannels, fetchGuildReminders } from "../../api";
import { EditReminder } from "../Reminder/EditReminder"; import { EditReminder } from "../Reminder/EditReminder";
import { CreateReminder } from "../Reminder/CreateReminder"; import { CreateReminder } from "../Reminder/CreateReminder";
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { Loader } from "../Loader"; import { Loader } from "../Loader";
import { useGuild } from "../App/useGuild";
enum Sort { enum Sort {
Time = "time", Time = "time",
@ -13,7 +13,7 @@ enum Sort {
} }
export const GuildReminders = () => { export const GuildReminders = () => {
const { guild } = useParams(); const guild = useGuild();
const { const {
isSuccess, isSuccess,

View File

@ -1,13 +1,13 @@
import { useQuery } from "react-query"; import { useQuery } from "react-query";
import { fetchGuildInfo } from "../../api"; import { fetchGuildInfo } from "../../api";
import { useParams } from "wouter";
import { GuildReminders } from "./GuildReminders"; import { GuildReminders } from "./GuildReminders";
import { GuildError } from "./GuildError"; import { GuildError } from "./GuildError";
import { createPortal } from "preact/compat"; import { createPortal } from "preact/compat";
import { Import } from "../Import"; import { Import } from "../Import";
import { useGuild } from "../App/useGuild";
export const Guild = () => { export const Guild = () => {
const { guild } = useParams(); const guild = useGuild();
const { isSuccess, data: guildInfo } = useQuery(fetchGuildInfo(guild)); const { isSuccess, data: guildInfo } = useQuery(fetchGuildInfo(guild));
if (!isSuccess) { if (!isSuccess) {

View File

@ -0,0 +1,3 @@
export const UserReminders = () => {
return <></>;
};

View File

@ -0,0 +1,9 @@
import { UserReminders } from "./UserReminders";
export const User = () => {
return (
<>
<UserReminders />
</>
);
};