From 63fc2cdcbcf267d1c4f72313c5c6d0f68f201d82 Mon Sep 17 00:00:00 2001 From: jude Date: Sun, 10 Mar 2024 19:43:57 +0000 Subject: [PATCH] Block editing username and avatar on DMs --- .../src/components/Reminder/Avatar.tsx | 28 ++++++++++ .../src/components/Reminder/Message.tsx | 51 +++++++------------ .../src/components/Reminder/Username.tsx | 8 ++- .../src/components/Sidebar/index.tsx | 20 +++++++- web/src/lib.rs | 1 + web/src/routes/dashboard/api/mod.rs | 1 - web/src/routes/dashboard/api/user/mod.rs | 2 +- 7 files changed, 73 insertions(+), 38 deletions(-) create mode 100644 reminder-dashboard/src/components/Reminder/Avatar.tsx diff --git a/reminder-dashboard/src/components/Reminder/Avatar.tsx b/reminder-dashboard/src/components/Reminder/Avatar.tsx new file mode 100644 index 0000000..61127ed --- /dev/null +++ b/reminder-dashboard/src/components/Reminder/Avatar.tsx @@ -0,0 +1,28 @@ +import { ImagePicker } from "./ImagePicker"; +import { useReminder } from "./ReminderContext"; +import { useGuild } from "../App/useGuild"; + +export const Avatar = () => { + const guild = useGuild(); + const [reminder, setReminder] = useReminder(); + + return guild ? ( + { + setReminder((reminder) => ({ + ...reminder, + avatar: url, + })); + }} + > + ) : ( + Image for discord avatar + ); +}; diff --git a/reminder-dashboard/src/components/Reminder/Message.tsx b/reminder-dashboard/src/components/Reminder/Message.tsx index 1b9ba10..07e7e7a 100644 --- a/reminder-dashboard/src/components/Reminder/Message.tsx +++ b/reminder-dashboard/src/components/Reminder/Message.tsx @@ -1,38 +1,23 @@ -import { ImagePicker } from "./ImagePicker"; import { Username } from "./Username"; import { Content } from "./Content"; import { Embed } from "./Embed"; -import { useReminder } from "./ReminderContext"; +import { Avatar } from "./Avatar"; -export const Message = () => { - const [reminder, setReminder] = useReminder(); - - return ( -
-
-
-

- { - setReminder((reminder) => ({ - ...reminder, - avatar: url, - })); - }} - > -

-
-
-
- - - -
+export const Message = () => ( +
+
+
+

+ +

+
+
+
+ + +
-
-
- ); -}; +
+
+
+); diff --git a/reminder-dashboard/src/components/Reminder/Username.tsx b/reminder-dashboard/src/components/Reminder/Username.tsx index 8e2d87a..4edcea2 100644 --- a/reminder-dashboard/src/components/Reminder/Username.tsx +++ b/reminder-dashboard/src/components/Reminder/Username.tsx @@ -1,9 +1,11 @@ import { useReminder } from "./ReminderContext"; +import { useGuild } from "../App/useGuild"; export const Username = () => { + const guild = useGuild(); const [reminder, setReminder] = useReminder(); - return ( + return guild ? (
{ }} >
+ ) : ( +
+ Reminder Bot +
); }; diff --git a/reminder-dashboard/src/components/Sidebar/index.tsx b/reminder-dashboard/src/components/Sidebar/index.tsx index 26c1570..4003e00 100644 --- a/reminder-dashboard/src/components/Sidebar/index.tsx +++ b/reminder-dashboard/src/components/Sidebar/index.tsx @@ -4,16 +4,19 @@ import { MobileSidebar } from "./MobileSidebar"; import { Brand } from "./Brand"; import { Wave } from "./Wave"; import { GuildEntry } from "./GuildEntry"; -import { fetchUserGuilds, GuildInfo } from "../../api"; +import { fetchUserGuilds, fetchUserInfo, GuildInfo } from "../../api"; import { TimezonePicker } from "../TimezonePicker"; import "./styles.scss"; +import { Link, useLocation } from "wouter"; type ContentProps = { guilds: GuildInfo[]; }; const SidebarContent = ({ guilds }: ContentProps) => { - const guildEntries = guilds.map((guild) => ); + const guildEntries = guilds.map((guild) => ); + const [loc] = useLocation(); + const { data: userInfo } = useQuery({ ...fetchUserInfo() }); return ( <> @@ -22,6 +25,19 @@ const SidebarContent = ({ guilds }: ContentProps) => {