mirror of
https://github.com/DeveloLongScript/MHSF.git
synced 2026-05-07 21:14:59 -05:00
fix: more type issues
This commit is contained in:
parent
51b3050528
commit
f1fa1d98c1
@ -1,16 +1,16 @@
|
|||||||
"use client";;
|
"use client";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormControl,
|
FormControl,
|
||||||
FormField,
|
FormField,
|
||||||
FormItem,
|
FormItem,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { setCustomization } from "@/lib/api";
|
import { setCustomization } from "@/lib/api";
|
||||||
@ -18,73 +18,73 @@ import { toast } from "sonner";
|
|||||||
import ColorProvider from "../ColorProvider";
|
import ColorProvider from "../ColorProvider";
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
website: z
|
website: z
|
||||||
.string()
|
.string()
|
||||||
.min(2, {
|
.min(2, {
|
||||||
message: "ID must be at least 2 characters.",
|
message: "ID must be at least 2 characters.",
|
||||||
})
|
})
|
||||||
.url({ message: "Image must be in URL form." }),
|
.url({ message: "Image must be in URL form." }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export function BannerPopover({ server, get }: { server: string; get: any }) {
|
export function BannerPopover({ server, get }: { server: string; get: any }) {
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
resolver: zodResolver(FormSchema),
|
resolver: zodResolver(FormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
website: "",
|
website: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onSubmit(data: z.infer<typeof FormSchema>) {
|
async function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||||
toast.promise(setCustomization(server, { banner: data.website }), {
|
toast.promise(setCustomization(server, { banner: data.website }), {
|
||||||
loading: "Setting banner..",
|
loading: "Setting banner..",
|
||||||
success: "Set banner!",
|
success: "Set banner!",
|
||||||
error: "Error while setting banner",
|
error: "Error while setting banner",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ColorProvider server={server} fetch={get}>
|
<ColorProvider server={server} fetchV={get}>
|
||||||
<div>
|
<div>
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
All images that are in a web supported format can be used as the
|
All images that are in a web supported format can be used as the
|
||||||
banner for a server.
|
banner for a server.
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
<form
|
<form
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
className="w-2/3 space-y-6"
|
className="w-2/3 space-y-6"
|
||||||
defaultValue={get?.banner}
|
defaultValue={get?.banner}
|
||||||
>
|
>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="website"
|
name="website"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Image URL</FormLabel>
|
<FormLabel>Image URL</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} />
|
<Input {...field} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Button type="submit" className="h-[30px]">
|
<Button type="submit" className="h-[30px]">
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
className="ml-2 h-[30px]"
|
className="ml-2 h-[30px]"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log("hi");
|
console.log("hi");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Clear
|
Clear
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</ColorProvider>
|
</ColorProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,7 +78,7 @@ export function DiscordPopover({ server, get }: { server: string; get: any }) {
|
|||||||
}, [get]);
|
}, [get]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ColorProvider server={server} fetch={get}>
|
<ColorProvider server={server} fetchV={get}>
|
||||||
<div>
|
<div>
|
||||||
<span className="text-sm">
|
<span className="text-sm">
|
||||||
To embed a Discord server into your server page, first enable the
|
To embed a Discord server into your server page, first enable the
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user