"use client"; import { getCommunityServerFavorites, getCustomization } from "@/lib/api"; import { useEffect, useState } from "react"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "./ui/card"; import Markdown from "react-markdown"; import { useTheme } from "next-themes"; import FadeIn from "react-fade-in/lib/FadeIn"; import { Button } from "./ui/button"; import { ServerResponse } from "@/lib/types/mh-server"; import { Copy } from "lucide-react"; import toast, { CheckmarkIcon } from "react-hot-toast"; import { MHSF } from "@/lib/mhsf"; import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; export default function AfterServerView({ server }: { server: string }) { const [description, setDescription] = useState(""); const [discord, setDiscord] = useState(""); const [mhsf, setMHSF] = useState(new MHSF()); const { resolvedTheme } = useTheme(); const [loading, setLoading] = useState(true); const [view, setView] = useState("desc"); const [serverObject, setServerObject] = useState( undefined ); const [copied, setCopied] = useState(false); useEffect(() => { getCustomization(server).then((b) => { if (b != null) { setDescription(b.description == null ? "" : b.description); setDiscord(b.discord == null ? "" : b.discord); mhsf.setCustomizations(b); getCommunityServerFavorites(server).then((c) => { mhsf.setFavorites(c); }); } fetch("https://api.minehut.com/server/" + server + "?byName=true").then( (c) => c.json().then((n) => setServerObject(n.server)) ); setLoading(false); }); }, []); if (loading) return <>; return ( <>
{(description != "" || discord != "") && (
)}
{description != "" && view == "desc" && ( {description} )} {discord != "" && view == "desc" && ( Discord Server