Skip to content

Commit

Permalink
linted using standard lint rules , updated dependencies and removed c…
Browse files Browse the repository at this point in the history
…ookie-parser
  • Loading branch information
Vincent440 committed Jul 27, 2020
1 parent 657b752 commit eac72a9
Show file tree
Hide file tree
Showing 58 changed files with 17,037 additions and 2,333 deletions.
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"proxy": "http://localhost:3001/",
"dependencies": {
"axios": "^0.19.0",
"axios": "^0.19.2",
"browserslist": "^4.6.3",
"core-js": "^3.1.4",
"dependency": "0.0.1",
Expand Down
165 changes: 82 additions & 83 deletions client/src/App.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import React, { Component } from "react";
import { BrowserRouter as Router, Route, Switch, Redirect } from "react-router-dom";
import { Row, Col } from 'react-grid-system';
import Container from "react-bootstrap/Container";
import Particles from "react-particles-js";
import UserContext from "./UserContext";
import InfoPart from "./components/infoPart";
import authapi from "./utils/authapi";
import ReserveNew from "./pages/newreservation/newreservation";
import ReserveUpdate from "./pages/updatereservation/updatereservation";
import Dashboard from "./pages/dashboard/dashboard";
import UpdateReservation from "./pages/allreservations/allreservations";
import Arrivals from "./pages/arrivals/arrivals";
import Billing from "./pages/billing/billing";
import Payment from "./pages/payment/payment";
import Inhouse from "./pages/inhouse/inhouse";
import Login from "./pages/login/login";
import ReservationTest from "./pages/newreservation/reservationTest";
import Housekeeping from "./pages/housekeeping/housekeeping";
import DetailedAvailability from "./pages/detailedAvailability/detailedAvailability";
import HouseStatus from "./pages/houseStatus/houseStatus";
import Maintenance from "./pages/maintenance/maintenance";
import React, { Component } from 'react'
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import { Row, Col } from 'react-grid-system'
import Container from 'react-bootstrap/Container'
import Particles from 'react-particles-js'
import UserContext from './UserContext'
import InfoPart from './components/infoPart'
import authapi from './utils/authapi'
import ReserveNew from './pages/newreservation/newreservation'
import ReserveUpdate from './pages/updatereservation/updatereservation'
import Dashboard from './pages/dashboard/dashboard'
import UpdateReservation from './pages/allreservations/allreservations'
import Arrivals from './pages/arrivals/arrivals'
import Billing from './pages/billing/billing'
import Payment from './pages/payment/payment'
import Inhouse from './pages/inhouse/inhouse'
import Login from './pages/login/login'
import ReservationTest from './pages/newreservation/reservationTest'
import Housekeeping from './pages/housekeeping/housekeeping'
import DetailedAvailability from './pages/detailedAvailability/detailedAvailability'
import HouseStatus from './pages/houseStatus/houseStatus'
import Maintenance from './pages/maintenance/maintenance'

const particleOptions = { particles: { number: { value: 120, density: { enable: true, value_area: 1000 } } } };
const particleOptions = { particles: { number: { value: 120, density: { enable: true, value_area: 1000 } } } }

const PrivateAccessRoute = ({ component: Component, aId, ...rest }) => (
<UserContext.Consumer>
Expand All @@ -34,102 +34,101 @@ const PrivateAccessRoute = ({ component: Component, aId, ...rest }) => (
) : (
<Redirect
to={{
pathname: "/",
pathname: '/',
state: { from: props.location }
}}
/>
)
}
)}
/>
)}
</UserContext.Consumer>
);
)

