Small fix

This commit is contained in:
Peter KW 2024-04-13 21:36:02 +02:00
parent f66b6a0f0a
commit 564b2e6f58
2 changed files with 22 additions and 26 deletions

View file

@ -36,7 +36,7 @@ export default function ProjectNameInput(props: {
</p>
)}
{alphanumeric.test(props.name) &&
name.length >= projNameHighLimit &&
name.length >= projNameLowLimit &&
name.length <= projNameHighLimit && (
<p className="text-green-500 pl-2 text-[13px] text-left">
Valid project name!

View file

@ -17,12 +17,11 @@ import {
* @returns The JSX element representing the registration form.
*/
export default function Register(): JSX.Element {
const [username, setUsername] = useState<string>();
const [password, setPassword] = useState<string>();
const [errMessage, setErrMessage] = useState<string>();
const [username, setUsername] = useState<string>("");
const [password, setPassword] = useState<string>("");
const [errMessage, setErrMessage] = useState<string>("");
const handleRegister = async (): Promise<void> => {
if (username !== undefined) {
if (
username.length > usernameUpLimit ||
username.length < usernameLowLimit ||
@ -33,18 +32,15 @@ export default function Register(): JSX.Element {
);
return;
}
}
if (password !== undefined) {
if (password.length !== passwordLength || !lowercase.test(password)) {
alert(
"Please provide valid password: \n-Exactly 6 characters \n-No uppercase letters \n-No numbers \n-No special characters (.-!?/*)",
);
return;
}
}
const newUser: NewUser = {
username: username?.replace(/ /g, "") ?? "",
password: password ?? "",
username: username,
password: password,
};
const response = await api.registerUser(newUser);
if (response.success) {
@ -78,14 +74,14 @@ export default function Register(): JSX.Element {
</h3>
<UsernameInput
username={username ?? ""}
username={username}
onChange={(e) => {
setUsername(e.target.value);
}}
/>
<div className="py-2" />
<PasswordInput
password={password ?? ""}
password={password}
onChange={(e) => {
setPassword(e.target.value);
}}