ErnestoOrtiz2 3 years ago
parent
commit
c20c4d842a

+ 9
- 3
screens/main/Calendar.js View File

11
       interpreter_id : this.props.route.params.Intereprete_id,
11
       interpreter_id : this.props.route.params.Intereprete_id,
12
       mapflag : this.props.route.params.Flag,
12
       mapflag : this.props.route.params.Flag,
13
       i_token: this.props.route.params.I_Token,
13
       i_token: this.props.route.params.I_Token,
14
-      u_token: this.props.route.params.U_Token
14
+      u_token: this.props.route.params.U_Token,
15
+      username: this.props.route.params.Username,
16
+      I_username: this.props.route.params.I_Username,
15
     };
17
     };
16
     this.onDateChange = this.onDateChange.bind(this);
18
     this.onDateChange = this.onDateChange.bind(this);
17
     
19
     
25
     console.log(this.props.route.params.Flag)
27
     console.log(this.props.route.params.Flag)
26
     
28
     
27
     if(this.state.mapflag == false){
29
     if(this.state.mapflag == false){
28
-      this.props.navigation.navigate('StateTime', {Appointment_Date: date._d, int_id : this.state.interpreter_id, Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token});
30
+      this.props.navigation.navigate('StateTime', {Appointment_Date: date._d, int_id : this.state.interpreter_id, 
31
+        Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token
32
+        ,Username: this.state.username, I_Username: this.state.I_username});
29
     }
33
     }
30
     else{
34
     else{
31
-      this.props.navigation.navigate('Map', {Appointment_Date: date._d, int_id : this.state.interpreter_id, Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token});
35
+      this.props.navigation.navigate('Map', {Appointment_Date: date._d, int_id : this.state.interpreter_id, 
36
+        Flag: this.state.mapflag, I_Token: this.state.i_token, U_Token: this.state.u_token
37
+        ,Username: this.state.username, I_Username: this.state.I_username});
32
     }
38
     }
33
   }
39
   }
34
   
40
   

+ 120
- 2
screens/main/Cita.js View File

19
    console.log("ID", route.params);
19
    console.log("ID", route.params);
20
    const [appointments, setAppointments] = useState([]); 
20
    const [appointments, setAppointments] = useState([]); 
21
 
21
 
22
+   const[interpreter, setState] = useState();
22
 
23
 
23
 
24
 
