+ setSocialHandles({
+ ...socialHandles,
+ email: e.target.value,
+ })
+ }
+ error={ValidationErrors.email}
+ feedback={ValidationErrors.email}
icon="envelope-open"
/>
+ setSocialHandles({
+ ...socialHandles,
+ phone: e.target.value,
+ })
+ }
+ error={ValidationErrors.phone}
+ feedback={ValidationErrors.phone}
icon="phone-alt"
/>
-
+ setSocialHandles({
+ ...socialHandles,
+ facebook: e.target.value,
+ })
+ }
error={ValidationErrors.facebook}
feedback={ValidationErrors.facebook}
icon="facebook"
@@ -286,7 +247,12 @@ const UserInfo = () => {
name="linkedin"
label="LinkedIn"
value={socialHandles.linkedin}
- handleChange={handleSocialHandles}
+ handleChange={(e) =>
+ setSocialHandles({
+ ...socialHandles,
+ linkedin: e.target.value,
+ })
+ }
error={ValidationErrors.linkedin}
feedback={ValidationErrors.linkedin}
icon="linkedin"
@@ -295,7 +261,12 @@ const UserInfo = () => {
+ setSocialHandles({
+ ...socialHandles,
+ instagram: e.target.value,
+ })
+ }
handleChange={handleSocialHandles}
icon="instagram"
IconBrand
@@ -303,7 +274,12 @@ const UserInfo = () => {
+ setSocialHandles({
+ ...socialHandles,
+ snapchat: e.target.value,
+ })
+ }
handleChange={handleSocialHandles}
icon="snapchat-ghost"
IconBrand
diff --git a/src/pages/private/user/profile/index.jsx b/src/pages/private/user/profile/index.jsx
index 9943297..a1d2bbf 100644
--- a/src/pages/private/user/profile/index.jsx
+++ b/src/pages/private/user/profile/index.jsx
@@ -36,7 +36,9 @@ const Profile = () => {
`${apiUrl}/${endPoints.messages.forLoggedInUser}`,
);
setMessages(data);
- if (!data.length) setMessagesStatus(true);
+ if (!data.length) {
+ setMessagesStatus(true);
+ }
} catch (ex) {}
};
@@ -54,7 +56,7 @@ const Profile = () => {
- 🔍 Know Me Better
+ 🤔 📖 SlamBook
{NoAnswers ? (
@@ -73,21 +75,34 @@ const Profile = () => {
className="card-title text-left h6-responsive mb-2"
style={{ textDecoration: 'underline' }}
>
- {index + 1}. {item.questionId.title}
+ {index + 1}. {item.title}
-
{item.answer}
+
{item.content}
))}
)}
- What others have written for you
+ {/* */}
+
+ What others have written for you
+
{messages.map((item, index) => (
diff --git a/src/pages/private/user/profile/messages.jsx b/src/pages/private/user/profile/messages.jsx
index f5cbb8a..3e17e11 100644
--- a/src/pages/private/user/profile/messages.jsx
+++ b/src/pages/private/user/profile/messages.jsx
@@ -1,11 +1,5 @@
import React from 'react';
import propTypes from 'prop-types';
-import { withStyles } from '@material-ui/core/styles';
-import Rating, { IconContainerProps } from '@material-ui/lab/Rating';
-import StarBorderIcon from '@material-ui/icons/StarBorder';
-import Typography from '@material-ui/core/Typography';
-import Box from '@material-ui/core/Box';
-import { Emoji } from '../../../../components';
const Message = ({ person, message, index }) => {
const getClass = () => {
@@ -28,18 +22,14 @@ const Message = ({ person, message, index }) => {
<>
-
- {person}
-
{message}
-
-
- {person} Rated your friendship 3.5/5
+
+ -{person}
diff --git a/src/pages/private/user/profile/profileCard/socialCard.jsx b/src/pages/private/user/profile/profileCard/socialCard.jsx
index 3b73eeb..faadead 100644
--- a/src/pages/private/user/profile/profileCard/socialCard.jsx
+++ b/src/pages/private/user/profile/profileCard/socialCard.jsx
@@ -7,45 +7,42 @@ import { TimerAlert } from '../../../../../components';
const PersonalCard = () => {
const [Name, setName] = useState('');
- const [info, setInfo] = useState({ bio: '', profilePicture: '' });
+ const [info, setInfo] = useState({
+ bio: '',
+ profilePicture: 'https://i.imgur.com/rHE3Y91.png',
+ });
+ const [department, setDepartment] = useState('');
+ const [section, setSection] = useState('');
const [socialHandles, setSocialHandles] = useState({
- contactEmail: '',
- contactNo: '',
+ email: '',
+ phone: '',
instagram: '',
- whatsappNo: '',
facebook: '',
linkedin: '',
snapchat: '',
});
- const {
- contactEmail,
- contactNo,
- whatsappNo,
- instagram,
- linkedin,
- facebook,
- snapchat,
- } = socialHandles;
+ const { email, phone, instagram, linkedin, facebook, snapchat } = socialHandles;
useEffect(() => {
const fetchUserData = async () => {
try {
const { data } = await http.get(`${apiUrl}/${endPoints.user.loggedInUser}`);
- setName(data.credentials.name);
+ setName(data.name);
setInfo({
- bio: data.info.bio,
- profilePicture: data.info.profilePicture,
+ bio: data.bio,
+ profilePicture: data.profilePicture,
});
setSocialHandles({
- contactEmail: data.socialHandles.contactEmail,
- contactNo: data.socialHandles.contactNo,
+ email: data.socialHandles.email,
+ phone: data.socialHandles.phone,
instagram: data.socialHandles.instagram,
- whatsappNo: data.socialHandles.whatsappNo,
facebook: data.socialHandles.facebook,
linkedin: data.socialHandles.linkedin,
snapchat: data.socialHandles.snapchat,
});
+ setDepartment(data.department);
+ setSection(data.section);
} catch (ex) {
if (ex.response && ex.response.status === 400) {
TimerAlert('Error', ex.response.data, 'error');
@@ -55,6 +52,21 @@ const PersonalCard = () => {
fetchUserData();
}, []);
+ const getBadgeClass = () => {
+ let classes = 'badge badge-';
+ const badgeClass = [
+ 'primary',
+ 'success',
+ 'danger',
+ 'default',
+ 'info',
+ 'secondary',
+ 'dark',
+ ];
+ classes += badgeClass[section.charCodeAt(0) - 65];
+ return classes;
+ };
+
return (
<>
{
@@ -82,7 +94,9 @@ const PersonalCard = () => {
{Name}
- CSE - B
+
+ {department} - {section}
+
{info.bio}
@@ -90,24 +104,21 @@ const PersonalCard = () => {
- {contactEmail && (
-
+ {email && (
+
)}
- {contactNo && (
+ {phone && (
)}
- {whatsappNo && (
+ {/* {whatsappNo && (
- )}
+ )} */}
{linkedin && (
{
- const [password, setPassword] = useState('');
+ const [currentPassword, setCurrentPassword] = useState('');
const [confirmNewPassword, setconfirmNewPassword] = useState('');
- const [newPassword, setnewPassword] = useState('');
+ const [newPassword, setNewPassword] = useState('');
const [Loading, setLoading] = useState(false);
const [passwordErrors, setPasswordErrors] = useState('');
const [serverError, setServerErrors] = useState('');
+ const [showPassword, setShowPassword] = useState(false);
+ const [inputType, setInputType] = useState('password');
const disabledButton = () => {
return newPassword !== confirmNewPassword;
};
const handlePasswordChange = ({ currentTarget: input }) => {
- setPassword(input.value);
+ setCurrentPassword(input.value);
};
- const handleNewPwsdChange = ({ currentTarget: input }) => {
- setnewPassword(input.value);
- };
+ // const handleNewPwsdChange = ({ currentTarget: input }) => {
+ // setnewPassword(input.value);
+ // };
- const handleConfirmNewPswdChange = ({ currentTarget: input }) => {
- if (input.value !== newPassword) {
- setPasswordErrors('New Password do not matches');
- } else {
- setPasswordErrors('');
- }
- setconfirmNewPassword(input.value);
- };
+ // const handleConfirmNewPswdChange = ({ currentTarget: input }) => {
+ // if (input.value !== newPassword) {
+ // setPasswordErrors('New Password do not matches');
+ // } else {
+ // setPasswordErrors('');
+ // }
+ // setconfirmNewPassword(input.value);
+ // };
const submitHandler = async (e) => {
setLoading(true);
e.preventDefault();
try {
- const { data } = await http.post(`${apiUrl}/api/user/self/reset`, {
- password,
- newPassword,
- });
- setServerErrors('');
- setPassword('');
- setconfirmNewPassword('');
- setnewPassword('');
- TimerAlert(' ', data, 'success');
+ // const { data } = await http.post(`${apiUrl}/api/user/self/reset`, {
+ // password,
+ // newPassword,
+ // });
+ // setServerErrors('');
+ // setCurrentPassword('');
+ // setconfirmNewPassword('');
+ // setnewPassword('');
+ // TimerAlert(' ', data, 'success');
} catch (ex) {
if (ex.response && ex.response.status === 401) {
setServerErrors(ex.response.data);
@@ -60,8 +63,12 @@ const ResetPassword = () => {
return (
<>
+
+ If you haven't updated your temporary (initial) password yet, please update
+ it.
+
-
+
@@ -71,14 +78,42 @@ const ResetPassword = () => {
noValidate
>
- Reset your password
+ Update your password
+
+
{
+ setShowPassword(!showPassword);
+ setInputType(showPassword ? 'password' : 'text');
+ }}
+ />
+
+ Show Password{' '}
+ {showPassword ? (
+
+ ) : (
+
+ )}
+
+
setCurrentPassword(e.target.value)}
error={serverError}
feedback={serverError}
/>
@@ -87,24 +122,23 @@ const ResetPassword = () => {
name="newPassword"
label="New Password"
value={newPassword}
- handleChange={handleNewPwsdChange}
- type="password"
+ handleChange={(e) => setNewPassword(e.target.value)}
+ type={inputType}
/>
-
+ type={inputType}
+ /> */}
{/* {passwordErrors && (
{passwordErrors}
diff --git a/src/pages/public/admin/login.jsx b/src/pages/public/admin/login.jsx
index b44e88f..fb6e087 100644
--- a/src/pages/public/admin/login.jsx
+++ b/src/pages/public/admin/login.jsx
@@ -20,7 +20,7 @@ const AdminLogin = () => {
e.preventDefault();
try {
setLoading(true);
- const { data, headers } = await http.post(`${apiUrl}/api/admin/auth`, {
+ const { data, headers } = await http.post(`${apiUrl}/api/admin/login`, {
username,
password,
});
@@ -28,10 +28,10 @@ const AdminLogin = () => {
TimerAlert('Success', data, 'success');
history.push('/');
} catch (ex) {
- if (ex.response && ex.reponse.status && ex.response.status === 400) {
+ if (ex.response && ex.response.status && ex.response.status === 400) {
TimerAlert('Error', ex.response.data, 'error');
}
- if (ex.reponse && ex.response.status && ex.response.status === 401) {
+ if (ex.response && ex.response.status && ex.response.status === 401) {
TimerAlert('Error', 'Invalid Username or Password', 'error');
}
setLoading(false);
diff --git a/src/pages/public/user/login.jsx b/src/pages/public/user/login.jsx
index 17736a3..2ca8bdb 100644
--- a/src/pages/public/user/login.jsx
+++ b/src/pages/public/user/login.jsx
@@ -10,9 +10,9 @@ import { apiUrl, endPoints } from '../../../config.json';
import { http } from '../../../services';
const UserLogin = () => {
- const [credentials, setCredentials] = useState({ email: '', password: '' });
+ const [credentials, setCredentials] = useState({ userId: '', password: '' });
const [validationErrors, setValidationErrors] = useState({
- email: '',
+ userId: '',
password: '',
});
const [Loading, setLoading] = useState(false);
@@ -65,9 +65,9 @@ const UserLogin = () => {
const submitHandler = async (e) => {
e.preventDefault();
e.target.className += ' was-validated';
- const errors = validateForm();
- setValidationErrors(errors || {});
- if (errors) return;
+ // const errors = validateForm();
+ // setValidationErrors(errors || {});
+ // if (errors) return;
try {
setLoading(true);
const { headers } = await http.post(
@@ -80,7 +80,8 @@ const UserLogin = () => {
path: '/',
expires,
});
- history.push('/');
+ // history.push('/');
+ window.location.href = '/';
TimerAlert('', 'Welcome to the Yearbook', 'success');
} catch (ex) {
if (
@@ -109,12 +110,12 @@ const UserLogin = () => {
Sign In
{
)}
-
+ {/*
Not a member?{' '}
Register
Forgot Password?{' '}
Reset Password
-
+ */}
diff --git a/src/routes/private/index.jsx b/src/routes/private/index.jsx
index 1d0c10f..ca9e118 100644
--- a/src/routes/private/index.jsx
+++ b/src/routes/private/index.jsx
@@ -12,19 +12,19 @@ import {
ManagePolls,
EmailNotifications,
ResetPassword,
+ ModerateMessages,
} from '../../pages';
const privateRoutes = () => {
const routes = [
- { path: '/write', component:
},
+ { path: '/write-message', component:
},
{
path: '/profile',
component:
,
},
{
- path: '/polls',
- component:
,
- systemAdminComponent:
,
+ path: '/moderation',
+ component:
,
},
{
path: '/details',
@@ -38,7 +38,7 @@ const privateRoutes = () => {
path: '/questions',
systemAdminComponent:
,
},
- { path: '/reset', component:
},
+ { path: '/update-password', component:
},
{ path: '/add-user', systemAdminComponent:
},
{ path: '/email', systemAdminComponent:
},
{ path: '/logout', component:
},
diff --git a/src/services/httpService.js b/src/services/httpService.js
index 6fd2a99..333bea9 100644
--- a/src/services/httpService.js
+++ b/src/services/httpService.js
@@ -21,5 +21,6 @@ export default {
post: axios.post,
put: axios.put,
delete: axios.delete,
+ patch: axios.patch,
setJwt,
};
diff --git a/src/utils/schemas.js b/src/utils/schemas.js
index 2b4f641..a88e2e9 100644
--- a/src/utils/schemas.js
+++ b/src/utils/schemas.js
@@ -2,11 +2,10 @@ import Joi from 'joi-browser';
const LoginSchema = () => {
return {
- email: Joi.string()
- .email()
+ userId: Joi.number()
.error(() => {
return {
- message: 'Please enter a valid Email ID',
+ message: 'Please enter a valid enrollment number',
};
})
.required(),
@@ -27,7 +26,7 @@ const SignUpSchema = () => {
.min(7)
.error(() => {
return {
- message: 'Password should be atleast 7 characters long',
+ message: 'Password should be at least 7 characters long',
};
})
.required(),