import { useQuery } from "react-query";
import { fetchGuildInfo } from "../../api";
import { useParams } from "wouter";
import { GuildReminders } from "./GuildReminders";
import { GuildError } from "./GuildError";

export const Guild = () => {
    const { guild } = useParams();
    const { isSuccess, data: guildInfo } = useQuery(fetchGuildInfo(guild));

    if (!isSuccess) {
        return <></>;
    } else if (guildInfo.error) {
        return <GuildError />;
    } else {
        return <GuildReminders />;
    }
};