class App extends Component {
constructor(props) {
super(props);
constructor (props) {
super(props)
this.postUserLogin = userData => {
if (userData) {
authapi.postUserLogin(userData, (err, res) => {
if (err === true) {
return console.log("Failed to log in");
return console.log('Failed to log in')
}
this.setState({ user: res.user });
});
this.setState({ user: res.user })
})
}
};
}
this.getUserLogout = event => {
event.preventDefault();
authapi.getLoggedOut().then(this.getUserStatus);
};
event.preventDefault()
authapi.getLoggedOut().then(this.getUserStatus)
}
this.getUserStatus = () => {
authapi.getLoginStatus().then(res => {
if (res) {
this.setState(()=>(
this.setState(() => (
{ user: res.user }
)
);
)
)
}
});
};
})
}
this.state = {
user: {
access_id: 0,
type: "Guest",
type: 'Guest',
user_id: 0,
username: "guest"
username: 'guest'
},
getUserStatus: this.getUserStatus,
getUserLogout: this.getUserLogout,
postUserLogin: this.postUserLogin
};
}
}
render() {
let { user } = this.state;

render () {
const { user } = this.state
return (
<UserContext.Provider value={this.state}>
<Router>
{ user.access_id === 0 ? (
<Router>
{user.access_id === 0 ? (
<div>
<Redirect to="/" />
<Redirect to='/' />
<Login />
</div> ) :
(
<Container className="m-0 p-0">
<Particles params={particleOptions} />
<Row className="m-0 py-2">
<Col xs={6} sm={4} md={3} lg={3} xl={2} >
<Row className="pt-3"><span></span></Row>
</div>)
: (
<Container className='m-0 p-0'>
<Particles params={particleOptions} />
<Row className='m-0 py-2'>
<Col xs={6} sm={4} md={3} lg={3} xl={2}>
<Row className='pt-3'><span /></Row>
<InfoPart />
</Col>
<Col xs={6} sm={8} md={9} lg={9} xl={10}>
<Row className="pt-3"><span></span></Row>
<div className="pl-2 m-0 py-0">
<Switch>
<PrivateAccessRoute exact strict path="/" component={Dashboard} aId="1" />
<PrivateAccessRoute exact path="/reserve/new" component={ReserveNew} aId="1" />
<PrivateAccessRoute exact path="/reserve/allreservations" component={UpdateReservation} aId="1" />
<PrivateAccessRoute exact path="/reserve/testUpdatereservation" component={ReserveUpdate} aId="1" />
<PrivateAccessRoute exact path="/reserve/testreservation" component={ReservationTest} aId="1" />
<PrivateAccessRoute exact path="/frontdesk/arrivals" component={Arrivals} aId="1" />
<PrivateAccessRoute exact path="/frontdesk/inhouse" component={Inhouse} aId="1" />
<PrivateAccessRoute exact path="/frontdesk/maintenance" component={Maintenance} aId="1" />
<PrivateAccessRoute exact path="/cashiering/billing" component={Billing} aId="1" />
<PrivateAccessRoute exact path="/cashiering/payment" component={Payment} aId="1" />
<PrivateAccessRoute exact path="/reports/housekeeping" component={Housekeeping} aId="1" />
<PrivateAccessRoute exact path="/reports/detailedAvailability" component={DetailedAvailability} aId="1" />
<PrivateAccessRoute exact path="/reports/houseStatus" component={HouseStatus} aId="1" />
</Switch>
</div>
</Col>
</Row>
</Container>
)
}
</Col>
<Col xs={6} sm={8} md={9} lg={9} xl={10}>
<Row className='pt-3'><span /></Row>
<div className='pl-2 m-0 py-0'>
<Switch>
<PrivateAccessRoute exact strict path='/' component={Dashboard} aId='1' />
<PrivateAccessRoute exact path='/reserve/new' component={ReserveNew} aId='1' />
<PrivateAccessRoute exact path='/reserve/allreservations' component={UpdateReservation} aId='1' />
<PrivateAccessRoute exact path='/reserve/testUpdatereservation' component={ReserveUpdate} aId='1' />
<PrivateAccessRoute exact path='/reserve/testreservation' component={ReservationTest} aId='1' />
<PrivateAccessRoute exact path='/frontdesk/arrivals' component={Arrivals} aId='1' />
<PrivateAccessRoute exact path='/frontdesk/inhouse' component={Inhouse} aId='1' />
<PrivateAccessRoute exact path='/frontdesk/maintenance' component={Maintenance} aId='1' />
<PrivateAccessRoute exact path='/cashiering/billing' component={Billing} aId='1' />
<PrivateAccessRoute exact path='/cashiering/payment' component={Payment} aId='1' />
<PrivateAccessRoute exact path='/reports/housekeeping' component={Housekeeping} aId='1' />
<PrivateAccessRoute exact path='/reports/detailedAvailability' component={DetailedAvailability} aId='1' />
<PrivateAccessRoute exact path='/reports/houseStatus' component={HouseStatus} aId='1' />
</Switch>
</div>
</Col>
</Row>
</Container>
)}
</Router>
</UserContext.Provider>
);
)
}
}

export default App;
export default App
14 changes: 7 additions & 7 deletions client/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

it("renders without crashing", () => {
const div = document.createElement("div");
ReactDOM.render(<App />, div);
});
it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<App />, div)
})
12 changes: 6 additions & 6 deletions client/src/UserContext.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from "react";
import React from 'react'

// Make sure the shape of the default value passed to
// createContext matches the shape that the consumers expect!
const UserContext = React.createContext({
user: {
access_id: 0,
type: "Guest",
type: 'Guest',
user_id: 0,
username: "guest"
username: 'guest'
},
getUserStatus: () => {},
postUserLogin: () => {},
getUserLogout: () => {},
});
export default UserContext;
getUserLogout: () => {}
})
export default UserContext
34 changes: 17 additions & 17 deletions client/src/components/Header/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import React from "react";
import { Row, Col } from 'react-grid-system';
import "./style.css"
import { Link } from 'react-router-dom';
import React from 'react'
import { Row, Col } from 'react-grid-system'
import './style.css'
import { Link } from 'react-router-dom'
const Header = props => {
return (
<div id="res6">
<Row>
<Col id="head" xs={9} sm={10} md={10} lg={11} xl={11}>
<h4>{props.children}</h4>
</Col>
<Col xs={3} sm={2} md={2} lg={1} xl={1}>
<Link id="xButton" className="btn navbar-right btn-primary" to="/" type="submit">X</Link>
</Col>
</Row>
</div>
return (
<div id='res6'>
<Row>
<Col id='head' xs={9} sm={10} md={10} lg={11} xl={11}>
<h4>{props.children}</h4>
</Col>
<Col xs={3} sm={2} md={2} lg={1} xl={1}>
<Link id='xButton' className='btn navbar-right btn-primary' to='/' type='submit'>X</Link>
</Col>
</Row>
</div>

)
)
}

export default Header;
export default Header
18 changes: 9 additions & 9 deletions client/src/components/RenderIfAId.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from "react";
import UserContext from "../UserContext";
// A function to wrap a component with that will render its children only if the user is logged in and
import React from 'react'
import UserContext from '../UserContext'
// A function to wrap a component with that will render its children only if the user is logged in and
// has an access_id that matches the aId passed as a prop to the function.
const RenderIfAId = (props) => (
const RenderIfAId = (props) => (
<UserContext.Consumer>
{
({user}) => ( user.access_id >= props.aId ? (
{
({ user }) => (user.access_id >= props.aId ? (
<div>{props.children}</div>
) : (null)
) : (null)
)
}
</UserContext.Consumer>
);
)

export default RenderIfAId;
export default RenderIfAId
Loading

0 comments on commit eac72a9

Please sign in to comment.