1
- import React , { Component } from " react" ;
2
- import { BrowserRouter as Router , Route , Switch , Redirect } from " react-router-dom" ;
3
- import { Row , Col } from 'react-grid-system' ;
4
- import Container from " react-bootstrap/Container" ;
5
- import Particles from " react-particles-js" ;
6
- import UserContext from " ./UserContext" ;
7
- import InfoPart from " ./components/infoPart" ;
8
- import authapi from " ./utils/authapi" ;
9
- import ReserveNew from " ./pages/newreservation/newreservation" ;
10
- import ReserveUpdate from " ./pages/updatereservation/updatereservation" ;
11
- import Dashboard from " ./pages/dashboard/dashboard" ;
12
- import UpdateReservation from " ./pages/allreservations/allreservations" ;
13
- import Arrivals from " ./pages/arrivals/arrivals" ;
14
- import Billing from " ./pages/billing/billing" ;
15
- import Payment from " ./pages/payment/payment" ;
16
- import Inhouse from " ./pages/inhouse/inhouse" ;
17
- import Login from " ./pages/login/login" ;
18
- import ReservationTest from " ./pages/newreservation/reservationTest" ;
19
- import Housekeeping from " ./pages/housekeeping/housekeeping" ;
20
- import DetailedAvailability from " ./pages/detailedAvailability/detailedAvailability" ;
21
- import HouseStatus from " ./pages/houseStatus/houseStatus" ;
22
- import Maintenance from " ./pages/maintenance/maintenance" ;
1
+ import React , { Component } from ' react'
2
+ import { BrowserRouter as Router , Route , Switch , Redirect } from ' react-router-dom'
3
+ import { Row , Col } from 'react-grid-system'
4
+ import Container from ' react-bootstrap/Container'
5
+ import Particles from ' react-particles-js'
6
+ import UserContext from ' ./UserContext'
7
+ import InfoPart from ' ./components/infoPart'
8
+ import authapi from ' ./utils/authapi'
9
+ import ReserveNew from ' ./pages/newreservation/newreservation'
10
+ import ReserveUpdate from ' ./pages/updatereservation/updatereservation'
11
+ import Dashboard from ' ./pages/dashboard/dashboard'
12
+ import UpdateReservation from ' ./pages/allreservations/allreservations'
13
+ import Arrivals from ' ./pages/arrivals/arrivals'
14
+ import Billing from ' ./pages/billing/billing'
15
+ import Payment from ' ./pages/payment/payment'
16
+ import Inhouse from ' ./pages/inhouse/inhouse'
17
+ import Login from ' ./pages/login/login'
18
+ import ReservationTest from ' ./pages/newreservation/reservationTest'
19
+ import Housekeeping from ' ./pages/housekeeping/housekeeping'
20
+ import DetailedAvailability from ' ./pages/detailedAvailability/detailedAvailability'
21
+ import HouseStatus from ' ./pages/houseStatus/houseStatus'
22
+ import Maintenance from ' ./pages/maintenance/maintenance'
23
23
24
- const particleOptions = { particles : { number : { value : 120 , density : { enable : true , value_area : 1000 } } } } ;
24
+ const particleOptions = { particles : { number : { value : 120 , density : { enable : true , value_area : 1000 } } } }
25
25
26
26
const PrivateAccessRoute = ( { component : Component , aId, ...rest } ) => (
27
27
< UserContext . Consumer >
@@ -34,102 +34,101 @@ const PrivateAccessRoute = ({ component: Component, aId, ...rest }) => (
34
34
) : (
35
35
< Redirect
36
36
to = { {
37
- pathname : "/" ,
37
+ pathname : '/' ,
38
38
state : { from : props . location }
39
39
} }
40
40
/>
41
- )
42
- }
41
+ ) }
43
42
/>
44
43
) }
45
44
</ UserContext . Consumer >
46
- ) ;
45
+ )
47
46
48
47
class App extends Component {
49
- constructor ( props ) {
50
- super ( props ) ;
48
+ constructor ( props ) {
49
+ super ( props )
51
50
this . postUserLogin = userData => {
52
51
if ( userData ) {
53
52
authapi . postUserLogin ( userData , ( err , res ) => {
54
53
if ( err === true ) {
55
- return console . log ( " Failed to log in" ) ;
54
+ return console . log ( ' Failed to log in' )
56
55
}
57
- this . setState ( { user : res . user } ) ;
58
- } ) ;
56
+ this . setState ( { user : res . user } )
57
+ } )
59
58
}
60
- } ;
59
+ }
61
60
this . getUserLogout = event => {
62
- event . preventDefault ( ) ;
63
- authapi . getLoggedOut ( ) . then ( this . getUserStatus ) ;
64
- } ;
61
+ event . preventDefault ( )
62
+ authapi . getLoggedOut ( ) . then ( this . getUserStatus )
63
+ }
65
64
this . getUserStatus = ( ) => {
66
65
authapi . getLoginStatus ( ) . then ( res => {
67
66
if ( res ) {
68
- this . setState ( ( ) => (
67
+ this . setState ( ( ) => (
69
68
{ user : res . user }
70
- )
71
- ) ;
69
+ )
70
+ )
72
71
}
73
- } ) ;
74
- } ;
72
+ } )
73
+ }
75
74
this . state = {
76
75
user : {
77
76
access_id : 0 ,
78
- type : " Guest" ,
77
+ type : ' Guest' ,
79
78
user_id : 0 ,
80
- username : " guest"
79
+ username : ' guest'
81
80
} ,
82
81
getUserStatus : this . getUserStatus ,
83
82
getUserLogout : this . getUserLogout ,
84
83
postUserLogin : this . postUserLogin
85
- } ;
84
+ }
86
85
}
87
- render ( ) {
88
- let { user } = this . state ;
86
+
87
+ render ( ) {
88
+ const { user } = this . state
89
89
return (
90
90
< UserContext . Provider value = { this . state } >
91
- < Router >
92
- { user . access_id === 0 ? (
91
+ < Router >
92
+ { user . access_id === 0 ? (
93
93
< div >
94
- < Redirect to = "/" />
94
+ < Redirect to = '/' />
95
95
< Login />
96
- </ div > ) :
97
- (
98
- < Container className = " m-0 p-0" >
99
- < Particles params = { particleOptions } />
100
- < Row className = " m-0 py-2" >
101
- < Col xs = { 6 } sm = { 4 } md = { 3 } lg = { 3 } xl = { 2 } >
102
- < Row className = " pt-3" > < span > </ span > </ Row >
96
+ </ div > )
97
+ : (
98
+ < Container className = ' m-0 p-0' >
99
+ < Particles params = { particleOptions } />
100
+ < Row className = ' m-0 py-2' >
101
+ < Col xs = { 6 } sm = { 4 } md = { 3 } lg = { 3 } xl = { 2 } >
102
+ < Row className = ' pt-3' > < span / ></ Row >
103
103
< InfoPart />
104
- </ Col >
105
- < Col xs = { 6 } sm = { 8 } md = { 9 } lg = { 9 } xl = { 10 } >
106
- < Row className = "pt-3" > < span > </ span > </ Row >
107
- < div className = "pl-2 m-0 py-0" >
108
- < Switch >
109
- < PrivateAccessRoute exact strict path = "/" component = { Dashboard } aId = "1" />
110
- < PrivateAccessRoute exact path = "/reserve/new" component = { ReserveNew } aId = "1" />
111
- < PrivateAccessRoute exact path = "/reserve/allreservations" component = { UpdateReservation } aId = "1" />
112
- < PrivateAccessRoute exact path = "/reserve/testUpdatereservation" component = { ReserveUpdate } aId = "1" />
113
- < PrivateAccessRoute exact path = "/reserve/testreservation" component = { ReservationTest } aId = "1" />
114
- < PrivateAccessRoute exact path = "/frontdesk/arrivals" component = { Arrivals } aId = "1" />
115
- < PrivateAccessRoute exact path = "/frontdesk/inhouse" component = { Inhouse } aId = "1" />
116
- < PrivateAccessRoute exact path = "/frontdesk/maintenance" component = { Maintenance } aId = "1" />
117
- < PrivateAccessRoute exact path = "/cashiering/billing" component = { Billing } aId = "1" />
118
- < PrivateAccessRoute exact path = "/cashiering/payment" component = { Payment } aId = "1" />
119
- < PrivateAccessRoute exact path = "/reports/housekeeping" component = { Housekeeping } aId = "1" />
120
- < PrivateAccessRoute exact path = "/reports/detailedAvailability" component = { DetailedAvailability } aId = "1" />
121
- < PrivateAccessRoute exact path = "/reports/houseStatus" component = { HouseStatus } aId = "1" />
122
- </ Switch >
123
- </ div >
124
- </ Col >
125
- </ Row >
126
- </ Container >
127
- )
128
- }
104
+ </ Col >
105
+ < Col xs = { 6 } sm = { 8 } md = { 9 } lg = { 9 } xl = { 10 } >
106
+ < Row className = 'pt-3' > < span /> </ Row >
107
+ < div className = 'pl-2 m-0 py-0' >
108
+ < Switch >
109
+ < PrivateAccessRoute exact strict path = '/' component = { Dashboard } aId = '1' />
110
+ < PrivateAccessRoute exact path = '/reserve/new' component = { ReserveNew } aId = '1' />
111
+ < PrivateAccessRoute exact path = '/reserve/allreservations' component = { UpdateReservation } aId = '1' />
112
+ < PrivateAccessRoute exact path = '/reserve/testUpdatereservation' component = { ReserveUpdate } aId = '1' />
113
+ < PrivateAccessRoute exact path = '/reserve/testreservation' component = { ReservationTest } aId = '1' />
114
+ < PrivateAccessRoute exact path = '/frontdesk/arrivals' component = { Arrivals } aId = '1' />
115
+ < PrivateAccessRoute exact path = '/frontdesk/inhouse' component = { Inhouse } aId = '1' />
116
+ < PrivateAccessRoute exact path = '/frontdesk/maintenance' component = { Maintenance } aId = '1' />
117
+ < PrivateAccessRoute exact path = '/cashiering/billing' component = { Billing } aId = '1' />
118
+ < PrivateAccessRoute exact path = '/cashiering/payment' component = { Payment } aId = '1' />
119
+ < PrivateAccessRoute exact path = '/reports/housekeeping' component = { Housekeeping } aId = '1' />
120
+ < PrivateAccessRoute exact path = '/reports/detailedAvailability' component = { DetailedAvailability } aId = '1' />
121
+ < PrivateAccessRoute exact path = '/reports/houseStatus' component = { HouseStatus } aId = '1' />
122
+ </ Switch >
123
+ </ div >
124
+ </ Col >
125
+ </ Row >
126
+ </ Container >
127
+ ) }
129
128
</ Router >
130
129
</ UserContext . Provider >
131
- ) ;
130
+ )
132
131
}
133
132
}
134
133
135
- export default App ;
134
+ export default App
0 commit comments