24
  useEffect(() => { 
25
  useEffect(() => { 
68
     
69
     
69
 
70
 
70
   
71
   
72
+  function check_user_type_INT(){ 
73
+
74
+    firebase.firestore()
75
+    .collection("Interprete")
76
+    .doc(firebase.auth().currentUser.uid)
77
+    .get()
78
+    .then((snapshot) => {
79
+      if(snapshot.exists){
80
+        setState(true);
81
+      }
82
+      else{
83
+        setState(false);
84
+      }
85
+    })
86
+
87
+    if(loading){
88
+      setLoading(false);
89
+    }
90
+
91
+  }
71
   
92
   
93
+  check_user_type_INT();
72
 
94
 
73
   const dimensions = Dimensions.get('window');
95
   const dimensions = Dimensions.get('window');
74
   const screenWidth = dimensions.width;
96
   const screenWidth = dimensions.width;
75
 
97
 
98
+  console.log("Inter: ", interpreter)
99
+
76
   const Pin = route.params.Pin;
100
   const Pin = route.params.Pin;
77
-  
101
+  if(interpreter == true){
78
   return (
102
   return (
79
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
103
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
80
         <FlatList style={{
104
         <FlatList style={{
110
         onPress={async () => {
134
         onPress={async () => {
111
           console.log("cita")
135
           console.log("cita")
112
         }}
136
         }}
113
-        >
137
+        > 
138
+        <List.Item
139
+          title='Usuario:'
140
+          description={item.User}
141
+          titleNumberOfLines={1}
142
+          titleStyle={styles.listTitle}
143
+          descriptionStyle={styles.listDescription}
144
+          descriptionNumberOfLines={1}
145
+          />
146
+          <List.Item
147
+            title='Mes:'
148
+            description={item.Month}
149
+            titleNumberOfLines={1}
150
+            titleStyle={styles.listTitle}
151
+            descriptionStyle={styles.listDescription}
152
+            descriptionNumberOfLines={1}
153
+          />
154
+          <List.Item
155
+            title='Día'
156
+            description={item.Day}
157
+            titleNumberOfLines={1}
158
+            titleStyle={styles.listTitle}
159
+            descriptionStyle={styles.listDescription}
160
+            descriptionNumberOfLines={1}
161
+          />
162
+          <List.Item
163
+            title='Hora:'
164
+            description={item.Time}
165
+            titleNumberOfLines={1}
166
+            titleStyle={styles.listTitle}
167
+            descriptionStyle={styles.listDescription}
168
+            descriptionNumberOfLines={1}
169
+          />
170
+        </TouchableOpacity>
171
+      )}
172
+          />
173
+      <Button
174
+        title ='Ver mapa'
175
+        onPress= {() => navigation.navigate('Map', {View_Only: true, Pin: Pin})}
176
+      />
177
+      <Button
178
+        title ='Logout'
179
+        onPress= {() => firebase.auth().signOut()}
180
+      />
181
+        </ImageBackground>
182
+    );
183
+    }
184
+
185
+    else{
186
+    return (
187
+      <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
188
+        <FlatList style={{
189
+             flex: 1,
190
+             width: screenWidth,
191
+         }}
192
+          data={threads}
193
+          keyExtractor = {item => item._id}
194
+          ItemSeparatorComponent={() => <Divider />}
195
+          renderItem = {({item}) => (
196
+          <TouchableOpacity
197
+            onPress={() => navigation.navigate('Room', {thread: item})}
198
+          >
199
+            <List.Item
200
+              title={item.name}
201
+              titleNumberOfLines={1}
202
+              titleStyle={styles.listTitle}
203
+              descriptionStyle={styles.listDescription}
204
+              descriptionNumberOfLines={1}
205
+            />
206
+          </TouchableOpacity>
207
+        )}
208
+        />
209
+        <FlatList style={{
210
+           flex: 1,
211
+           width: screenWidth,
212
+       }}
213
+        data={appointments}
214
+        keyExtractor = {item => item._id}
215
+        ItemSeparatorComponent={() => <Divider />}
216
+        renderItem = {({item}) => (
217
+        <TouchableOpacity
218
+        onPress={async () => {
219
+          console.log("cita")
220
+        }}
221
+        > 
222
+        <List.Item
223
+          title='Interprete:'
224
+          description={item.Interpreter}
225
+          titleNumberOfLines={1}
226
+          titleStyle={styles.listTitle}
227
+          descriptionStyle={styles.listDescription}
228
+          descriptionNumberOfLines={1}
229
+          />
114
           <List.Item
230
           <List.Item
115
             title='Mes:'
231
             title='Mes:'
116
             description={item.Month}
232
             description={item.Month}
148
       />
264
       />
149
         </ImageBackground>
265
         </ImageBackground>
150
     );
266
     );
267
+    }
151
   }
268
   }
152
 
269
 
153
 
270
 
158
 
275
 
159
 export default connect(mapStateToProps, mapDispatchProps)(Cita);
276
 export default connect(mapStateToProps, mapDispatchProps)(Cita);
160
 
277
 
278
+

+ 1
- 1
screens/main/Confirm.js View File

154
         />
154
         />
155
        <Button
155
        <Button
156
         title ='Ver mapa'
156
         title ='Ver mapa'
157
-        onPress= {() => navigation.navigate('Map')}
157
+        onPress= {() => navigation.navigate('Map',{View_Only: true, Confirm_Flag: true, Pin: appointments})}
158
       />
158
       />
159
       <FlatList style={{
159
       <FlatList style={{
160
              flex: 1,
160
              flex: 1,

+ 74
- 6
screens/main/Home_page.js View File

31
   const [appointments, setAppointments] = useState([]); 
31
   const [appointments, setAppointments] = useState([]); 
32
 
32
 
33
   const[interpreter, setState] = useState();
33
   const[interpreter, setState] = useState();
34
+  const [Iuser, setIUser] = useState({})
35
+  const [Uuser, setUser] = useState({})
34
 
36
 
35
   const [expoPushToken, setExpoPushToken] = useState('');
37
   const [expoPushToken, setExpoPushToken] = useState('');
36
   const [notification, setNotification] = useState(false);
38
   const [notification, setNotification] = useState(false);
54
       } 
56
       } 
55
     });
57
     });
56
 
58
 
59
+    const user_email = firebase.auth().currentUser.email;
60
+
61
+  const Iuser_data = firebase.firestore()
62
+  .collection('Interprete')
63
+  .where("email", "==", user_email)
64
+  .onSnapshot(snapShot => {
65
+    const user = snapShot.docs.map(docSnap => {
66
+      return{
67
+        _id:docSnap.id,
68
+        email:'',
69
+        username:'',
70
+        ...docSnap.data()
71
+      };
72
+    });
73
+      setIUser(user)
74
+
75
+      if(loading){
76
+        setLoading(false);
77
+      }
78
+  });
79
+
80
+  const user_data = firebase.firestore()
81
+  .collection('Users')
82
+  .where("email", "==", user_email)
83
+  .onSnapshot(snapShot => {
84
+    const user = snapShot.docs.map(docSnap => {
85
+      return{
86
+        _id:docSnap.id,
87
+        email:'',
88
+        username:'',
89
+        ...docSnap.data()
90
+      };
91
+    });
92
+      setUser(user)
93
+
94
+      if(loading){
95
+        setLoading(false);
96
+      }
97
+  });
98
+
99
+
57
     const fire = firebase.firestore()
100
     const fire = firebase.firestore()
58
     .collection('THREADS')
101
     .collection('THREADS')
59
     .where("members", "array-contains", firebase.auth().currentUser.uid)
102
     .where("members", "array-contains", firebase.auth().currentUser.uid)
77
       const appointments = snapShot.docs.map(docSnap => {
120
       const appointments = snapShot.docs.map(docSnap => {
78
         return{
121
         return{
79
           _id:docSnap.id,
122
           _id:docSnap.id,
123
+          User:'',
124
+          Interpreter:'',
80
           new:'',
125
           new:'',
81
           Day:'',
126
           Day:'',
82
           Month:'',
127
           Month:'',
97
       Notifications.removeNotificationSubscription(responseListener.current);
142
       Notifications.removeNotificationSubscription(responseListener.current);
98
       fire();
143
       fire();
99
       cita();
144
       cita();
145
+      Iuser_data();
146
+      user_data();
100
     }
147
     }
101
   }, []);
148
   }, []);
102
   
149
   
109
   const screenWidth = dimensions.width;
156
   const screenWidth = dimensions.width;
110
 
157
 
111
   
158
   
112
-  function check_user_type_INT(){
113
-
114
-    
159
+  function check_user_type_INT(){ 
115
 
160
 
116
     firebase.firestore()
161
     firebase.firestore()
117
     .collection("Interprete")
162
     .collection("Interprete")
141
       })
186
       })
142
   }
187
   }
