Small fix
This commit is contained in:
parent
f66b6a0f0a
commit
564b2e6f58
2 changed files with 22 additions and 26 deletions
|
@ -36,7 +36,7 @@ export default function ProjectNameInput(props: {
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{alphanumeric.test(props.name) &&
|
{alphanumeric.test(props.name) &&
|
||||||
name.length >= projNameHighLimit &&
|
name.length >= projNameLowLimit &&
|
||||||
name.length <= projNameHighLimit && (
|
name.length <= projNameHighLimit && (
|
||||||
<p className="text-green-500 pl-2 text-[13px] text-left">
|
<p className="text-green-500 pl-2 text-[13px] text-left">
|
||||||
Valid project name!
|
Valid project name!
|
||||||
|
|
|
@ -17,34 +17,30 @@ import {
|
||||||
* @returns The JSX element representing the registration form.
|
* @returns The JSX element representing the registration form.
|
||||||
*/
|
*/
|
||||||
export default function Register(): JSX.Element {
|
export default function Register(): JSX.Element {
|
||||||
const [username, setUsername] = useState<string>();
|
const [username, setUsername] = useState<string>("");
|
||||||
const [password, setPassword] = useState<string>();
|
const [password, setPassword] = useState<string>("");
|
||||||
const [errMessage, setErrMessage] = useState<string>();
|
const [errMessage, setErrMessage] = useState<string>("");
|
||||||
|
|
||||||
const handleRegister = async (): Promise<void> => {
|
const handleRegister = async (): Promise<void> => {
|
||||||
if (username !== undefined) {
|
if (
|
||||||
if (
|
username.length > usernameUpLimit ||
|
||||||
username.length > usernameUpLimit ||
|
username.length < usernameLowLimit ||
|
||||||
username.length < usernameLowLimit ||
|
!alphanumeric.test(username)
|
||||||
!alphanumeric.test(username)
|
) {
|
||||||
) {
|
alert(
|
||||||
alert(
|
"Please provide valid username: \n-Between 5-10 characters \n-No special characters (.-!?/*)",
|
||||||
"Please provide valid username: \n-Between 5-10 characters \n-No special characters (.-!?/*)",
|
);
|
||||||
);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (password !== undefined) {
|
if (password.length !== passwordLength || !lowercase.test(password)) {
|
||||||
if (password.length !== passwordLength || !lowercase.test(password)) {
|
alert(
|
||||||
alert(
|
"Please provide valid password: \n-Exactly 6 characters \n-No uppercase letters \n-No numbers \n-No special characters (.-!?/*)",
|
||||||
"Please provide valid password: \n-Exactly 6 characters \n-No uppercase letters \n-No numbers \n-No special characters (.-!?/*)",
|
);
|
||||||
);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const newUser: NewUser = {
|
const newUser: NewUser = {
|
||||||
username: username?.replace(/ /g, "") ?? "",
|
username: username,
|
||||||
password: password ?? "",
|
password: password,
|
||||||
};
|
};
|
||||||
const response = await api.registerUser(newUser);
|
const response = await api.registerUser(newUser);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
@ -78,14 +74,14 @@ export default function Register(): JSX.Element {
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<UsernameInput
|
<UsernameInput
|
||||||
username={username ?? ""}
|
username={username}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setUsername(e.target.value);
|
setUsername(e.target.value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="py-2" />
|
<div className="py-2" />
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
password={password ?? ""}
|
password={password}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setPassword(e.target.value);
|
setPassword(e.target.value);
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in a new issue