FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
erover-react/src/app.jsx at master · lpython/erover-react · GitHub
lpython
erover-react
Repository navigation
Code
Issues
Pull requests
10
(10)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
erover-react
/
src
/
app.jsx
Copy path
More file actions
More file actions
Latest commit
History
History
History
123 lines (99 loc) · 2.92 KB
Breadcrumbs
erover-react
/
src
/
app.jsx
Copy path
File metadata and controls
123 lines (99 loc) · 2.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import
React
,
{
Component
}
from
'react'
import
ReactDOM
from
'react-dom'
;
import
'typeface-roboto'
;
import
{
MuiThemeProvider
,
createMuiTheme
,
CssBaseline
,
withStyles
,
}
from
'@material-ui/core'
;
import
{
deepOrange
,
amber
}
from
'@material-ui/core/colors'
;
import
{
BrowserRouter
,
Route
,
Switch
}
from
'react-router-dom'
;
import
*
as
R
from
'ramda'
;
import
SignIn
from
'./sign-in.jsx'
;
import
CreateUser
from
'./create-user.jsx'
;
import
User
from
'./user.jsx'
;
import
{
AppContext
}
from
'./contexts.js'
;
import
*
as
Back
from
'./back/back.js'
;
const
theme
=
createMuiTheme
(
{
palette
:
{
primary
:
{
main
:
deepOrange
[
300
]
,
light
:
deepOrange
[
200
]
,
dark
:
deepOrange
[
900
]
}
,
secondary
:
{
main
:
amber
.
A400
,
light
:
amber
[
200
]
,
dark
:
amber
[
700
]
}
}
,
overrides
:
{
MuiFormControlLabel
:
{
root
:
{
width
:
'100%'
}
}
}
}
)
;
class
App
extends
Component
{
browserRouter
=
React
.
createRef
(
)
;
state
=
{
user
:
null
}
;
handleSignIn
=
credientials
=>
{
return
Back
.
SignIn
(
credientials
)
.
then
(
user
=>
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
)
)
;
this
.
browserRouter
.
current
.
history
.
push
(
'/user'
)
;
}
)
}
handleFormRetrieval
=
facilityID
=>
{
const
user
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
)
;
const
facilities
=
user
.
facilities
;
const
index
=
facilities
.
findIndex
(
f
=>
f
.
id
==
facilityID
)
;
if
(
!
R
.
is
(
Object
,
facilities
[
index
]
.
femap154
)
)
{
facilities
[
index
]
.
femap154
=
{
}
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
)
)
;
}
return
facilities
[
index
]
.
femap154
;
}
handleFormSave
=
(
facilityID
,
form
)
=>
{
const
user
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
)
;
const
facilities
=
user
.
facilities
;
const
index
=
facilities
.
findIndex
(
f
=>
f
.
id
==
facilityID
)
;
facilities
[
index
]
.
femap154
=
form
;
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
user
)
)
;
console
.
log
(
user
)
Back
.
SaveUser
(
user
)
.
catch
(
(
error
)
=>
console
.
error
(
"Unable to save user"
,
error
)
)
}
appContextEvents
=
(
)
=>
(
{
attemptSignIn
:
this
.
handleSignIn
,
retrieveForm
:
this
.
handleFormRetrieval
,
saveForm
:
this
.
handleFormSave
}
)
componentDidMount
(
)
{
console
.
log
(
this
.
browserRouter
)
}
render
(
)
{
return
(
<
AppContext
.
Provider
value
=
{
this
.
appContextEvents
(
)
}
>
<
BrowserRouter
ref
=
{
this
.
browserRouter
}
>
<
Switch
>
<
Route
path
=
"/"
component
=
{
SignIn
}
exact
/>
<
Route
path
=
"/newUser"
component
=
{
CreateUser
}
exact
/>
<
Route
path
=
"/user"
component
=
{
User
}
/>
<
Route
component
=
{
(
)
=>
<
h6
>
Not found
</
h6
>
}
/>
</
Switch
>
</
BrowserRouter
>
</
AppContext
.
Provider
>
)
;
}
}
document
.
addEventListener
(
'DOMContentLoaded'
,
(
)
=>
ReactDOM
.
render
(
(
<
MuiThemeProvider
theme
=
{
theme
}
>
<
CssBaseline
/>
<
App
/>
</
MuiThemeProvider
>
)
,
document
.
querySelector
(
'#app'
)
)
)
;
Back
|
FazBrowse Home
|
New Git URL