import { fetchGuildChannels, fetchUserInfo, Reminder } from "../../api"; import { useQueries } from "react-query"; import { QueryKeys } from "../../consts"; import { useParams } from "wouter"; import { Name } from "./Name"; import { Username } from "./Username"; import { Content } from "./Content"; import { ChannelSelector } from "./ChannelSelector"; import { useState } from "preact/hooks"; import { IntervalSelector } from "./IntervalSelector"; import { Embed } from "./Embed"; type Props = { reminder: Reminder; }; export const EditReminder = ({ reminder }: Props) => { const { guild } = useParams(); 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 <>; } const channelInfo = guildChannels.find((c) => c.id === reminder.channel); return (
#{channelInfo.name}
Intervals available on{" "} Patreon or{" "} self-hosting
); };