From e36d2610dabc98c1cd6b4b99be84c0cf6615fe03 Mon Sep 17 00:00:00 2001 From: jude Date: Mon, 30 Oct 2023 21:24:05 +0000 Subject: [PATCH] Add reminder creator --- src/components/GuildReminders/index.tsx | 5 +- .../ChannelSelector.tsx | 0 .../{EditReminder => Reminder}/Content.tsx | 0 src/components/Reminder/CreateReminder.tsx | 231 ++++++++++++++++++ .../index.tsx => Reminder/EditReminder.tsx} | 4 +- .../Embed/Author.tsx | 0 .../Embed/Color.tsx | 0 .../Embed/Description.tsx | 0 .../Embed/Footer.tsx | 0 .../Embed/Title.tsx | 0 .../Embed/index.tsx | 0 .../IntervalSelector.tsx | 0 .../{EditReminder => Reminder}/Name.tsx | 0 .../{EditReminder => Reminder}/Username.tsx | 0 14 files changed, 237 insertions(+), 3 deletions(-) rename src/components/{EditReminder => Reminder}/ChannelSelector.tsx (100%) rename src/components/{EditReminder => Reminder}/Content.tsx (100%) create mode 100644 src/components/Reminder/CreateReminder.tsx rename src/components/{EditReminder/index.tsx => Reminder/EditReminder.tsx} (98%) rename src/components/{EditReminder => Reminder}/Embed/Author.tsx (100%) rename src/components/{EditReminder => Reminder}/Embed/Color.tsx (100%) rename src/components/{EditReminder => Reminder}/Embed/Description.tsx (100%) rename src/components/{EditReminder => Reminder}/Embed/Footer.tsx (100%) rename src/components/{EditReminder => Reminder}/Embed/Title.tsx (100%) rename src/components/{EditReminder => Reminder}/Embed/index.tsx (100%) rename src/components/{EditReminder => Reminder}/IntervalSelector.tsx (100%) rename src/components/{EditReminder => Reminder}/Name.tsx (100%) rename src/components/{EditReminder => Reminder}/Username.tsx (100%) diff --git a/src/components/GuildReminders/index.tsx b/src/components/GuildReminders/index.tsx index 76b7f83..e273418 100644 --- a/src/components/GuildReminders/index.tsx +++ b/src/components/GuildReminders/index.tsx @@ -2,7 +2,8 @@ import { useParams } from "wouter"; import { useQuery } from "react-query"; import { fetchGuildReminders } from "../../api"; import { QueryKeys } from "../../consts"; -import { EditReminder } from "../EditReminder"; +import { EditReminder } from "../Reminder/EditReminder"; +import { CreateReminder } from "../Reminder/CreateReminder"; export const GuildReminders = () => { const { guild } = useParams(); @@ -16,7 +17,7 @@ export const GuildReminders = () => {
Create Reminder
- <> +


diff --git a/src/components/EditReminder/ChannelSelector.tsx b/src/components/Reminder/ChannelSelector.tsx similarity index 100% rename from src/components/EditReminder/ChannelSelector.tsx rename to src/components/Reminder/ChannelSelector.tsx diff --git a/src/components/EditReminder/Content.tsx b/src/components/Reminder/Content.tsx similarity index 100% rename from src/components/EditReminder/Content.tsx rename to src/components/Reminder/Content.tsx diff --git a/src/components/Reminder/CreateReminder.tsx b/src/components/Reminder/CreateReminder.tsx new file mode 100644 index 0000000..7b6d3ea --- /dev/null +++ b/src/components/Reminder/CreateReminder.tsx @@ -0,0 +1,231 @@ +import { useParams } from "wouter"; +import { useState } from "preact/hooks"; +import { useQueries } from "react-query"; +import { QueryKeys } from "../../consts"; +import { fetchGuildChannels, fetchUserInfo } from "../../api"; +import { Name } from "./Name"; +import { Username } from "./Username"; +import React from "react"; +import { Content } from "./Content"; +import { Embed } from "./Embed"; +import { ChannelSelector } from "./ChannelSelector"; +import { DateTime } from "luxon"; +import { IntervalSelector } from "./IntervalSelector"; + +export const CreateReminder = () => { + const { guild } = useParams(); + const [reminder, setReminder] = useState({}); + + const [ + { isSuccess: channelsFetched, data: guildChannels }, + { isSuccess: userFetched, data: userInfo }, + ] = useQueries([ + { + queryKey: [QueryKeys.GUILD_CHANNELS, guild], + queryFn: () => fetchGuildChannels(guild), + staleTime: 300, + }, + { + queryKey: [QueryKeys.USER_DATA], + queryFn: fetchUserInfo, + staleTime: Infinity, + }, + ]); + + const [collapsed, setCollapsed] = useState(false); + + if (!channelsFetched || !userFetched) { + // todo + return <>; + } + + return ( +
+
+ +
+ +
+
+
+
+
+
+

+ + Image for discord avatar + +

+
+
+
+ { + setReminder((reminder) => ({ + ...reminder, + username, + })); + }} + > + { + setReminder((reminder) => ({ + ...reminder, + content, + })); + }} + > + +
+
+
+
+
+
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+
+ Intervals available on{" "} + Patreon or{" "} + + self-hosting + +
+
+ + +
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+ ); +}; diff --git a/src/components/EditReminder/index.tsx b/src/components/Reminder/EditReminder.tsx similarity index 98% rename from src/components/EditReminder/index.tsx rename to src/components/Reminder/EditReminder.tsx index 6f4dfc9..54768d2 100644 --- a/src/components/EditReminder/index.tsx +++ b/src/components/Reminder/EditReminder.tsx @@ -137,7 +137,9 @@ export const EditReminder = ({ reminder: initialReminder }: Props) => {
-
+
Intervals available on{" "} Patreon or{" "} diff --git a/src/components/EditReminder/Embed/Author.tsx b/src/components/Reminder/Embed/Author.tsx similarity index 100% rename from src/components/EditReminder/Embed/Author.tsx rename to src/components/Reminder/Embed/Author.tsx diff --git a/src/components/EditReminder/Embed/Color.tsx b/src/components/Reminder/Embed/Color.tsx similarity index 100% rename from src/components/EditReminder/Embed/Color.tsx rename to src/components/Reminder/Embed/Color.tsx diff --git a/src/components/EditReminder/Embed/Description.tsx b/src/components/Reminder/Embed/Description.tsx similarity index 100% rename from src/components/EditReminder/Embed/Description.tsx rename to src/components/Reminder/Embed/Description.tsx diff --git a/src/components/EditReminder/Embed/Footer.tsx b/src/components/Reminder/Embed/Footer.tsx similarity index 100% rename from src/components/EditReminder/Embed/Footer.tsx rename to src/components/Reminder/Embed/Footer.tsx diff --git a/src/components/EditReminder/Embed/Title.tsx b/src/components/Reminder/Embed/Title.tsx similarity index 100% rename from src/components/EditReminder/Embed/Title.tsx rename to src/components/Reminder/Embed/Title.tsx diff --git a/src/components/EditReminder/Embed/index.tsx b/src/components/Reminder/Embed/index.tsx similarity index 100% rename from src/components/EditReminder/Embed/index.tsx rename to src/components/Reminder/Embed/index.tsx diff --git a/src/components/EditReminder/IntervalSelector.tsx b/src/components/Reminder/IntervalSelector.tsx similarity index 100% rename from src/components/EditReminder/IntervalSelector.tsx rename to src/components/Reminder/IntervalSelector.tsx diff --git a/src/components/EditReminder/Name.tsx b/src/components/Reminder/Name.tsx similarity index 100% rename from src/components/EditReminder/Name.tsx rename to src/components/Reminder/Name.tsx diff --git a/src/components/EditReminder/Username.tsx b/src/components/Reminder/Username.tsx similarity index 100% rename from src/components/EditReminder/Username.tsx rename to src/components/Reminder/Username.tsx