|
@@ -1,61 +1,200 @@
|
1
|
|
-import React from "react";
|
2
|
|
-import firebase from "firebase";
|
3
|
|
-import { Component } from "react";
|
4
|
|
-import { TouchableWithoutFeedback, ImageBackground, Text, Button } from "react-native";
|
5
|
|
-import { styles } from "../../config/styles";
|
6
|
|
-import CustomButton from "../../components/CustomButton";
|
7
|
|
-
|
8
|
|
-export default class Time extends Component{
|
9
|
|
- constructor(props){
|
10
|
|
- super(props);
|
11
|
|
- this.state = {
|
12
|
|
- Appointment : this.props.route.params.Appointment_Date,
|
13
|
|
- int2_id : this.props.route.params.int_id,
|
14
|
|
- }
|
15
|
|
- this.time_assignment = this.time_assignment.bind(this);
|
16
|
|
- }
|
17
|
|
-
|
18
|
|
-
|
19
|
|
- time_assignment(desired_time, selectedTime){
|
20
|
|
-
|
21
|
|
- if(desired_time == 1){
|
22
|
|
- selectedTime = "8:00am-9:00am"
|
23
|
|
- }
|
24
|
|
-
|
25
|
|
- console.log(this.props.route.params)
|
26
|
|
- const user = firebase.auth().currentUser
|
27
|
|
- const uid = user.uid
|
28
|
|
- const month = this.state.Appointment.month
|
29
|
|
- const day = this.state.Appointment.day
|
30
|
|
- const _time_ = selectedTime
|
31
|
|
- const i_id = this.state.int2_id
|
32
|
|
- firebase.firestore()
|
33
|
|
- .collection('APPOINTMENTS')
|
34
|
|
- .add({
|
35
|
|
- i_id : i_id,
|
36
|
|
- uid1: uid,
|
37
|
|
- Month : month,
|
38
|
|
- Day: day,
|
39
|
|
- Time: _time_})
|
40
|
|
-
|
41
|
|
- this.props.navigation.navigate('Home')
|
42
|
|
- }
|
43
|
|
-
|
44
|
|
-
|
45
|
|
-render(){
|
46
|
|
- return(
|
47
|
|
- <TouchableWithoutFeedback style={styles.stdcontainer}>
|
48
|
|
- <ImageBackground style={styles.regcontainer} source={require('../../assets/yellow-white.jpg')}>
|
49
|
|
- <Text style={styles.stdcontainer}> Please select a time frame for the appointment</Text>
|
50
|
|
- <Button
|
51
|
|
- title ='Ver mapa'
|
52
|
|
- onPress= {() => this.props.navigation.navigate('Map')}
|
53
|
|
- />
|
54
|
|
- <CustomButton marginTop={25} title="8:00am-9:00am" onPress={() => this.time_assignment(1,)}/>
|
55
|
|
-
|
56
|
|
- </ImageBackground>
|
57
|
|
- </TouchableWithoutFeedback>
|
58
|
|
- );
|
59
|
|
- }
|
60
|
|
-}
|
61
|
|
-
|
|
1
|
+import React from "react";
|
|
2
|
+import firebase from "firebase";
|
|
3
|
+import { Component } from "react";
|
|
4
|
+import { TouchableWithoutFeedback, ImageBackground, Text } from "react-native";
|
|
5
|
+import { styles } from "../../config/styles";
|
|
6
|
+import { Button, View} from 'react-native'
|
|
7
|
+import moment from "moment";
|
|
8
|
+
|
|
9
|
+export default class Time extends Component{
|
|
10
|
+ constructor(props){
|
|
11
|
+ super(props);
|
|
12
|
+ this.starttime = 0 ,
|
|
13
|
+ this.endtime = 0,
|
|
14
|
+ this.timesetter = 0,
|
|
15
|
+ this.state = {
|
|
16
|
+ Appointment : this.props.route.params.Appointment_Date,
|
|
17
|
+ int2_id : this.props.route.params.int_id,
|
|
18
|
+ mapflag: this.props.route.params.mapflag,
|
|
19
|
+ Pin: this.props.route.params.Pin
|
|
20
|
+ }
|
|
21
|
+ console.log(this.props.route.params)
|
|
22
|
+ this.time_assignment = this.time_assignment.bind(this);
|
|
23
|
+ }
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+ time_set(desired_time){
|
|
27
|
+
|
|
28
|
+ if(!this.startTime){
|
|
29
|
+ if(desired_time == 1){
|
|
30
|
+ this.startTime = "8:00am"
|
|
31
|
+ }
|
|
32
|
+ if(desired_time == 2){
|
|
33
|
+ this.startTime = "9:00am"
|
|
34
|
+ }
|
|
35
|
+ if(desired_time == 3){
|
|
36
|
+ this.startTime = "10:00am"
|
|
37
|
+ }
|
|
38
|
+ if(desired_time == 4){
|
|
39
|
+ this.startTime = "11:00am"
|
|
40
|
+ }
|
|
41
|
+ if(desired_time == 5){
|
|
42
|
+ this.startTime = "12:00pm"
|
|
43
|
+ }
|
|
44
|
+ if(desired_time == 6){
|
|
45
|
+ this.startTime = "1:00pm"
|
|
46
|
+ }
|
|
47
|
+ if(desired_time == 7){
|
|
48
|
+ this.startTime = "2:00pm"
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ this.timesetter = desired_time
|
|
52
|
+ }
|
|
53
|
+ else{
|
|
54
|
+
|
|
55
|
+ if(this.timesetter > desired_time){
|
|
56
|
+
|
|
57
|
+ this.endtime = this.startTime
|
|
58
|
+
|
|
59
|
+ if(desired_time == 1){
|
|
60
|
+ this.startTime = "8:00am"
|
|
61
|
+ }
|
|
62
|
+ if(desired_time == 2){
|
|
63
|
+ this.startTime = "9:00am"
|
|
64
|
+ }
|
|
65
|
+ if(desired_time == 3){
|
|
66
|
+ this.startTime = "10:00am"
|
|
67
|
+ }
|
|
68
|
+ if(desired_time == 4){
|
|
69
|
+ this.startTime = "11:00am"
|
|
70
|
+ }
|
|
71
|
+ if(desired_time == 5){
|
|
72
|
+ this.startTime = "12:00pm"
|
|
73
|
+ }
|
|
74
|
+ if(desired_time == 6){
|
|
75
|
+ this.startTime = "1:00pm"
|
|
76
|
+ }
|
|
77
|
+ if(desired_time == 7){
|
|
78
|
+ this.startTime = "2:00pm"
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+ }
|
|
83
|
+ else{
|
|
84
|
+
|
|
85
|
+ if(desired_time == 1){
|
|
86
|
+ this.endtime = "8:00am"
|
|
87
|
+ }
|
|
88
|
+ if(desired_time == 2){
|
|
89
|
+ this.endtime = "9:00am"
|
|
90
|
+ }
|
|
91
|
+ if(desired_time == 3){
|
|
92
|
+ this.endtime = "10:00am"
|
|
93
|
+ }
|
|
94
|
+ if(desired_time == 4){
|
|
95
|
+ this.endtime = "11:00am"
|
|
96
|
+ }
|
|
97
|
+ if(desired_time == 5){
|
|
98
|
+ this.endtime = "12:00pm"
|
|
99
|
+ }
|
|
100
|
+ if(desired_time == 6){
|
|
101
|
+ this.endtime = "1:00pm"
|
|
102
|
+ }
|
|
103
|
+ if(desired_time == 7){
|
|
104
|
+ this.endtime = "2:00pm"
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+ }
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ time_assignment(selectedTime){
|
|
117
|
+
|
|
118
|
+ selectedTime = this.startTime +'-'+ this.endtime
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+ if(this.state.mapflag == true){
|
|
122
|
+ console.log("Pin is: ")
|
|
123
|
+ console.log(this.state.Pin)
|
|
124
|
+ const user = firebase.auth().currentUser;
|
|
125
|
+ const uid = user.uid;
|
|
126
|
+ const date = this.state.Appointment;
|
|
127
|
+ const month = date.month();
|
|
128
|
+ const day = date.date();
|
|
129
|
+ const _time_ = selectedTime;
|
|
130
|
+ const i_id = this.state.int2_id;
|
|
131
|
+ const pin = this.state.Pin;
|
|
132
|
+ const lat = pin.latitude;
|
|
133
|
+ const lon = pin.longitude;
|
|
134
|
+ console.log('Params: ')
|
|
135
|
+ console.log(this.props.route.params)
|
|
136
|
+ console.log("lat is: ")
|
|
137
|
+ console.log(lat)
|
|
138
|
+ firebase.firestore()
|
|
139
|
+ .collection('APPOINTMENTS')
|
|
140
|
+ .add({
|
|
141
|
+ participantes: [
|
|
142
|
+ i_id,
|
|
143
|
+ uid,
|
|
144
|
+ ],
|
|
145
|
+ Month : month,
|
|
146
|
+ Day: day,
|
|
147
|
+ Time: _time_,
|
|
148
|
+ Pin: [
|
|
149
|
+ lat,
|
|
150
|
+ lon,
|
|
151
|
+ ],
|
|
152
|
+ })
|
|
153
|
+
|
|
154
|
+ }
|
|
155
|
+ else{
|
|
156
|
+ const user = firebase.auth().currentUser
|
|
157
|
+ const uid = user.uid
|
|
158
|
+ const date = moment(this.state.Appointment)
|
|
159
|
+ const month = date.month()
|
|
160
|
+ const day = date.date()
|
|
161
|
+ const _time_ = selectedTime
|
|
162
|
+ const i_id = this.state.int2_id
|
|
163
|
+ console.log('Params: ')
|
|
164
|
+ console.log(this.props.route.params)
|
|
165
|
+ firebase.firestore()
|
|
166
|
+ .collection('APPOINTMENTS')
|
|
167
|
+ .add({
|
|
168
|
+ participantes: [
|
|
169
|
+ i_id,
|
|
170
|
+ uid,
|
|
171
|
+ ],
|
|
172
|
+ Month : month,
|
|
173
|
+ Day: day,
|
|
174
|
+ Time: _time_,
|
|
175
|
+ })
|
|
176
|
+
|
|
177
|
+ }
|
|
178
|
+
|
|
179
|
+ this.props.navigation.navigate('Home');
|
|
180
|
+
|
|
181
|
+ }
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+ render(){
|
|
185
|
+ return(
|
|
186
|
+ <TouchableWithoutFeedback style={styles.stdcontainer}>
|
|
187
|
+ <ImageBackground style={styles.regcontainer} source={require('../../assets/yellow-white.jpg')}>
|
|
188
|
+ <Button style={styles.cenregbutton} title="8:00am" onPress={() => this.time_set(1,)}/>
|
|
189
|
+ <Button style={styles.cenregbutton} title="9:00am" onPress={() => this.time_set(2,)}/>
|
|
190
|
+ <Button style={styles.cenregbutton} title="10:00am" onPress={() => this.time_set(3,)}/>
|
|
191
|
+ <Button style={styles.cenregbutton} title="11:00am" onPress={() => this.time_set(4,)}/>
|
|
192
|
+ <Button style={styles.cenregbutton} title="12:00pm" onPress={() => this.time_set(5,)}/>
|
|
193
|
+ <Button style={styles.cenregbutton} title="1:00pm" onPress={() => this.time_set(6,)}/>
|
|
194
|
+ <Button style={styles.cenregbutton} title="2:00pm" onPress={() => this.time_set(7,)}/>
|
|
195
|
+ <Button style={styles.cenregbutton} title="Request Appointment" onPress={() => this.time_assignment()}/>
|
|
196
|
+ </ImageBackground>
|
|
197
|
+ </TouchableWithoutFeedback>
|
|
198
|
+ );
|
|
199
|
+ }
|
|
200
|
+}
|