Skip to content

Commit 1e5363f

Browse files
back to running again
1 parent 60b1339 commit 1e5363f

File tree

22 files changed

+335
-2193
lines changed

22 files changed

+335
-2193
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
2424

25-
.env
26-
hide.json
25+
.env

client/package-lock.json

Lines changed: 101 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
"@fortawesome/fontawesome-svg-core": "^1.2.36",
77
"@fortawesome/free-solid-svg-icons": "^5.15.4",
88
"@fortawesome/react-fontawesome": "^0.1.16",
9-
"@kommunicate/kommunicate-chatbot-plugin": "^0.0.5",
109
"@testing-library/jest-dom": "^5.16.5",
1110
"@testing-library/react": "^13.4.0",
1211
"@testing-library/user-event": "^13.5.0",
1312
"axios": "^1.2.2",
14-
"dotenv": "^16.0.3",
1513
"gh-pages": "^5.0.0",
1614
"jwt-decode": "^3.1.2",
1715
"moment": "^2.29.4",
@@ -22,7 +20,6 @@
2220
"react-redux": "^8.0.5",
2321
"react-router-dom": "^6.6.2",
2422
"react-scripts": "5.0.1",
25-
"react-thunk": "^1.0.0",
2623
"redux": "^4.2.0",
2724
"redux-thunk": "^2.4.2",
2825
"web-vitals": "^2.1.4"
@@ -52,5 +49,8 @@
5249
"last 1 firefox version",
5350
"last 1 safari version"
5451
]
52+
},
53+
"devDependencies": {
54+
"dotenv": "^16.4.5"
5555
}
5656
}

client/src/App.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515

1616
@media (max-width:768px) {
1717
.home-container-2{
18-
max-width: 1100px;
19-
width: calc(100% - 164px);
20-
padding: 24px;
18+
width: calc(100%);
19+
padding: 10px;
2120
box-sizing: border-box;
22-
display: flex;
23-
flex-direction: column;
2421
}
2522
}

