"use client"; import { Button } from "./ui/button"; import { Textarea } from "./ui/textarea"; import { CheckIcon, X } from "lucide-react"; import { Dispatch, SetStateAction, useEffect, useState } from "react"; import { getCustomization, ownServer, reportServer, setCustomization, serverOwned as sOFunc, unownServer, userOwnedServer, } from "@/lib/api"; import toast from "react-hot-toast"; import { SignedIn, SignedOut, useUser } from "@clerk/nextjs"; import { OnlineServer } from "@/lib/types/mh-server"; import Link from "next/link"; import Setting from "./ui/setting"; import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Form, } from "./ui/form"; import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import "@/themes.css"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "./ui/card"; import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover"; import { themes } from "@/lib/themes"; import { useTheme } from "next-themes"; import { DiscordPopover } from "./misc/DiscordPopover"; import { Spinner } from "./ui/spinner"; import { BannerPopover } from "./misc/BannerPopover"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "./ui/dialog"; const formSchema = z.object({ description: z .string() .min(2, { message: "Description must be at least 2 characters.", }) .max(1250, { message: "Description cannot be longer than 1250 characters.", }), }); export default function ServerCustomize({ server, cs, setCS, }: { server: string; cs: string; setCS: Dispatch>; }) { const [serverOwned, setServerOwned] = useState(false); const [userOwned, setUserOwned] = useState(false); const [loading, setLoading] = useState(true); const [reason, setReason] = useState(""); const [description, setDescription] = useState(""); const [get, setGet] = useState({}); const [author, setAuthor] = useState(""); const [minehutOwned, setMinehutOwned] = useState(false); const { resolvedTheme: mode } = useTheme(); const { user, isSignedIn } = useUser(); useEffect(() => { sOFunc(server).then((c) => { setServerOwned(c); getCustomization(server).then((b) => { setGet(b); setDescription(b != null ? b.description : ""); form.reset({ description: b != null ? b.description : "" }); setCS(b != null ? b.colorScheme : "zinc"); userOwnedServer(server).then((c) => { setUserOwned(c); fetch("https://api.minehut.com/servers").then((c) => { c.json().then((c: { servers: Array }) => { c.servers.forEach((v) => { setAuthor(v.author); if (v.name == server && isSignedIn) { if (user?.publicMetadata.player === v.author) { setMinehutOwned(true); } } setLoading(false); }); }); }); }); }); }); }, [isSignedIn]); const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { description, }, }); if (loading) { return ( <>
); } return ( <> {!serverOwned && (
Do you own this server?
Create an account and link it to the owner of the server to customize it.
)}
{!serverOwned && user?.publicMetadata.player == null && (
Do you own this server?
Create an account and link it to the owner of the server to customize it.
)} {serverOwned && !userOwned && (
Is this server in violation of the ECA?
Is this server in violation of the{" "} External Content Agreement (aka ECA) ? You can report the server to remove the customizations from the server. Report Server This will send a notification to MHSF maintainers. This server must be in violation of the{" "} ECA to be a valid report. Typical response times include 1 hour to 1 day, and you will not be notified if your report is successful or not.{" "} Please do not spam this form with mindless reports. If you do, your account will be banned. We are not Minehut support, we cannot help you with a problem within the Minehut platform or within the server, we can only moderate the customization of the server. {" "} (if the problem is within the server,{" "} report it on Minehut )

Reason: