Skip to content

Commit 11a3b4f

Browse files
committed
Fixed minor errors
1 parent b32e26a commit 11a3b4f

File tree

19 files changed

+285
-286
lines changed

19 files changed

+285
-286
lines changed

.gitignore

-12
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,3 @@
1313
# production
1414
/build
1515

16-
# misc
17-
.DS_Store
18-
.env
19-
20-
.env.local
21-
.env.development.local
22-
.env.test.local
23-
.env.production.local
24-
25-
npm-debug.log*
26-
yarn-debug.log*
27-
yarn-error.log*

client/public/index.html

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> -->
5-
<meta charset="utf-8" />
6-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1" />
8-
<meta name="theme-color" content="#000000" />
9-
<meta
10-
name="description"
11-
content="Web site created using create-react-app"
12-
/>
13-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
14-
<!--
3+
4+
<head>
5+
<!-- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> -->
6+
<meta charset="utf-8" />
7+
<!-- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> -->
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
9+
<meta name="theme-color" content="#000000" />
10+
<meta name="description" content="Web site created using create-react-app" />
11+
<link rel="icon" type="image/png"
12+
href="https://cdn.discordapp.com/attachments/760027403933712387/864417493446426624/full-stack.png" />
13+
<!-- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> -->
14+
<!--
1515
manifest.json provides metadata used when your web app is installed on a
1616
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1717
-->
18-
<!--
18+
<!--
1919
Notice the use of %PUBLIC_URL% in the tags above.
2020
It will be replaced with the URL of the `public` folder during the build.
2121
Only files inside the `public` folder can be referenced from the HTML.
@@ -24,12 +24,13 @@
2424
work correctly both with client-side routing and a non-root public URL.
2525
Learn how to configure a non-root public URL by running `npm run build`.
2626
-->
27-
<title>React App</title>
28-
</head>
29-
<body>
30-
<noscript>You need to enable JavaScript to run this app.</noscript>
31-
<div id="root"></div>
32-
<!--
27+
<title>IITG-Stackoverflow</title>
28+
</head>
29+
30+
<body>
31+
<noscript>You need to enable JavaScript to run this app.</noscript>
32+
<div id="root"></div>
33+
<!--
3334
This HTML file is a template.
3435
If you open it directly in the browser, you will see an empty page.
3536
@@ -39,5 +40,6 @@
3940
To begin the development, run `npm start` or `yarn start`.
4041
To create a production bundle, use `npm run build` or `yarn build`.
4142
-->
42-
</body>
43-
</html>
43+
</body>
44+
45+
</html>

client/src/api/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ export const answerQuestion = (Answer, question_id) =>
7676
export const getAllAnswers = (questionId) =>
7777
API.get("/question/answers/" + questionId);
7878

79-
//Update one answerby Id
79+
//Update one answer by Id
8080
export const updateAnswer = (Answer, id) => API.patch("/answer/" + id, Answer);
8181

8282
//Vote on an answer
8383
export const voteAnsAPI = (answer_id, voteType) =>
8484
API.patch("/answer/vote/" + answer_id, { voteType });
8585

86-
//DELETE an Answer
86+
//Delete an Answer
8787
export const deleteAnswer = (answer_id) => API.delete("/answer/"+ answer_id);
8888

89-
//UPDATE USER NAME
89+
//Update User
9090
export const updateUserAPI = ({name, password, newPassword, confirmPassword, id}) => API.patch("/user/"+ id, {name, password, newPassword, confirmPassword});

client/src/components/Footer/Footer.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
2+
import {NavLink} from 'react-router-dom';
33
import { useSelector } from "react-redux";
44