client/src/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import React from 'react';
1111
function App() {
1212

1313
const dispatch = useDispatch()
14-
1514
useEffect(() => {
1615
dispatch(fetchAllQuestions())
1716
dispatch(fetchAllUsers())

client/src/Pages/Auth/Auth.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ const Auth = () => {
3636
}
3737

3838
return (
39-
<section class='auth-section'>
39+
<section className='auth-section'>
4040
{ isSignup && <AboutAuth />}
41-
<div class='auth-container-2'>
41+
<div className='auth-container-2'>
4242
{ !isSignup && <img src={icon} alt='stack overflow' className='login-logo'/>}
4343
<form onSubmit={handleSubmit}>
4444
{

client/src/Pages/Questions/Questions.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
border-bottom: solid 1px rgba(0, 0, 0, 0.112);
1313
}
1414
.question-details-container-2{
15-
flex-direction: column;
15+
display: flex;
16+
/* flex-direction: column; */
1617
}
1718
.question-details-container .question-votes{
1819
padding: 5px 20px 5px 10px;

client/src/Pages/Questions/QuestionsDetails.jsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,15 @@ const QuestionsDetails = () => {
4747
// answeredOn: "jan 2",
4848
// userId: 2,
4949
// }]
50-
// },{
51-
// _id: '3',
52-
// upVotes: 3,
53-
// downVotes: 2,
54-
// noOfAnswers: 0,
55-
// questionTitle: "What is a function?",
56-
// questionBody: "It meant to be",
57-
// questionTags: ["javascript", "R", "python"],
58-
// userPosted: "mano",
59-
// askedOn: "jan 1",
60-
// userId: 1,
61-
// answer: [{
62-
// answerBody: "Answer",
63-
// userAnswered: 'kumar',
64-
// answeredOn: "jan 2",
65-
// userId: 2,
66-
// }]
50+
// }
6751
// }]
6852
const [Answer, setAnswer] = useState('')
6953
const Navigate = useNavigate()
7054
const dispatch = useDispatch()
7155
const User = useSelector((state) => (state.currentUserReducer))
7256
const location = useLocation()
57+
const url=process.env.REACT_APP_APP_URL
7358
// const url = 'http://localhost:3000'
74-
const config = require('../../hide.json');
75-
const url = config.BASE_URL;
7659

7760
const handlePostAns = (e, answerLength) =>{
7861
e.preventDefault()
@@ -84,6 +67,8 @@ const QuestionsDetails = () => {
8467
alert('Enter an answer before submitting')
8568
} else{
8669
dispatch(postAnswer({ id, noOfAnswers: answerLength + 1, answerBody: Answer, userAnswered: User.result.name }))
70+
setAnswer('')
71+
window.location.reload()
8772
}
8873
}
8974
}

client/src/actions/auth.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const signup = (authData, navigate) => async (dispatch) => {
99
navigate('/')
1010
} catch (error) {
1111
console.log(error)
12+
// alert error message
13+
alert(error.response.data.message)
1214
}
1315
}
1416

@@ -20,5 +22,7 @@ export const login = (authData, navigate) => async (dispatch) => {
2022
navigate('/')
2123
} catch (error) {
2224
console.log(error)
25+
// alert error message
26+
alert(error.response.data.message)
2327
}
2428
}

client/src/api/index.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1-
import axios from 'axios'
1+
import axios from "axios";
22

3-
// const API = axios.create({ baseURL: 'http://localhost:5000'})
4-
const config = require('../hide.json');
5-
console.log("base url is"+config.BASE_URL)
6-
const API = axios.create({ baseURL: config.BASE_URL})
3+
// const API = axios.create({ baseURL: "http://localhost:5000/api" });
4+
const API = axios.create({ baseURL: process.env.REACT_APP_API_URL})
75

86
API.interceptors.request.use((req) => {
9-
if(localStorage.getItem('Profile')){
10-
req.headers.authorization = `Bearer ${JSON.parse(localStorage.getItem('Profile')).token}`
11-
}
12-
return req;
13-
})
7+
if (localStorage.getItem("Profile")) {
8+
req.headers.authorization = `Bearer ${JSON.parse(localStorage.getItem("Profile")).token}`;
9+
}
10+
return req;
11+
});
1412

15-
export const logIn = (authData) => API.post('/user/login', authData);
16-
export const signUp = (authData) => API.post('/user/signup', authData);
13+
export const logIn = (authData) => {
14+
console.log("authdata= ", authData);
15+
return API.post("/user/login", authData);
16+
};
17+
export const signUp = (authData) => {
18+
return API.post("/user/signup", authData);
19+
};
1720

18-
export const postQuestion = (questionData) => API.post('/questions/Ask', questionData)
19-
export const getAllQuestions = () => API.get('/questions/get');
20-
export const deleteQuestion = (id) => API.delete(`/questions/delete/${id}`)
21-
export const voteQuestion = (id, value ) => API.patch(`/questions/vote/${id}`, { value })
21+
export const postQuestion = (questionData) => API.post("/questions/Ask", questionData);
22+
export const getAllQuestions = () => API.get("/questions/get");
23+
export const deleteQuestion = (id) => API.delete(`/questions/delete/${id}`);
24+
export const voteQuestion = (id, value) => API.patch(`/questions/vote/${id}`, { value });
2225

23-
export const postAnswer = (id, noOfAnswers, answerBody, userAnswered ) => API.patch(`/answer/post/${id}`, { noOfAnswers, answerBody, userAnswered })
24-
export const deleteAnswer = (id, answerId, noOfAnswers) => API.patch(`/answer/delete/${id}`, { answerId, noOfAnswers})
26+
export const postAnswer = (id, noOfAnswers, answerBody, userAnswered) => API.patch(`/answer/post/${id}`, { noOfAnswers, answerBody, userAnswered });
27+
export const deleteAnswer = (id, answerId, noOfAnswers) => API.patch(`/answer/delete/${id}`, { answerId, noOfAnswers });
2528

26-
export const getAllUsers = () => API.get('/user/getAllUsers');
27-
export const updateProfile = (id, updateData) => API.patch(`/user/update/${id}`, updateData)
29+
export const getAllUsers = () => API.get("/user/getAllUsers");
30+
export const updateProfile = (id, updateData) => API.patch(`/user/update/${id}`, updateData);

0 commit comments

Comments
 (0)