From e92877158c10bf0f766beae94fba43e6888becb7 Mon Sep 17 00:00:00 2001
From: Snazzah <7025343+Snazzah@users.noreply.github.com>
Date: Tue, 31 Aug 2021 04:33:47 +0000
Subject: [PATCH] update create bot form
---
src/context/intermediate/popovers/CreateBot.tsx | 5 +++--
src/pages/login/FormField.tsx | 11 ++++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/context/intermediate/popovers/CreateBot.tsx b/src/context/intermediate/popovers/CreateBot.tsx
index 1f63940b..6010ba4f 100644
--- a/src/context/intermediate/popovers/CreateBot.tsx
+++ b/src/context/intermediate/popovers/CreateBot.tsx
@@ -1,6 +1,7 @@
import { SubmitHandler, useForm } from "react-hook-form";
import { Bot } from "revolt-api/types/Bots";
+import { Text } from "preact-i18n";
import { useContext, useState } from "preact/hooks";
import Modal from "../../../components/ui/Modal";
@@ -45,12 +46,12 @@ export function CreateBotModal({ onClose, onCreate }: Props) {
contrast: true,
accent: true,
onClick: handleSubmit(onSubmit),
- children: "Create",
+ children: ,
},
{
plain: true,
onClick: onClose,
- children: "Cancel",
+ children: ,
},
]}>
{/* Preact / React typing incompatabilities */}
diff --git a/src/pages/login/FormField.tsx b/src/pages/login/FormField.tsx
index 719346c7..9f8b9131 100644
--- a/src/pages/login/FormField.tsx
+++ b/src/pages/login/FormField.tsx
@@ -67,7 +67,16 @@ export default function FormField({
},
}
: type === "username"
- ? { required: "RequiredField" }
+ ? {
+ validate: (value: string) =>
+ value.length === 0
+ ? "RequiredField"
+ : value.length < 2
+ ? "TooShort"
+ : value.length > 32
+ ? "TooLong"
+ : undefined,
+ }
: { required: "RequiredField" },
)}
/>