Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/inputs/image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const DropPicture = ({ defaultPicture }) => {
try {
const compressedFile = await imageCompression(acceptedFiles[0], options);
formData.append('file', compressedFile);
const { data } = await http.post(
const { data } = await http.patch(
`${apiUrl}/${endPoints.user.updateProfilePicture}`,
formData,
{
Expand Down
10 changes: 5 additions & 5 deletions src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"login": "api/user/login",
"signup": "api/user/signup"
},
"allUsers": "api/user/info/all",
"loggedInUser": "api/user/info",
"getClassStudents": "api/user/class/all",
"updateProfilePicture": "api/user/update/profile_picture"
"allUsers": "api/users/all",
"loggedInUser": "api/user",
"getClassStudents": "api/users/class",
"updateProfilePicture": "api/user/update-profile-picture"
},
"slamBook": {
"getUserAnswers": "api/user/answers",
"getUserAnswers": "api/answers",
"deleteAnswerById": "api/slambook/answer/delete",
"upsertAnswer": "api/slambook/answer/upsert",
"createQuestion": "api/slambook/question/new",
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/private/user/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const Navbar = () => {
<MDBNavItem>
<MDBNavLink to="/write">Writes</MDBNavLink>
</MDBNavItem>
<MDBNavItem>
{/* <MDBNavItem>
<MDBNavLink to="/polls">Polls</MDBNavLink>
</MDBNavItem>
</MDBNavItem> */}
</MDBNavbarNav>
<MDBNavbarNav right>
<MDBNavItem>
Expand Down
28 changes: 14 additions & 14 deletions src/pages/private/user/messages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class PeopleCards extends Component {
const { data: persons } = await http.get(`${apiUrl}/${endPoints.user.allUsers}`);

let departments = persons.map((e) => {
return e.deptSection.department;
return e.department;
});
let sections = persons.map((e) => {
return e.deptSection.section;
return e.section;
});
departments.sort();
departments = ['ALL', ...new Set(departments)];
Expand All @@ -51,7 +51,7 @@ class PeopleCards extends Component {
filterPeople = (e) => {
const people = this.state.persons.filter(
(person) =>
person.credentials.name
person.name
.toLowerCase()
.search(e.target.value.trim().toLowerCase()) !== -1,
);
Expand All @@ -65,7 +65,7 @@ class PeopleCards extends Component {

return this.setState({
people: persons.filter((e) => {
return e.deptSection.section === sectionSelect;
return e.section === sectionSelect;
}),
departmentSelect: input.value,
});
Expand All @@ -75,11 +75,11 @@ class PeopleCards extends Component {
people: persons.filter((e) => {
if (sectionSelect !== 'ALL') {
return (
e.deptSection.department === input.value &&
e.deptSection.section === sectionSelect
e.department === input.value &&
e.section === sectionSelect
);
}
return e.deptSection.department === input.value;
return e.department === input.value;
}),
departmentSelect: input.value,
});
Expand All @@ -92,7 +92,7 @@ class PeopleCards extends Component {

return this.setState({
people: persons.filter((e) => {
return e.deptSection.department === departmentSelect;
return e.department === departmentSelect;
}),
sectionSelect: input.value,
});
Expand All @@ -102,11 +102,11 @@ class PeopleCards extends Component {
people: persons.filter((e) => {
if (departmentSelect !== 'ALL') {
return (
e.deptSection.section === input.value &&
e.deptSection.department === departmentSelect
e.section === input.value &&
e.department === departmentSelect
);
}
return e.deptSection.section === input.value;
return e.section === input.value;
}),
sectionSelect: input.value,
});
Expand Down Expand Up @@ -162,9 +162,9 @@ class PeopleCards extends Component {
<UserCard
person={person}
key={person._id}
personName={person.credentials.name}
personImageUrl={person.info.profilePicture}
personBio={person.info.bio}
personName={person.name}
personImageUrl={person.profilePicture}
personBio={person.bio}
triggerModal={this.triggerModal}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/private/user/messages/single.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const UserCard = ({ person, personName, personBio, personImageUrl }) => {
'secondary',
'dark',
];
classes += badgeClass[person.deptSection.section.charCodeAt(0) - 65];
classes += badgeClass[person.section.charCodeAt(0) - 65];
return classes;
};
const classes = useStyles();
Expand All @@ -61,7 +61,7 @@ const UserCard = ({ person, personName, personBio, personImageUrl }) => {
</div>
<div className="text-center">
<span className={getBadgeClass()}>
{person.deptSection.department} - {person.deptSection.section}
{person.department} - {person.section}
</span>
</div>
{personBio ? (
Expand Down
24 changes: 12 additions & 12 deletions src/pages/private/user/profile/details.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ const UserInfo = () => {
try {
const { data } = await http.get(`${apiUrl}/${endPoints.user.loggedInUser}`);
setCredentials({
name: data.credentials.name,
phoneNo: data.credentials.phoneNo,
email: data.credentials.email,
name: data.name,
phoneNo: data.socialHandles.phone,
email: data.socialHandles.email,
});
setDeptSection({
department: data.deptSection.department,
section: data.deptSection.section,
department: data.department,
section: data.section,
});
setInfo({
bio: data.info.bio,
profilePicture: data.info.profilePicture,
bio: data.bio,
profilePicture: data.profilePicture,
});
setSocialHandles({
contactEmail: data.socialHandles.contactEmail,
contactNo: data.socialHandles.contactNo,
contactEmail: data.socialHandles.email,
contactNo: data.socialHandles.phone,
instagram: data.socialHandles.instagram,
whatsappNo: data.socialHandles.whatsappNo,
whatsappNo: data.socialHandles.whatsapp,
facebook: data.socialHandles.facebook,
linkedin: data.socialHandles.linkedin,
snapchat: data.socialHandles.snapchat,
Expand Down Expand Up @@ -201,14 +201,14 @@ const UserInfo = () => {
isDisabled
/>

<Input
{/* <Input
name="email"
label="Account Email"
value={credentials.email}
handleChange={handleChange}
icon="envelope"
isDisabled
/>
/> */}
<Input
name="department"
label="Department"
Expand Down
4 changes: 2 additions & 2 deletions src/pages/private/user/profile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const Profile = () => {
className="card-title text-left h6-responsive mb-2"
style={{ textDecoration: 'underline' }}
>
{index + 1}. {item.questionId.title}
{index + 1}. {item.title}
</h6>
<p className="card-text">{item.answer}</p>
<p className="card-text">{item.content}</p>
</div>
))}
</div>
Expand Down
35 changes: 17 additions & 18 deletions src/pages/private/user/profile/profileCard/socialCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ const PersonalCard = () => {
const [Name, setName] = useState('');
const [info, setInfo] = useState({ bio: '', profilePicture: '' });
const [socialHandles, setSocialHandles] = useState({
contactEmail: '',
contactNo: '',
email: '',
phone: '',
instagram: '',
whatsappNo: '',
facebook: '',
linkedin: '',
snapchat: '',
});

const {
contactEmail,
contactNo,
whatsappNo,
email,
phone,
instagram,
linkedin,
facebook,
Expand All @@ -32,20 +30,21 @@ const PersonalCard = () => {
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,
// whatsappNo: data.socialHandles.whatsappNo,
facebook: data.socialHandles.facebook,
linkedin: data.socialHandles.linkedin,
snapchat: data.socialHandles.snapchat,
});
console.log('socialss', data)
} catch (ex) {
if (ex.response && ex.response.status === 400) {
TimerAlert('Error', ex.response.data, 'error');
Expand Down Expand Up @@ -90,24 +89,24 @@ const PersonalCard = () => {
<div>
<Tooltip title="You can add more details from update details section">
<div className="row">
{contactEmail && (
{email && (
<SocialHandle
platform={contactEmail}
platform={email}
iconClass="fas fa-lg fa-envelope"
/>
)}
{contactNo && (
{phone && (
<SocialHandle
platform={contactNo}
platform={phone}
iconClass="fas fa-lg fa-phone-square-alt"
/>
)}
{whatsappNo && (
{/* {whatsappNo && (
<SocialHandle
platform={whatsappNo}
iconClass="fab fa-lg fa-whatsapp"
/>
)}
)} */}
{linkedin && (
<SocialHandle
platform={linkedin}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/public/admin/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions src/pages/public/user/login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -109,12 +109,12 @@ const UserLogin = () => {
Sign In <Emoji symbol="🔐" />
</p>
<Input
name="email"
label="Email"
value={credentials.email}
name="userId"
label="Roll No."
value={credentials.userId}
handleChange={handleChange}
error={validationErrors.email}
feedback={validationErrors.email}
error={validationErrors.userId}
feedback={validationErrors.userId}
/>

<Input
Expand Down
1 change: 1 addition & 0 deletions src/services/httpService.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ export default {
post: axios.post,
put: axios.put,
delete: axios.delete,
patch: axios.patch,
setJwt,
};
8 changes: 4 additions & 4 deletions src/utils/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ 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(),
Expand All @@ -27,7 +27,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(),
Expand Down