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 8 commits
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
31 changes: 31 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"react-cookies": "^0.1.1",
"react-dom": "^16.13.1",
"react-dropzone": "^11.0.1",
"react-error-boundary": "^3.1.3",
"react-flip-move": "^3.0.4",
"react-hot-toast": "^2.0.0",
"react-pose": "^4.0.10",
"react-pose-text": "^3.1.0",
"react-router-dom": "^5.1.2",
Expand Down
19 changes: 19 additions & 0 deletions src/components/alerts/confirm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Swal from 'sweetalert2';

const Confirm = (title, cb, text = `You won't be able to revert this`, icon = 'warning', confirmBtnText = 'Save') => {
Swal.fire({
title,
text,
icon,
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: confirmBtnText,
}).then((result) => {
if (result.isConfirmed) {
cb(true);
}
})
}

export default Confirm;
4 changes: 3 additions & 1 deletion src/components/alerts/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import RequestStatus from './request';
import TimerAlert from './timer';
import HTMLAlert from './html';
import ChainInput from './chaining';
import Confirm from './confirm';
import Toast from './toast';

export { NotifyAlert, RequestStatus, TimerAlert, HTMLAlert, ChainInput };
export { NotifyAlert, RequestStatus, TimerAlert, HTMLAlert, ChainInput, Confirm, Toast };
23 changes: 23 additions & 0 deletions src/components/alerts/toast.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import toast, { Toaster } from 'react-hot-toast';



// const Toast = (toastMessage, toastType='success') => {
// // toast[toastType](toastMessage);

// toast('Here is your toast.');
// };

import React from 'react'

const Toast = () => {
const notify = () => toast('Here is your toast.');
return (
<div>
{notify()}
<Toaster />
</div>
)
}

