Merge branch 'main' of https://github.com/anshnk/Radius
This commit is contained in:
commit
c97a009fac
5 changed files with 115 additions and 5 deletions
|
|
@ -20,7 +20,7 @@ export default function RootLayout({
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<link rel="icon" href="/icon.png" />
|
<link rel="icon" href="/icon.png" />
|
||||||
<script src="/chemical.js"></script>
|
<script data-wisp-store src="/chemical.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body className={inter.className}>
|
<body className={inter.className}>
|
||||||
<Themes>
|
<Themes>
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,6 @@ export default function Settings() {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
toast.success("Settings saved");
|
toast.success("Settings saved");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
console.log(values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onReset() {
|
function onReset() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Users, Link, Palette } from "lucide-react";
|
import { Users, Link, Palette, ArrowRightLeft } from "lucide-react";
|
||||||
import NextLink from "next/link";
|
import NextLink from "next/link";
|
||||||
|
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
|
|
@ -23,6 +23,16 @@ export default function SettingsLayout({
|
||||||
<Palette className="h-5 w-5" /> Appearance
|
<Palette className="h-5 w-5" /> Appearance
|
||||||
</Button>
|
</Button>
|
||||||
</NextLink>
|
</NextLink>
|
||||||
|
<NextLink href="/settings/wisp/">
|
||||||
|
<Button
|
||||||
|
variant={
|
||||||
|
pathname?.includes("/settings/wisp/") ? "secondary" : "ghost"
|
||||||
|
}
|
||||||
|
className="w-full items-center justify-start gap-2"
|
||||||
|
>
|
||||||
|
<ArrowRightLeft className="h-5 w-5" /> Wisp
|
||||||
|
</Button>
|
||||||
|
</NextLink>
|
||||||
<NextLink href="/settings/credits/">
|
<NextLink href="/settings/credits/">
|
||||||
<Button
|
<Button
|
||||||
variant={
|
variant={
|
||||||
|
|
|
||||||
102
src/app/settings/wisp/page.tsx
Normal file
102
src/app/settings/wisp/page.tsx
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/components/ui/form";
|
||||||
|
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Separator } from "@/components/ui/separator";
|
||||||
|
import { Save, RotateCcw } from "lucide-react";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
const formSchema = z.object({
|
||||||
|
wispServer: z.string().url("Please provide a valid URL"),
|
||||||
|
description: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function WispSwitcher() {
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const form = useForm<z.infer<typeof formSchema>>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues: {
|
||||||
|
wispServer: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const wispServer: string = window.chemical.getStore("wisp");
|
||||||
|
const defaultWisp: string =
|
||||||
|
(location.protocol === "https:" ? "wss" : "ws") +
|
||||||
|
"://" +
|
||||||
|
location.host +
|
||||||
|
"/wisp/";
|
||||||
|
form.setValue("wispServer", wispServer !== defaultWisp ? wispServer : "");
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||||
|
setSubmitting(true);
|
||||||
|
|
||||||
|
window.chemical.setStore("wisp", values.wispServer);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setSubmitting(false);
|
||||||
|
toast.success("Settings saved");
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onReset() {
|
||||||
|
form.reset();
|
||||||
|
window.chemical.setStore("wisp", "");
|
||||||
|
toast("Settings reset");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1 className="text-4xl font-semibold">Wisp</h1>
|
||||||
|
<Separator />
|
||||||
|
<div className="mt-4">
|
||||||
|
<Form {...form}>
|
||||||
|
<form
|
||||||
|
onSubmit={form.handleSubmit(onSubmit)}
|
||||||
|
className="w-1/2 space-y-4"
|
||||||
|
>
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="wispServer"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Wisp Server Switcher</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input placeholder="Wisp Server URL" {...field} />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{}
|
||||||
|
<div className="flex space-x-4">
|
||||||
|
<Button type="submit" disabled={submitting}>
|
||||||
|
<Save className="mr-2 h-5 w-5" /> Save Changes
|
||||||
|
</Button>
|
||||||
|
<Button type="button" onClick={onReset}>
|
||||||
|
<RotateCcw className="mr-2 h-5 w-5" /> Reset
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ export default function Navbar() {
|
||||||
if (pathname && pathname.includes('/go/')) return null
|
if (pathname && pathname.includes('/go/')) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-screen fixed h-14 border-b flex items-center px-4">
|
<div className="w-screen fixed h-14 border-b flex items-center px-4 bg-background z-10">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Button onClick={() => setOpen(true)} size="icon" variant="ghost">
|
<Button onClick={() => setOpen(true)} size="icon" variant="ghost">
|
||||||
<Lucide.Menu className="h-7 w-7" />
|
<Lucide.Menu className="h-7 w-7" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue