-
Notifications
You must be signed in to change notification settings - Fork 3
TUR-41: Updated Frontend #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
ba5a466
9f55063
5c6c336
a85ad39
ce0eb64
af06a1b
6835691
ae759ef
dc935d6
a896397
cb45f1c
4560398
069a435
f957178
8c4c52c
ec0632e
325312e
888a723
74a45a0
91d5a75
716d4e0
354c4e1
e135b3a
7a13f0a
713bebb
68c8a49
4f40142
c26ead2
e4a78c0
2c772da
edf2abf
eaa765c
28a2361
d87697b
b351046
7381b51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,12 @@ import { Provider } from 'react-redux'; | |
import store from '../store'; | ||
|
||
import NavBar from '../components/NavBar/NavBar'; | ||
import Register from '../pages/Register'; | ||
import Login from '../pages/Login'; | ||
import Register from '../pages/Register/Register'; | ||
import Login from '../pages/Login/Login'; | ||
import Home from '../pages/Home/Home'; | ||
import PrivateRoute from '../components/private-route/PrivateRoute'; | ||
import NewPage from '../components/NewPage/NewPage'; | ||
|
||
|
||
// Check for token to keep user logged in | ||
if (localStorage.jwtToken) { | ||
|
@@ -33,28 +35,31 @@ if (localStorage.jwtToken) { | |
// Logout user | ||
store.dispatch(logoutUser()); | ||
|
||
// Redirect to login | ||
window.location.href = './login'; | ||
// Redirect to NewPage, was login | ||
window.location.href = './'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove . |
||
} | ||
} | ||
|
||
function App () { | ||
return ( | ||
return ( | ||
<Provider store={store}> | ||
<Router> | ||
<div> | ||
<NavBar /> | ||
<div> | ||
<NavBar /> | ||
|
||
<Switch> | ||
<Route | ||
exact | ||
path='/' | ||
component={() => <Redirect to='/login' />} | ||
/> | ||
<Route exact path='/login' component={Login} /> | ||
<Route exact path='/register' component={Register} /> | ||
<PrivateRoute exact path='/home' component={Home} /> | ||
</Switch> | ||
<Switch> | ||
<Route | ||
exact | ||
path='/' | ||
component={() => <Redirect to='/login' />} | ||
/> | ||
<Route exact path='/newpage' component={NewPage}/> | ||
<Route exact path='/login' component={Login} /> | ||
<Route exact path='/register' component={Register} /> | ||
<PrivateRoute exact path='/home' component={Home} /> | ||
</Switch> | ||
</div> | ||
</div> | ||
</Router> | ||
</Provider> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,35 @@ import { Link, withRouter } from "react-router-dom"; | |
import PropTypes from "prop-types"; | ||
import { connect } from "react-redux"; | ||
import { logoutUser } from "../../actions/authActions"; | ||
import { MainNav, NavLogo, StyledLinked, Header, NavItemLocation} from "./NavBar.styled"; | ||
import logo from '../../images/real.png'; | ||
|
||
class NavBar extends Component { | ||
render() { | ||
const { auth, logoutUser } = this.props; | ||
|
||
return ( | ||
<> | ||
{auth.isAuthenticated ? ( | ||
<MainNav> | ||
<NavLogo> | ||
<img src={logo}/> | ||
</NavLogo> | ||
<Header>Cloud Haven</Header> | ||
<NavItemLocation> | ||
<> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont need empty <> |
||
<button onClick={logoutUser}>Sign out</button> | ||
<p key={3}>{`Logged in as: You`}</p> | ||
{auth.isAuthenticated ? ( | ||
<> | ||
<button onClick={logoutUser}>Sign out</button> | ||
<p key={3}>{`Logged in as: You`}</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why key? |
||
</> | ||
) : ( | ||
<> | ||
<StyledLinked to="login">Login</StyledLinked> | ||
<StyledLinked to="register">Register </StyledLinked> | ||
</> | ||
)} | ||
</> | ||
) : ( | ||
<> | ||
<Link to="/login">Login</Link> | ||
<Link to="/register">Register</Link> | ||
</> | ||
)} | ||
</> | ||
</NavItemLocation> | ||
</MainNav> | ||
); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,57 @@ | ||
import styled from 'styled-components'; | ||
import { Link } from "react-router-dom"; | ||
|
||
export const MainNav = styled.a` | ||
align-items: center; | ||
background: gray; | ||
display: flex; | ||
flex-flow: row nowrap; | ||
-webkit-font-smoothing: antialiased; | ||
height: 60px; | ||
padding: 0 30px; | ||
box-shadow: 0 2px 4px 0 rgba(0,0,0,.2); | ||
`; | ||
|
||
export const NavLogo = styled.a` | ||
display: flex; | ||
height: 100%; | ||
margin-right: 10px; | ||
transition: opacity 0.2s ease-in-out; | ||
:hover { | ||
cursor: pointer; | ||
opacity: 0.5; | ||
} | ||
> img { | ||
margin: auto; | ||
} | ||
`; | ||
|
||
export const StyledLinked = styled(Link)` | ||
font-family: 'Trebuchet MS', sans-serif; | ||
color: white; | ||
text-decoration: none; | ||
height: 100%; | ||
padding: 0px 20px; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure spacing like this is everywhere before a :hover or &something |
||
:hover { | ||
color: black; | ||
transition: all 0.3s ease; | ||
} | ||
`; | ||
|
||
export const Header = styled.h2` | ||
text-align: center; | ||
color: black; | ||
font-family: 'Trebuchet MS', sans-serif; | ||
:hover { | ||
cursor: pointer; | ||
} | ||
`; | ||
|
||
export const NavItemLocation = styled.div` | ||
display: flex; | ||
flex-flow: row nowrap; | ||
align-items: center; | ||
margin-left: auto; | ||
justify-content: space-between; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { Component } from "react"; | ||
|
||
class NewPage extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
students: [ | ||
{ id: 1, name: 'Joe', age: 21, email: '[email protected]'}, | ||
{ id: 2, name: 'Bob', age: 22, email: '[email protected]'} | ||
] | ||
} | ||
} | ||
|
||
returnTableData() { | ||
return this.state.students.map((student, index) => { | ||
let col = Object.keys(student) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wheres you ; bro |
||
return ( | ||
<tr key={student.id}> | ||
{col.map((val, index) => { | ||
return <td key={index}>{student[col[index]]}</td> | ||
})} | ||
</tr> | ||
) | ||
}) | ||
} | ||
|
||
renderTableHeader() { | ||
let header = Object.keys(this.state.students[0]) | ||
return header.map((key, index) => { | ||
return <th key={index}>{key.toUpperCase()}</th> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. key should probably be key... isn't key and index the same? |
||
}) | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<h1 id='title'>TESTING TABLE PAGE</h1> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove id and replace with styled components |
||
<table id='students'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
<tbody> | ||
<tr>{this.renderTableHeader()}</tr> | ||
{this.returnTableData()} | ||
</tbody> | ||
</table> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default NewPage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import styled from 'styled-components'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we rename newpage to something more specific |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import React, { Component } from "react"; | ||
|
||
export default class Home extends Component { | ||
export default class EmptyPage extends Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
render() { | ||
|
||
return ( | ||
<div> | ||
Welcome Home | ||
<h3>Hello</h3> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. umm why? |
||
</div> | ||
) | ||
} | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove da comments