Skip to content

Commit 02dc420

Browse files
committed
add call to backend for editing profile and password
1 parent 9b3cb79 commit 02dc420

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

frontend/src/components/ChangePasswordModal/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { forwardRef, useState } from 'react';
22
import { Box, Button, Stack, Typography } from '@mui/material';
33
import PasswordTextField from '../PasswordTextField';
4-
//import { userClient } from '../../utils/api';
5-
//import axios from 'axios';
6-
//import { FAILED_PW_UPDATE_MESSAGE, SUCCESS_PW_UPDATE_MESSAGE } from '../../utils/constants';
4+
import { userClient } from '../../utils/api';
5+
import axios from 'axios';
6+
import { FAILED_PW_UPDATE_MESSAGE, SUCCESS_PW_UPDATE_MESSAGE } from '../../utils/constants';
77

88
interface ChangePasswordModalProps {
99
handleClose: () => void;
@@ -12,8 +12,7 @@ interface ChangePasswordModalProps {
1212
}
1313

1414
const ChangePasswordModal = forwardRef<HTMLDivElement, ChangePasswordModalProps>((props, ref) => {
15-
const { handleClose } = props;
16-
//const { handleClose, userId, onUpdate } = props;
15+
const { handleClose, userId, onUpdate } = props;
1716
const [currPassword, setCurrPassword] = useState<string>('');
1817
const [newPassword, setNewPassword] = useState<string>('');
1918
const [confirmPassword, setConfirmPassword] = useState<string>('');
@@ -26,7 +25,7 @@ const ChangePasswordModal = forwardRef<HTMLDivElement, ChangePasswordModalProps>
2625

2726
const handleSubmit = async () => {
2827
//TODO: test with token (only tested without)
29-
/*const accessToken = localStorage.getItem("token");
28+
const accessToken = localStorage.getItem("token");
3029

3130
try {
3231
await userClient.patch(
@@ -51,7 +50,7 @@ const ChangePasswordModal = forwardRef<HTMLDivElement, ChangePasswordModalProps>
5150
} else {
5251
onUpdate(FAILED_PW_UPDATE_MESSAGE, false);
5352
}
54-
}*/
53+
}
5554
};
5655

5756
return (

frontend/src/components/EditProfileModal/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { forwardRef, useState } from 'react';
22
import { Box, Button, FormControl, FormHelperText, Stack, TextField, Typography } from '@mui/material';
3-
//import { userClient } from '../../utils/api';
4-
//import axios from 'axios';
5-
//import { FAILED_PROFILE_UPDATE_MESSAGE, SUCCESS_PROFILE_UPDATE_MESSAGE } from '../../utils/constants';
3+
import { userClient } from '../../utils/api';
4+
import axios from 'axios';
5+
import { FAILED_PROFILE_UPDATE_MESSAGE, SUCCESS_PROFILE_UPDATE_MESSAGE } from '../../utils/constants';
66

77
interface EditProfileModalProps {
88
handleClose: () => void;
@@ -14,8 +14,7 @@ interface EditProfileModalProps {
1414
}
1515

1616
const EditProfileModal = forwardRef<HTMLDivElement, EditProfileModalProps>((props, ref) => {
17-
const { handleClose, currFirstName, currLastName, currBiography } = props;
18-
//const { handleClose, currFirstName, currLastName, currBiography, userId, onUpdate } = props;
17+
const { handleClose, currFirstName, currLastName, currBiography, userId, onUpdate } = props;
1918
const nameCharLimit = 50;
2019
const bioCharLimit = 255;
2120
const [newFirstName, setNewFirstName] = useState<string>(currFirstName);
@@ -39,7 +38,7 @@ const EditProfileModal = forwardRef<HTMLDivElement, EditProfileModalProps>((prop
3938

4039
const handleSubmit = async () => {
4140
// TODO: test with token (only tested without)
42-
/*const accessToken = localStorage.getItem("token");
41+
const accessToken = localStorage.getItem("token");
4342

4443
try {
4544
await userClient.patch(
@@ -66,7 +65,7 @@ const EditProfileModal = forwardRef<HTMLDivElement, EditProfileModalProps>((prop
6665
} else {
6766
onUpdate(FAILED_PROFILE_UPDATE_MESSAGE, false);
6867
}
69-
}*/
68+
}
7069
};
7170

7271
return (

frontend/src/utils/constants.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export const FILL_ALL_FIELDS = "Please fill in all fields";
1111
// Question
1212
export const SUCCESS_QUESTION_CREATE = "Question created successfully";
1313
export const FAILED_QUESTION_CREATE = "Failed to create question";
14-
export const NO_QUESTION_CHANGES = "You have not made any changes to the question";
14+
export const NO_QUESTION_CHANGES =
15+
"You have not made any changes to the question";
1516
export const SUCCESS_QUESTION_UPDATE = "Question updated successfully";
1617
export const FAILED_QUESTION_UPDATE = "Failed to update question";
1718
export const SUCCESS_QUESTION_DELETE = "Question deleted successfully";
@@ -20,7 +21,7 @@ export const SUCCESS_FILE_UPLOAD = "File uploaded successfully";
2021
export const FAILED_FILE_UPLOAD = "Failed to upload file";
2122

2223
// Profile
23-
/*export const SUCCESS_PW_UPDATE_MESSAGE = "Password updated successfully";
24+
export const SUCCESS_PW_UPDATE_MESSAGE = "Password updated successfully";
2425
export const FAILED_PW_UPDATE_MESSAGE = "Failed to update password";
2526
export const SUCCESS_PROFILE_UPDATE_MESSAGE = "Profile updated successfully";
26-
export const FAILED_PROFILE_UPDATE_MESSAGE = "Failed to update profile";*/
27+
export const FAILED_PROFILE_UPDATE_MESSAGE = "Failed to update profile";

0 commit comments

Comments
 (0)