export default Toast;
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -78,7 +78,7 @@ const DropPicture = ({ defaultPicture }) => {
<section className="container" style={customStyle}>
<div {...getRootProps({ className: 'dropzone' })}>
<input {...getInputProps()} />
<div className="text-center" style={{ fontFamily: 'Inter' }}>
<div className="text-center">
<BackupIcon className="mb-1" fontSize="large" />
<strong>
<p className="text-center">Upload your profile picture</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/socialHandle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import propTypes from 'prop-types';
const SocialHandle = ({ platform, iconClass }) => {
return (
<div className="row">
<div className="col ml-5">
<div className="col mx-5">
<i className={iconClass} />
</div>
<div className="col pl-1">{platform}</div>
Expand Down
32 changes: 18 additions & 14 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
{
"apiUrl": "http://localhost:5000",
"apiUrl": "https://yb-server.herokuapp.com",
"endPoints": {
"user": {
"onboarding": {
"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",
"updateDetails": "api/user/update"
},
"slamBook": {
"getUserAnswers": "api/user/answers",
"deleteAnswerById": "api/slambook/answer/delete",
"upsertAnswer": "api/slambook/answer/upsert",
"createQuestion": "api/slambook/question/new",
"allQuestions": "api/slambook/questions/all",
"getQuestionById": "api/slambook/question",
"deleteQuestionById": "api/slambook/question/delete"
"getUserAnswers": "api/answers",
"deleteAnswerById": "api/answer/delete",
"upsertAnswer": "api/answer/upsert",
"createQuestion": "api/question/new",
"allQuestions": "api/questions/all",
"getQuestionById": "api/question",
"deleteQuestionById": "api/question/delete"
},
"messages": {
"forLoggedInUser": "api/user/messages",
"feed": "api/user/messages/all"
"forLoggedInUser": "api/messages",
"feed": "api/messages/all",
"new": "api/message/new",
"delete": "api/message/delete",
"deleteByMessageId": "api/message/delete-by-id"
}
},
"routes": {
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/private/user/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const Navbar = () => {
<MDBNavLink to="/">Home</MDBNavLink>
</MDBNavItem>
<MDBNavItem>
<MDBNavLink to="/write">Writes</MDBNavLink>
<MDBNavLink to="/write-message">Write Message</MDBNavLink>
</MDBNavItem>
<MDBNavItem>
<MDBNavLink to="/polls">Polls</MDBNavLink>
<MDBNavLink to="/moderation">Moderation</MDBNavLink>
</MDBNavItem>
</MDBNavbarNav>
<MDBNavbarNav right>
Expand All @@ -59,7 +59,7 @@ const Navbar = () => {
<NavLink to="/answers">Self Answers</NavLink>
</MDBDropdownItem>
<MDBDropdownItem>
<NavLink to="/reset">Reset Password</NavLink>
<NavLink to="/update-password">Update Password</NavLink>
</MDBDropdownItem>
</MDBDropdownMenu>
</MDBDropdown>
Expand Down
11 changes: 5 additions & 6 deletions src/pages/private/admin/manageQuestions.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import http from '../../../services/httpService';
import { apiUrl, routes } from '../../../config.json';
import { apiUrl, endPoints } from '../../../config.json';
import ListQuestions from './questions/listQuestion';
import { NotifyAlert } from '../../../components';

Expand All @@ -16,8 +16,7 @@ const ManageQuestions = () => {
useEffect(() => {
const fetchQuestions = async () => {
try {
const { data } = await http.get(`${apiUrl}/api/admin/questions`);
console.log(data)
const { data } = await http.get(`${apiUrl}/${endPoints.slamBook.allQuestions}`);
setQuestions(data);
setNoQuestions(false);
} catch (ex) {}
Expand Down Expand Up @@ -47,10 +46,10 @@ const ManageQuestions = () => {
return setInputValidationAlert(updatedInputValidation);
}

const originalQuestions = questions;
const originalQuestions = [...questions];
try {
const { data } = await http.post(`${apiUrl}/api/admin/questions`, {
question: previousInputValue,
const { data } = await http.post(`${apiUrl}/${endPoints.slamBook.createQuestion}`, {
title: previousInputValue,
});
NotifyAlert('Successfully added the question', 'top');
setQuestions([data, ...questions]);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/private/admin/questions/listQuestion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ListQuestions = ({
onKeyDown={handleKeyPress}
/>
{inputValidationAlert.apply && (
<Alert severity="error" style={{ fontFamily: 'Sofia Pro Medium' }}>
<Alert severity="error">
{inputValidationAlert.message}
</Alert>
)}
Expand All @@ -63,7 +63,7 @@ const ListQuestions = ({
<Question
key={item._id}
onDelete={onDelete}
question={item.question}
question={item.title}
id={item._id}
/>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/private/user/answers/box.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import propTypes from 'prop-types';
import SplitText from 'react-pose-text';
import Tooltip from '@material-ui/core/Tooltip';
Expand All @@ -13,6 +13,10 @@ import http from '../../../../services/httpService';
const AnswerBox = ({ question, questionId, answer, answerId }) => {
const [CurrentAnswer, setCurrentAnswer] = useState(answer);

useEffect(() => {
setCurrentAnswer(answer);
}, [answer]);

const charPoses = {
exit: { opacity: 0, y: 20 },
enter: {
Expand Down
10 changes: 4 additions & 6 deletions src/pages/private/user/answers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const SelfAnswers = () => {
const [totalQuestions, setTotalQuestions] = useState(0); // Total Number of Questions
const [CurrentPage, setCurrentPage] = useState(1); // The current pagination page
// eslint-disable-next-line no-unused-vars
const [postsPerPage, setpostsPerPage] = useState(1); // No. of posts per page
const [postsPerPage, setPostsPerPage] = useState(1); // No. of posts per page

useEffect(() => {
document.title = 'Self Questions';
Expand All @@ -35,10 +35,8 @@ const SelfAnswers = () => {
}, []);

const getAnswer = (questionId) => {
// console.log('Question ID is ', questionId);
const result = answeredQuestions.find((e) => e.questionId._id === questionId);
// console.log('Answer result is ', result);
return result ? { answer: result.answer, _id: result._id } : {};
const result = answeredQuestions.find((e) => e.titleId === questionId);
return result ? { content: result.content, _id: result._id } : {};
};

const getTotalAnswersClass = () => {
Expand Down Expand Up @@ -75,7 +73,7 @@ const SelfAnswers = () => {
<AnswerBox
question={item.title}
questionId={item._id}
answer={getAnswer(item._id).answer}
answer={getAnswer(item._id).content}
answerId={getAnswer(item._id)._id}
key={item._id}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/private/user/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SelfAnswers from './answers';
import HomePage from './home';
import LogOut from './logout';
import ResetPassword from './resetPassword';
import ModerateMessages from './moderation';

export {
ListPolls,
Expand All @@ -16,4 +17,5 @@ export {
HomePage,
LogOut,
ResetPassword,
ModerateMessages
};
Loading