143
   
188
   
189
+
144
   check_user_type_INT();
190
   check_user_type_INT();
145
   console.log("interpreter", interpreter);
191
   console.log("interpreter", interpreter);
192
+
193
+  
146
   if(interpreter == false){
194
   if(interpreter == false){
195
+    const user_name = Uuser[0].username;
147
     return (
196
     return (
148
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
197
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
149
       <FlatList style={{
198
       <FlatList style={{
160
           navigation.navigate('Cita',{tag: item, Pin: item})
209
           navigation.navigate('Cita',{tag: item, Pin: item})
161
         }}
210
         }}
162
         >
211
         >
212
+          <List.Item
213
+            title='Interprete: '
214
+            description={item.Interpreter}
215
+            titleNumberOfLines={1}
216
+            titleStyle={styles.listTitle}
217
+            descriptionStyle={styles.listDescription}
218
+            descriptionNumberOfLines={1}
219
+          />
163
            <List.Item
220
            <List.Item
164
             title='Mes:'
221
             title='Mes:'
165
             description={item.Month}
222
             description={item.Month}
210
             />
267
             />
211
         <Button
268
         <Button
212
           title ='Hacer Busqueda'
269
           title ='Hacer Busqueda'
213
-          onPress= {() => navigation.navigate('Search', {U_Token: expoPushToken})}
270
+          onPress= {() => navigation.navigate('Search', {U_Token: expoPushToken, Username: user_name})}
214
         />
271
         />
215
         <Button
272
         <Button
216
           title ='Logout'
273
           title ='Logout'
220
       );
277
       );
221
     }
278
     }
