/* * MHSF, Minehut Server List * All external content is rather licensed under the ECA Agreement * located here: https://list.mlnehut.com/docs/legal/external-content-agreement * * All code under MHSF is licensed under the MIT License * by open source contributors * * Copyright (c) 2024 dvelo * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ "use client"; import { useEffect, useState } from "react"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { Button } from "@/components/ui/button"; import { Switch } from "./ui/switch"; import { setAccountSL } from "@/lib/api"; import { toast } from "sonner"; import { useUser } from "@clerk/nextjs"; export function SLCustomize() { const [padding, setPadding] = useState("0"); const [itemsPerRow, setItemsPerRow] = useState("4"); const [usePaddingOnSides, setUsePaddingOnSides] = useState(false); const [advanced, setAdvanced] = useState(false); const { user } = useUser(); useEffect(() => { setItemsPerRow((user?.publicMetadata.ipr as string | undefined) || "4"); setPadding((user?.publicMetadata.pad as string | undefined) || "0"); setUsePaddingOnSides( (user?.publicMetadata.srv as boolean | undefined) || false ); }, [ user?.publicMetadata.srv, user?.publicMetadata.pad, user?.publicMetadata.ipr, ]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (padding) setAccountSL(Number(padding), "pad"); if (usePaddingOnSides) setAccountSL(usePaddingOnSides, "srv"); if (itemsPerRow) setAccountSL(Number(itemsPerRow), "ipr"); toast.success("Set account preferences"); }; return (