Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 901f791

Browse files
committed
excluded some constants from registration and profile
1 parent 8d4f7a7 commit 901f791

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

src/background/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ const dev: constantsdef = {
1717
}
1818
};
1919
export const constants = process.env.NODE_ENV === "development" ? dev : prod;
20+
21+
22+
export const MIN_PASSWORD_LENGTH = 8;
23+
export const MAX_PASSWORD_LENGTH = 20;
24+
export const DEFAULT_ALERT_DURATION = 3500;

src/components/pages/User/Profile.tsx

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,17 @@ import {notMinStrLength} from "../../../background/methods/checkInput";
88

99
export default function Profile(): ReactElement {
1010
const [isEditing, setIsEditing] = useState<boolean>(false);
11-
const user = useSelector((state: RootState) => state.user);
12-
13-
/*const handlePasswordChange = (event: ChangeEvent<HTMLInputElement>) => {
14-
event.preventDefault();
15-
let value: [string, boolean] | string = makePasswordInputFitRules(event.target.value);
16-
if (!value[1]) {
17-
value = password;
18-
} else {
19-
value = value[0]
20-
}
21-
setPasswordInformationLength(!notMinStrLength(value, MIN_PASSWORD_LENGTH));
22-
setPasswordInformationLowercase(value.match(/[a-z]/) !== null);
23-
setPasswordInformationUppercase(value.match(/[A-Z]/) !== null);
24-
setPasswordInformationNumber(value.match(/\d/) !== null);
25-
setPassword(value)
26-
}
27-
28-
const handlePasswordConfirmationChange = async (event: ChangeEvent<HTMLInputElement>) => {
29-
event.preventDefault();
30-
let value: [string, boolean] | string = makePasswordInputFitRules(event.target.value);
31-
if (!value[1]) {
32-
value = passwordConfirmation;
33-
} else {
34-
value = value[0]
35-
}
36-
setPasswordConfirmation(value);
37-
}*/
11+
const [username, setUsername] = useState<string>("");
12+
const [password, setPassword] = useState<string>("");
13+
const [passwordConfirmation, setPasswordConfirmation] = useState<string>("");
14+
const [passwordInformationLength, setPasswordInformationLength] = useState<boolean>(false);
15+
const [passwordInformationLowercase, setPasswordInformationLowercase] = useState<boolean>(false);
16+
const [passwordInformationUppercase, setPasswordInformationUppercase] = useState<boolean>(false);
17+
const [passwordInformationNumber, setPasswordInformationNumber] = useState<boolean>(false);
18+
const [passwordsMatch, setPasswordsMatch] = useState<boolean>(true);
19+
const [alertMessage, setAlertMessage] = useState<string>("Error 404: No Message found.");
20+
const [alertVariant, setAlertColor] = useState<"primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark">("success");
21+
const [alertVisibility, setAlertVisibility] = useState<boolean>(false);
3822

3923
function handleEditModeChange(): void {
4024
if (isEditing) {

src/components/pages/User/Registration.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import fileFighter from "../../../assets/images/logos/adventurer-run.gif";
99
import {registerNewUser} from "../../../background/api/registration";
1010
import {getWindowSize, getWindowSize_Interface} from "../../../background/methods/windowSize";
1111
import {getStyleValue} from "../../../background/methods/style";
12+
import {DEFAULT_ALERT_DURATION, MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH} from "../../../background/constants";
1213

1314
export default function Registration(): ReactElement {
14-
const MIN_PASSWORD_LENGTH = 8;
15-
const MAX_PASSWORD_LENGTH = 20;
16-
const DEFAULT_ALERT_DURATION = 3500;
1715

1816
const [username, setUsername] = useState<string>("");
1917
const [password, setPassword] = useState<string>("");

0 commit comments

Comments
 (0)