222
     else{
279
     else{
280
+      //En caso de que se necesite el username del interprete que esta logged in.
281
+      //const user_name = Iuser[0].username;
223
       return (
282
       return (
224
         <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
283
         <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
225
         <FlatList style={{
284
         <FlatList style={{
232
           renderItem = {({item}) => (
291
           renderItem = {({item}) => (
233
           <TouchableOpacity
292
           <TouchableOpacity
234
           onPress={async () => {
293
           onPress={async () => {
235
-            console.log("item._id, home, interpreter", item._id)
294
+            console.log("item._id, home, interpreter", item)
236
             navigation.navigate('Cita',{tag: item, Pin: item})
295
             navigation.navigate('Cita',{tag: item, Pin: item})
237
           }}
296
           }}
238
           >
297
           >
239
           <List.Item
298
           <List.Item
299
+            title='Usuario:'
300
+            description={item.User}
301
+            titleNumberOfLines={1}
302
+            titleStyle={styles.listTitle}
303
+            descriptionStyle={styles.listDescription}
304
+            descriptionNumberOfLines={1}
305
+          />
306
+          <List.Item
240
             title='Mes:'
307
             title='Mes:'
241
             description={item.Month}
308
             description={item.Month}
242
             titleNumberOfLines={1}
309
             titleNumberOfLines={1}
359
 })
426
 })
360
 const mapDispatchProps = (dispatch) => bindActionCreators({fetchUser}, dispatch);
427
 const mapDispatchProps = (dispatch) => bindActionCreators({fetchUser}, dispatch);
361
 
428
 
362
-export default connect(mapStateToProps, mapDispatchProps)(Home_page);
429
+export default connect(mapStateToProps, mapDispatchProps)(Home_page);
430
+

+ 38
- 7
screens/main/Map.js View File

2
 import { useState } from 'react';
2
 import { useState } from 'react';
3
 import MapView, { Marker } from 'react-native-maps';
3
 import MapView, { Marker } from 'react-native-maps';
4
 import { Button, StyleSheet, Text, View, Dimensions, Pressable } from 'react-native';
4
 import { Button, StyleSheet, Text, View, Dimensions, Pressable } from 'react-native';
5
+import { Confirm } from './Confirm';
5
 
6
 
6
 
7
 
7
 export default function Map({route, navigation} ) {
8
 export default function Map({route, navigation} ) {
17
     mapflag = route.params.Flag, 
18
     mapflag = route.params.Flag, 
18
     i_token = route.params.I_Token,
19
     i_token = route.params.I_Token,
19
     u_token =  route.params.U_Token,
20
     u_token =  route.params.U_Token,
21
+    username = route.params.Username,
22
+    I_username = route.params.I_Username,
23
+    Confirm_Flag = route.params.Confirm_Flag,
20
     View_Only = route.params.View_Only
24
     View_Only = route.params.View_Only
21
     } = route.params
25
     } = route.params
22
     
26
     
28
   if(View_Only == true){
32
   if(View_Only == true){
29
 
33
 
30
     const Retrive_pin = route.params.Pin;
34
     const Retrive_pin = route.params.Pin;
35
+    console.log("Retrieve lat", Retrive_pin)
31
 
36
 
32
-  console.log("Retrieve lat", Retrive_pin.Pin[0])
37
+    if(Confirm_Flag == true){
38
+      const [pin2, setPin2] = React.useState({
39
+        latitude: Retrive_pin[0].Pin[0],
40
+        longitude: Retrive_pin[0].Pin[1],
41
+      })
33
 
42
 
34
-  const [pin2, setPin2] = React.useState({
35
-    latitude: Retrive_pin.Pin[0],
36
-    longitude: Retrive_pin.Pin[1],
37
-  })
43
+      console.log("Pin2", pin2)
44
+  
45
+      return (
46
+        <View style={styles.container}>
47
+          <MapView style={styles.map}
48
+            initialRegion={{
49
+              latitude: pin2.latitude,
50
+              longitude: pin2.longitude,
51
+              latitudeDelta: 0.0922,
52
+              longitudeDelta: 0.0421,
53
+            }}
54
+            provider="google"
55
+          >
56
+            <Marker coordinate={pin2} />
57
+          </MapView>
58
+        </View>
59
+      );
60
+    }
38
 
61
 
39
-  console.log("Pin2", pin2)
62
+    else{
63
+      const [pin2, setPin2] = React.useState({
64
+      latitude: Retrive_pin.Pin[0],
65
+      longitude: Retrive_pin.Pin[1],
66
+      })
67
+    console.log("Pin2", pin2)
40
   
68
   
41
     return (
69
     return (
42
       <View style={styles.container}>
70
       <View style={styles.container}>
54
       </View>
82
       </View>
55
     );
83
     );
56
   }
84
   }
85
+}
57
   else{
86
   else{
58
 
87
 
59
     const [pin1, setPin1] = React.useState({
88
     const [pin1, setPin1] = React.useState({
82
           <Marker coordinate={pin1} />
111
           <Marker coordinate={pin1} />
83
         </MapView>
112
         </MapView>
84
           <View style = {{position: 'absolute', bottom: '5%'}}>
113
           <View style = {{position: 'absolute', bottom: '5%'}}>
85
-              <Button title= 'Confirm Location' onPress = {() => navigation.navigate('StateTime' , {Pin : pin1 , Appointment : Appointment, int_id : int_id, mapflag : mapflag, I_Token: i_token, U_Token: u_token})}/>
114
+              <Button title= 'Confirm Location' onPress = {() => navigation.navigate('StateTime' , {Pin : pin1 , Appointment : Appointment, int_id : int_id, 
115
+                mapflag : mapflag, I_Token: i_token, U_Token: u_token
116
+                ,Username: username, I_Username: I_username})}/>
86
           </View>
117
           </View>
87
       </View>
118
       </View>
88
       
119
       

+ 6
- 5
screens/main/Search.js View File

84
 function Search({route, navigation }) {
84
 function Search({route, navigation }) {
85
 
85
 
86
   const u_token = route.params.U_Token;
86
   const u_token = route.params.U_Token;
87
+  const username = route.params.Username;
87
   console.log("U__token: ", u_token)
88
   console.log("U__token: ", u_token)
88
   
89
   
89
   const [users, setUsers] = useState([])
90
   const [users, setUsers] = useState([])
115
       //check which tags where called in the search 
116
       //check which tags where called in the search 
116
       if (tags[i].id === 'PL') {
117
       if (tags[i].id === 'PL') {
117
         console.log('Presencial')
118
         console.log('Presencial')
118
-        query = query.where('face_to_face', '==', true)
119
+        query = query.where('Modalidad.Presencial', '==', true)
119
         mapflag = true
120
         mapflag = true
120
       }
121
       }
121
       if (tags[i].id == 'ON') {
122
       if (tags[i].id == 'ON') {
250
           return (
251
           return (
251
           <View>
252
           <View>
252
             <View style={{ flexDirection: "row", paddingBottom: 20, paddingTop: 20,  justifyContent: "space-between" }}>
253
             <View style={{ flexDirection: "row", paddingBottom: 20, paddingTop: 20,  justifyContent: "space-between" }}>
253
-              <Text>{item.data.name}</Text>
254
+              <Text>{item.data.username}</Text>
254
               <Text>{item.data.Precio}</Text>
255
               <Text>{item.data.Precio}</Text>
255
-              <Button title='Buscar' onPress={() => { dothing(item.id, item.data.push_token, u_token) }}/>
256
+              <Button title='Buscar' onPress={() => { dothing(item.id, item.data.push_token, u_token, item.data.username) }}/>
256
             </View>
257
             </View>
257
             <View style={{ borderBottomColor: 'black', borderBottomWidth: 1 }} />
258
             <View style={{ borderBottomColor: 'black', borderBottomWidth: 1 }} />
258
           </View>
259
           </View>
268
     return (item) => setSelectedTags(xorBy(selectedTags, [item], 'id'))
269
     return (item) => setSelectedTags(xorBy(selectedTags, [item], 'id'))
269
   }
270
   }
270
   
271
   
271
-  function dothing(item, i_token, u_token) {
272
+  function dothing(item, i_token, u_token, I_username) {
272
     console.log('This is the item id: ', item, "With i_token: ", i_token, " u_token : ", u_token)
273
     console.log('This is the item id: ', item, "With i_token: ", i_token, " u_token : ", u_token)
273
-    navigation.navigate('Calendar', {Intereprete_id: item, Flag: mapflag, I_Token: i_token, U_Token: u_token})
274
+    navigation.navigate('Calendar', {Intereprete_id: item, Flag: mapflag, I_Token: i_token, U_Token: u_token, Username: username, I_Username: I_username})
274
   } 
275
   } 
275
 
276
 
276
 }
277
 }

+ 6
- 0
screens/main/StateTime.js View File

18
       mapflag: this.props.route.params.mapflag,
18
       mapflag: this.props.route.params.mapflag,
19
       i_token: this.props.route.params.I_Token,
19
       i_token: this.props.route.params.I_Token,
20
       u_token: this.props.route.params.U_Token,
20
       u_token: this.props.route.params.U_Token,
21
+      username: this.props.route.params.Username,
22
+      I_username: this.props.route.params.I_Username,
21
       pin: this.props.route.params.Pin
23
       pin: this.props.route.params.Pin
22
     }
24
     }
23
     console.log(" Time params: ",this.props.route.params)
25
     console.log(" Time params: ",this.props.route.params)
125
     console.log(this.state.u_token)
127
     console.log(this.state.u_token)
126
     const user = firebase.auth().currentUser;
128
     const user = firebase.auth().currentUser;
127
     const uid = user.uid
129
     const uid = user.uid
130
+    const username = this.state.username;
131
+    const I_username = this.state.I_username;
128
     const u_token = this.state.u_token;
132
     const u_token = this.state.u_token;
129
     const i_token = this.state.i_token;
133
     const i_token = this.state.i_token;
130
     const date = this.state.Appointment
134
     const date = this.state.Appointment
139
     firebase.firestore()
143
     firebase.firestore()
140
     .collection('APPOINTMENTS')
144
     .collection('APPOINTMENTS')
141
     .add({ 
145
     .add({ 
146
+      User: username,
147
+      Interpreter: I_username,
142
       participantes: [
148
       participantes: [
143
       i_id,
149
       i_id,
144
       uid, 
150
       uid,