-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
87 lines (77 loc) · 1.97 KB
/
App.js
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
import React from 'react';
import { View } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { ThemeProvider } from 'react-native-elements';
import { Appbar } from 'material-bread';
import TurnosView from './src/TurnosView';
import TurnosMedicosView from './src/TurnosMedicosView';
import LoginView from './src/LoginView';
const theme = {
colors: {
primary: '#FF5656',
grey0: "#DAD6D6"
}
}
export default function App() {
global.backendUrl = "https://medical-managment-backend.herokuapp.com/";
return (
<NavigationContainer>
<ThemeProvider theme={theme}>
<MainScreen/>
</ThemeProvider>
</NavigationContainer>
);
}
class MainScreen extends React.Component {
constructor(props) {
super(props);
this.state = {
loginStatus: "",
person: []
}
}
loginStatus(data) {
this.setState({
loginStatus: "200",
person: data
})
}
leaveSession() {
this.setState({
loginStatus: "",
person: undefined
})
}
render(){
var loginStatus = this.loginStatus;
var leaveSession = this.leaveSession;
return(
<View style={{flex: 1}}>
{
(this.state.loginStatus === "200") ? <HomeScreen personData={this.state.person} leaveSession={leaveSession.bind(this)}/> : <LoginView loginStatus={loginStatus.bind(this)}/>
}
</View>
)
}
}
class HomeScreen extends React.Component {
constructor() {
super();
this.state = {
role: "",
titleColor: "#FF5656"
}
}
render() {
return(
<View style={{ flex: 1}}>
{
(this.props.personData.role.role === "medic") && <TurnosMedicosView personData={this.props.personData} leaveSession={this.props.leaveSession}/>
}
{
(this.props.personData.role.role === "patient") && <TurnosView personData={this.props.personData} leaveSession={this.props.leaveSession}/>
}
</View>
)
};
};