55
// FOOTER color : #242729
@@ -12,8 +12,19 @@ const Footer = () => {
1212
}`}
1313
>
1414
<div className="flex flex-col text-lg">
15-
<span>IITG Stackoverflow</span>
16-
<span>Coding Club, IIT Guwahati</span>
15+
<span className = "text-xl py-1">IITG Stackoverflow</span>
16+
<span className = "text-xl pb-1">Coding Club, IIT Guwahati</span>
17+
<div>
18+
<NavLink to = "/" className="px-3 py-1 hover:text-gray-100">
19+
Home
20+
</NavLink>
21+
<NavLink to = "/questions" className="px-3 py-1 hover:text-gray-100">
22+
Questions
23+
</NavLink>
24+
<NavLink to = "/users" className="px-3 py-1 hover:text-gray-100">
25+
Users
26+
</NavLink>
27+
</div>
1728
</div>
1829
</div>
1930
);

client/src/components/Navbar/Navbar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const Navbar = () => {
3434
}
3535

3636
const onChangeHandler = (event) => {
37-
setSearch(event.target.value);
37+
setSearch(event.target.value.toLowerCase());
3838
}
3939

4040
return (

client/src/components/QuestionItem/QuestionItem.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import moment from "moment";
55
const QuestionItem = (props) => {
66
const question = props.data;
77
const loading = props.loading;
8+
let idx = 1000;
9+
if(!loading && question && question.description) {
10+
idx = question.description.indexOf("~~~js")
11+
}
812
return (
913
<>
1014
{!loading && (
@@ -52,14 +56,14 @@ const QuestionItem = (props) => {
5256
<span>
5357
{question.description.substring(
5458
0,
55-
Math.min(question.description.length, 400)
59+
Math.min(idx,Math.min(question.description.length, 400))
5660
)}...
5761
</span>
5862
) : (
5963
<span>
6064
{question.description.substring(
6165
0,
62-
Math.min(question.description.length, 400)
66+
Math.min(idx,Math.min(question.description.length, 400))
6367
)}
6468
</span>
6569
)}

client/src/components/RightSideBar/SideBarWidget.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import Pencil from "../../assets/svg/Pencil";
33
import Npm from "../../assets/svg/Npm";
44
import { Link } from "react-router-dom";
55

6-
const SideBarWidget = () => {
6+
const SideBarWidget = (props) => {
77
return (
8-
<div className="bg-yellow-50 h-64 rounded mt-6 border border-yellow-200 shadow-md">
8+
<div className={`bg-yellow-50 h-64 rounded mt-6 border border-yellow-200 shadow-md`}>
99
<div className="h-11 pl-4 text-gray-600 text-sm font-semibold bg-yellow-100 rounded-t-md border border-yellow-200 flex items-center">
1010
About IITG Stackoverflow
1111
</div>
@@ -16,6 +16,7 @@ const SideBarWidget = () => {
1616
target="_blank"
1717
href="https://github.com/joat28/iitg-stack-overflow"
1818
className="text-sm inline-block text-left font-semibold"
19+
rel="noreferrer"
1920
>
2021
Source Code
2122
</a>
@@ -39,8 +40,10 @@ const SideBarWidget = () => {
3940
<div>
4041
<a
4142
target="_blank"
42-
href="https://www.npmjs.com/package/react-markdown"
43+
href="
44+
https://commonmark.org/help/"
4345
className="text-sm inline-block text-left font-semibold"
46+
rel="noreferrer"
4447
>
4548
Using Markdown in React
4649
</a>

client/src/screens/SearchBar/SearchBarScreen.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ const SearchBarScreen = () => {
88
window.scrollTo(0, 0);
99
const location = useLocation();
1010
const url = location.pathname.split("/")[2];
11-
// console.log(url);
1211

1312
return (
1413
<React.Fragment>
1514
<div className="min-h-screen bg-white">
1615
<LeftSideBar />
1716
<div className="bg-white flex flex-row pl-72">
1817
<SearchResults url={url} />
19-
<div className="mt-16 mr-10 ml-10 w-1/4">
20-
<SideBarWidget/>
18+
<div className="mt-16 mr-10 ml-10 w-1/3">
19+
<SideBarWidget width={true}/>
2120
</div>
2221
</div>
2322
</div>

client/src/screens/SearchBar/SearchResults.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import React, { useEffect, useState } from "react";
2-
import { useDispatch, useSelector } from "react-redux";
2+
import { useSelector } from "react-redux";
33
import SearchItem from "./SearchItem";
44
import Spinner from "../../components/Spinner/Spinner";
55
import { NavLink } from "react-router-dom";
66
import Nothing from "../../assets/svg/Nothing";
7-
import { useLocation } from "react-router";
87

98
const SearchResults = (props) => {
109
const url = props.url;
1110
console.log(url);
1211
const { questions } = useSelector((state) => state.question);
1312
const [visibleQues, setVisibleQues] = useState([]);
1413
const[localLoading, setLocalLoading] = useState(true);
15-
// const dispatch = useDispatch();
16-
// const location = useLocation()
14+
1715

1816
useEffect(() => {
1917
window.scrollTo(0,0);
2018
setLocalLoading(false);
2119
if(questions && questions.length > 0)
22-
setVisibleQues([...questions.filter(question=>(question.title.includes(url) || question.description.includes(url)))]);
23-
}, [url]);
20+
setVisibleQues([...questions.filter(question=>(question.title.toLowerCase().includes(url) || question.description.toLowerCase().includes(url)))]);
21+
}, [url, questions]);
2422

2523
return (
2624
<>

client/src/screens/TeamScreen/TeamScreen.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import LinkedIn from "../../assets/svg/LinkedIn";
33
import Github from "../../assets/svg/Github";
4-
import Background from "../../assets/svg/Background";
54

65
const TeamScreen = () => {
76
return (
@@ -17,12 +16,12 @@ const TeamScreen = () => {
1716
<div className="flex h-2/5 justify-center text-5xl pt-6 mb-2 italic text-white">
1817
OUR TEAM
1918
</div>
20-
<div className="h-2/5 text-left px-5 text-xl pt-6 italic text-white">
19+
<div className="h-2/5 flex px-5 text-xl pt-6 italic text-white justify-center">
2120
We are a talented team of developers with skillsets in various domains of technology.
2221
</div>
2322
<div className="flex flex-row px-5 mt-16 justify-around">
2423
<div className="w-1/4 h-2/5 rounded-md border-8 border-white bg-white hover:scale-110 transform duration-500 ease-in-out">
25-
<img src="https://i.ibb.co/XJWFdzD/FB-IMG-1626115440284.jpg"></img>
24+
<img src="https://i.ibb.co/XJWFdzD/FB-IMG-1626115440284.jpg" alt="Tanmay Shreshth"></img>
2625
<div className="flex content-around w-full justify-center my-1.5">
2726
<a
2827
className="mr-2"
@@ -38,7 +37,7 @@ const TeamScreen = () => {
3837
</div>
3938

4039
<div className="w-1/4 h-2/5 rounded-md border-8 border-white bg-white hover:scale-110 transform duration-500 ease-in-out">
41-
<img src="https://i.ibb.co/W697x9x/20210713-004249.jpg"></img>
40+
<img src="https://i.ibb.co/W697x9x/20210713-004249.jpg" alt="Shashank Raj"></img>
4241
<div className="flex content-around w-full justify-center my-1.5 ">
4342
<a className="mr-2" href="https://www.linkedin.com/in/srj1105">
4443
<LinkedIn />
@@ -50,7 +49,7 @@ const TeamScreen = () => {
5049
<span className="font-semibold">Shashank Raj</span>
5150
</div>
5251
<div className="w-1/4 h-2/5 rounded-md border-8 border-white bg-white hover:scale-110 transform duration-500 ease-in-out">
53-
<img src="https://i.ibb.co/bPXsXc2/Whats-App-Image-2021-07-13-at-01-09-57.jpg"></img>
52+
<img src="https://i.ibb.co/bPXsXc2/Whats-App-Image-2021-07-13-at-01-09-57.jpg" alt="Kautilya Pandey"></img>
5453
<div className="flex content-around w-full justify-center place-items-center my-1.5">
5554
<a
5655
className="mr-2"
@@ -67,7 +66,7 @@ const TeamScreen = () => {
6766
</div>
6867
<div className="flex flex-row h-1/2 justify-center py-0 pl-20 mt-16 mb-8 ">
6968
<div className="w-1/4 h-2/5 mr-40 rounded-md border-8 border-white bg-white hover:scale-110 transform duration-500 ease-in-out">
70-
<img src="https://i.ibb.co/hL2gswz/Whats-App-Image-2021-07-13-at-00-27-26.jpg"></img>
69+
<img src="https://i.ibb.co/hL2gswz/Whats-App-Image-2021-07-13-at-00-27-26.jpg" alt = "Shantanu Pathak"></img>
7170
<div className="flex content-around w-full justify-center my-1.5">
7271
<a
7372
className="mr-2"
@@ -82,7 +81,7 @@ const TeamScreen = () => {
8281
<span className="font-semibold">Shantanu Pathak</span>
8382
</div>
8483
<div className="w-1/4 h-2/5 ml-2 rounded-md border-8 border-white bg-white hover:scale-110 transform duration-500 ease-in-out">
85-
<img src="https://i.ibb.co/txFZ6mJ/Whats-App-Image-2021-07-13-at-00-37-13.jpg"></img>
84+
<img src="https://i.ibb.co/txFZ6mJ/Whats-App-Image-2021-07-13-at-00-37-13.jpg" alt ="Prabhat Rao"></img>
8685
<div className="flex content-around w-full justify-center my-1.5 ">
8786
<a className="mr-2" href="https://www.linkedin.com/in/prabhat-rao/">
8887
<LinkedIn />

client/src/screens/UserProfile/EditProfileCard.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ const EditProfileCard = (props) => {
115115
Password
116116
</label>
117117
<input
118+
placeholder="Required"
118119
type="password"
119120
required
120121
className="p-2 rounded border-2 focus:border-blue-300 outline-none"
@@ -126,6 +127,7 @@ const EditProfileCard = (props) => {
126127
New Password
127128
</label>
128129
<input
130+
placeholder="Keep blank for no change"
129131
type="password"
130132
className="p-2 rounded border-2 focus:border-blue-300 outline-none"
131133
onChange={newPasswordChangeHandler}
@@ -136,7 +138,8 @@ const EditProfileCard = (props) => {
136138
Confirm New Password
137139
</label>
138140
<input
139-
type="text"
141+
placeholder="Keep blank for no change"
142+
type="password"
140143
className="p-2 rounded border-2 focus:border-blue-300 outline-none"
141144
onChange={confirmPasswordChangeHandler}
142145
/>

client/src/screens/UserProfile/UserProfileScreen.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from "react";
2-
import { useLocation, NavLink, useHistory } from "react-router-dom";
2+
import { useLocation, useHistory } from "react-router-dom";
33
import { useSelector } from "react-redux";
44
import { getUser } from "../../api/index";
55
import LeftSideBar from "../../components/LeftSideBar/LeftSideBar";
@@ -18,16 +18,16 @@ const UserProfileScreen = () => {
1818
const [radio, setRadio] = useState(true);
1919
const [editClick, setEditClick] = useState(false);
2020
useEffect(() => {
21-
console.log(location.pathname.split("/")[2]);
21+
2222
getUser(location.pathname.split("/")[2])
2323
.then((res) => {
2424
setUser(res.data.data);
2525
})
2626
.catch((error) => {
2727
// console.log(error);
28-
history.push('/xyz');
28+
history.push('/notfound');
2929
});
30-
}, [location.pathname]);
30+
}, [location.pathname, history]);
3131

3232
const radioChangeHandler = (type) => {
3333
if (type === "question" && radio) return;
@@ -48,7 +48,7 @@ const UserProfileScreen = () => {
4848
<div className="flex w-full">
4949
<div className="flex flex-col items-center">
5050
<div
51-
className="flex flex-col px-6 p-6 pb-2 h-64 relative border border-gray-300 rounded w-52"
51+
className="flex flex-col px-6 p-6 pb-2 h-68 relative border border-gray-300 rounded w-52"
5252
style={{ boxShadow: "inset 0 8.5em 0 #eff0f1" }}
5353
>
5454
<img
@@ -83,7 +83,7 @@ const UserProfileScreen = () => {
8383
</button>
8484
)}
8585
</div>
86-
{editClick && <EditProfileCard user={user} editClickHandler={editClickHandler}/>}
86+
{editClick && <EditProfileCard user={(user._id===currentUser._id)?currentUser:user} editClickHandler={editClickHandler}/>}
8787
{!editClick && (
8888
<div className="flex ml-2 pl-2 flex-col w-full ">
8989
<div className="flex flex-row w-full justify-between pb-1.5 border-b border-gray-300">

client/src/screens/ViewQuestion/AnswerSection/AnswerItem.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ const AnswerItem = (props) => {
5252
};
5353

5454
const deleteAnswerHandler = (event) => {
55-
dispatch(deleteAnswerAction(answer._id));
55+
const value = window.confirm('Delete Answer?');
56+
if(value) dispatch(deleteAnswerAction(answer._id));
57+
return;
5658
};
5759
const editClickHandler = (event) => {
5860
event.preventDefault();

0 commit comments

Comments
 (0)