update create bot form

This commit is contained in:
Snazzah 2021-08-31 04:33:47 +00:00 committed by GitHub
parent 28dbd49957
commit e92877158c
2 changed files with 13 additions and 3 deletions

View file

@ -1,6 +1,7 @@
import { SubmitHandler, useForm } from "react-hook-form"; import { SubmitHandler, useForm } from "react-hook-form";
import { Bot } from "revolt-api/types/Bots"; import { Bot } from "revolt-api/types/Bots";
import { Text } from "preact-i18n";
import { useContext, useState } from "preact/hooks"; import { useContext, useState } from "preact/hooks";
import Modal from "../../../components/ui/Modal"; import Modal from "../../../components/ui/Modal";
@ -45,12 +46,12 @@ export function CreateBotModal({ onClose, onCreate }: Props) {
contrast: true, contrast: true,
accent: true, accent: true,
onClick: handleSubmit(onSubmit), onClick: handleSubmit(onSubmit),
children: "Create", children: <Text id="app.special.modals.actions.create" />,
}, },
{ {
plain: true, plain: true,
onClick: onClose, onClick: onClose,
children: "Cancel", children: <Text id="app.special.modals.actions.cancel" />,
}, },
]}> ]}>
{/* Preact / React typing incompatabilities */} {/* Preact / React typing incompatabilities */}

View file

@ -67,7 +67,16 @@ export default function FormField({
}, },
} }
: type === "username" : type === "username"
? { required: "RequiredField" } ? {
validate: (value: string) =>
value.length === 0
? "RequiredField"
: value.length < 2
? "TooShort"
: value.length > 32
? "TooLong"
: undefined,
}
: { required: "RequiredField" }, : { required: "RequiredField" },
)} )}
/> />