Skip to content

Commit a2e260d

Browse files
committed
Adding routes and pages
1 parent b0acd42 commit a2e260d

File tree

3 files changed

+48
-36
lines changed

3 files changed

+48
-36
lines changed

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { auth } from './firebase';
88
import Login from './components/auth/Login';
99
import HomePage from './pages/homepage/HomePage';
1010
import Following from './pages/followingpage/FollowingPage';
11-
import Questions from './pages/questionpage/QuestionsPage';
11+
import Questions from './pages/questionspage/QuestionsPage';
1212

1313
import './App.css';
1414

src/components/navbar/Navbar.js

+44-32
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useSelector } from 'react-redux';
33
import Modal from 'react-modal';
44
// withRouter is a higher-order component
55
// ( A function which takes component as input and return modified component as output )
6-
import { withRouter } from 'react-router-dom';
6+
import { Link, withRouter } from 'react-router-dom';
77
import { selectUser } from '../../features/userSlice';
88
import db, { auth } from '../../firebase';
99
import firebase from 'firebase';
@@ -17,46 +17,58 @@ Modal.setAppElement("#root");
1717

1818
const Navbar = ({history, match}) => {
1919

20-
const user = useSelector(selectUser);
21-
const [openModal,setopenModal] = useState(false);
22-
const [selectOption,setSelectOption]=useState();
23-
const [input,setInput] = useState("");
24-
const[inputUrl,setInputUrl] = useState("");
20+
const user = useSelector(selectUser);
21+
const [openModal,setopenModal] = useState(false);
22+
const [selectOption,setSelectOption]=useState();
23+
const [input,setInput] = useState("");
24+
const[inputUrl,setInputUrl] = useState("");
2525

26-
const handleChange=(e)=>{
27-
setSelectOption(e.target.value);
28-
}
26+
const handleChange=(e)=>{
27+
setSelectOption(e.target.value);
28+
}
2929

30-
const handleQuestion = (e) => {
31-
e.preventDefault();
32-
setopenModal(false);
33-
db.collection('questions').add({
34-
section:selectOption,
35-
question:input,
36-
imageUrl:inputUrl,
37-
timestamp:firebase.firestore.FieldValue.serverTimestamp(),
38-
user: user,
39-
});
40-
setInput("");
41-
setInputUrl("");
42-
setSelectOption("");
43-
}
30+
const handleQuestion = (e) => {
31+
e.preventDefault();
32+
setopenModal(false);
33+
db.collection('questions').add({
34+
section:selectOption,
35+
question:input,
36+
imageUrl:inputUrl,
37+
timestamp:firebase.firestore.FieldValue.serverTimestamp(),
38+
user: user,
39+
});
40+
setInput("");
41+
setInputUrl("");
42+
setSelectOption("");
43+
}
44+
45+
const navStyle = {
46+
listStyle: 'none',
47+
textDecoration: 'none',
48+
};
4449

4550
return (
4651
<div className="navbar">
4752
<div className="header_logo">
4853
<img src={logo} alt="JU"/>
4954
</div>
5055
<div className="icons_wrapper">
51-
<div className="icon">
52-
<HomeIcon />
53-
</div>
54-
<div className="icon" onClick={() => history.push(`${match.url}/following`)}>
55-
<FeaturedPlayListOutlined />
56-
</div>
57-
<div className="icon">
58-
<AssignmentTurnedInOutlined />
59-
</div>
56+
<Link to="/" style={navStyle}>
57+
<div className="icon">
58+
<HomeIcon />
59+
</div>
60+
</Link>
61+
{/* <div className="icon" onClick={() => history.push(`${match.url}/following`)}> */}
62+
<Link to="/following" style={navStyle}>
63+
<div className="icon">
64+
<FeaturedPlayListOutlined />
65+
</div>
66+
</Link>
67+
<Link to="/question" style={navStyle}>
68+
<div className="icon">
69+
<AssignmentTurnedInOutlined />
70+
</div>
71+
</Link>
6072
<div className="icon">
6173
<PeopleAltOutlined />
6274
</div>

0 commit comments

Comments
 (0)