mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-27 09:23:03 +03:00
set blank values by default (fix uncontrolled warnings)
This commit is contained in:
+19
-30
@@ -109,11 +109,13 @@ function ServerList(props: { servers: AimeServer[] | undefined }) {
|
||||
function ServerAddForm() {
|
||||
const router = useRouter();
|
||||
const form = useForm<z.infer<typeof serverAdditionSchema>>({
|
||||
resolver: zodResolver(serverAdditionSchema)
|
||||
resolver: zodResolver(serverAdditionSchema),
|
||||
defaultValues: {
|
||||
address: ''
|
||||
}
|
||||
});
|
||||
|
||||
const [showHttpsWarning, setHttpsWarning] = useState(false);
|
||||
const [showPortWarning, setPortWarning] = useState(false);
|
||||
const [blockSubmit, setBlockSubmit] = useState(true);
|
||||
|
||||
async function onSubmit(values: z.infer<typeof serverAdditionSchema>) {
|
||||
@@ -147,11 +149,9 @@ function ServerAddForm() {
|
||||
const address = new URL(event.target.value);
|
||||
|
||||
setBlockSubmit(false);
|
||||
setPortWarning(!address.port);
|
||||
setHttpsWarning(address.protocol !== "http:");
|
||||
} catch {
|
||||
setBlockSubmit(true);
|
||||
setPortWarning(false);
|
||||
setHttpsWarning(false);
|
||||
}
|
||||
|
||||
@@ -160,31 +160,21 @@ function ServerAddForm() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{(showHttpsWarning || showPortWarning) && (<div></div>)}
|
||||
{showHttpsWarning && (
|
||||
<Alert variant="blank" className="text-yellow-500 border-yellow-500">
|
||||
<ShieldAlert className="h-5 w-5 text-yellow-500"/>
|
||||
<AlertTitle>HTTPS Warning</AlertTitle>
|
||||
<AlertDescription>
|
||||
AimeNet doesn't support HTTPS out-the-box.
|
||||
If you're using HTTPS, ensure a reverse-proxy or <Link target="_blank"
|
||||
className="underline"
|
||||
href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/httpsys">
|
||||
HTTP.SYS <SquareArrowOutUpRight className="inline h-3 w-3"/>
|
||||
</Link> has been configured and a valid, trusted SSL certificate has been configured.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{(showPortWarning && !showHttpsWarning) && (
|
||||
<Alert variant="blank" className="text-purple-500 border-purple-500">
|
||||
<Network className="h-5 w-5 text-purple-500"/>
|
||||
<AlertTitle>Default Port Detected</AlertTitle>
|
||||
<AlertDescription>
|
||||
Ensure you've set the correct port in the address field. By default, AimeNet uses
|
||||
port <code>6070</code>.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
{showHttpsWarning && (<>
|
||||
<div></div>
|
||||
<Alert variant="blank" className="text-yellow-500 border-yellow-500">
|
||||
<ShieldAlert className="h-5 w-5 text-yellow-500"/>
|
||||
<AlertTitle>HTTPS Warning</AlertTitle>
|
||||
<AlertDescription>
|
||||
AimeNet doesn't support HTTPS out-the-box.
|
||||
If you're using HTTPS, ensure a reverse-proxy or <Link target="_blank"
|
||||
className="underline"
|
||||
href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/httpsys">
|
||||
HTTP.SYS <SquareArrowOutUpRight className="inline h-3 w-3"/>
|
||||
</Link> has been configured and a valid, trusted SSL certificate has been configured.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Form {...form}>
|
||||
@@ -192,7 +182,6 @@ function ServerAddForm() {
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="address"
|
||||
|
||||
render={({field}) => (
|
||||
<FormItem className="flex-grow">
|
||||
<FormControl>
|
||||
|
||||
@@ -85,7 +85,11 @@ export function CardCreationDialog(props: { children: Readonly<React.ReactNode>
|
||||
|
||||
function AimeCardCreationForm(props: { callback?: () => void }) {
|
||||
const form = useForm<z.infer<typeof schema>>({
|
||||
resolver: zodResolver(schema)
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
id: '',
|
||||
name: ''
|
||||
}
|
||||
});
|
||||
|
||||
async function onSubmit(values: z.infer<typeof schema>) {
|
||||
|
||||
Reference in New Issue
Block a user