ErnestoOrtiz2 2 years ago
parent
commit
c20c4d842a

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

@@ -11,7 +11,9 @@ export default class Calendario extends Component {
11 11
       interpreter_id : this.props.route.params.Intereprete_id,
12 12
       mapflag : this.props.route.params.Flag,
13 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 18
     this.onDateChange = this.onDateChange.bind(this);
17 19
     
@@ -25,10 +27,14 @@ export default class Calendario extends Component {
25 27
     console.log(this.props.route.params.Flag)
26 28
     
27 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 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,6 +19,7 @@ export function Cita({route, navigation}) {
19 19
    console.log("ID", route.params);
20 20
    const [appointments, setAppointments] = useState([]); 
21 21
 
22
+   const[interpreter, setState] = useState();
22 23
 
23 24
 
24 25
  useEffect(() => { 
@@ -68,13 +69,36 @@ export function Cita({route, navigation}) {
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 95
   const dimensions = Dimensions.get('window');
74 96
   const screenWidth = dimensions.width;
75 97
 
98
+  console.log("Inter: ", interpreter)
99
+
76 100
   const Pin = route.params.Pin;
77
-  
101
+  if(interpreter == true){
78 102
   return (
79 103
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
80 104
         <FlatList style={{
@@ -110,7 +134,99 @@ export function Cita({route, navigation}) {
110 134
         onPress={async () => {
111 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 230
           <List.Item
115 231
             title='Mes:'
116 232
             description={item.Month}
@@ -148,6 +264,7 @@ export function Cita({route, navigation}) {
148 264
       />
149 265
         </ImageBackground>
150 266
     );
267
+    }
151 268
   }
152 269
 
153 270
 
@@ -158,3 +275,4 @@ const mapDispatchProps = (dispatch) => bindActionCreators({fetchUser}, dispatch)
158 275
 
159 276
 export default connect(mapStateToProps, mapDispatchProps)(Cita);
160 277
 
278
+

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

@@ -154,7 +154,7 @@ export function Confirm({navigation}) {
154 154
         />
155 155
        <Button
156 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 159
       <FlatList style={{
160 160
              flex: 1,

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

@@ -31,6 +31,8 @@ export function Home_page({navigation}) {
31 31
   const [appointments, setAppointments] = useState([]); 
32 32
 
33 33
   const[interpreter, setState] = useState();
34
+  const [Iuser, setIUser] = useState({})
35
+  const [Uuser, setUser] = useState({})
34 36
 
35 37
   const [expoPushToken, setExpoPushToken] = useState('');
36 38
   const [notification, setNotification] = useState(false);
@@ -54,6 +56,47 @@ export function Home_page({navigation}) {
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 100
     const fire = firebase.firestore()
58 101
     .collection('THREADS')
59 102
     .where("members", "array-contains", firebase.auth().currentUser.uid)
@@ -77,6 +120,8 @@ export function Home_page({navigation}) {
77 120
       const appointments = snapShot.docs.map(docSnap => {
78 121
         return{
79 122
           _id:docSnap.id,
123
+          User:'',
124
+          Interpreter:'',
80 125
           new:'',
81 126
           Day:'',
82 127
           Month:'',
@@ -97,6 +142,8 @@ export function Home_page({navigation}) {
97 142
       Notifications.removeNotificationSubscription(responseListener.current);
98 143
       fire();
99 144
       cita();
145
+      Iuser_data();
146
+      user_data();
100 147
     }
101 148
   }, []);
102 149
   
@@ -109,9 +156,7 @@ export function Home_page({navigation}) {
109 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 161
     firebase.firestore()
117 162
     .collection("Interprete")
@@ -141,9 +186,13 @@ export function Home_page({navigation}) {
141 186
       })
142 187
   }
143 188
   
189
+
144 190
   check_user_type_INT();
145 191
   console.log("interpreter", interpreter);
192
+
193
+  
146 194
   if(interpreter == false){
195
+    const user_name = Uuser[0].username;
147 196
     return (
148 197
       <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
149 198
       <FlatList style={{
@@ -160,6 +209,14 @@ export function Home_page({navigation}) {
160 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 220
            <List.Item
164 221
             title='Mes:'
165 222
             description={item.Month}
@@ -210,7 +267,7 @@ export function Home_page({navigation}) {
210 267
             />
211 268
         <Button
212 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 272
         <Button
216 273
           title ='Logout'
@@ -220,6 +277,8 @@ export function Home_page({navigation}) {
220 277
       );
221 278
     }
222 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 282
       return (
224 283
         <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
225 284
         <FlatList style={{
@@ -232,11 +291,19 @@ export function Home_page({navigation}) {
232 291
           renderItem = {({item}) => (
233 292
           <TouchableOpacity
234 293
           onPress={async () => {
235
-            console.log("item._id, home, interpreter", item._id)
294
+            console.log("item._id, home, interpreter", item)
236 295
             navigation.navigate('Cita',{tag: item, Pin: item})
237 296
           }}
238 297
           >
239 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 307
             title='Mes:'
241 308
             description={item.Month}
242 309
             titleNumberOfLines={1}
@@ -359,4 +426,5 @@ const mapStateToProps = (store) => ({
359 426
 })
360 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,6 +2,7 @@ import * as React from 'react';
2 2
 import { useState } from 'react';
3 3
 import MapView, { Marker } from 'react-native-maps';
4 4
 import { Button, StyleSheet, Text, View, Dimensions, Pressable } from 'react-native';
5
+import { Confirm } from './Confirm';
5 6
 
6 7
 
7 8
 export default function Map({route, navigation} ) {
@@ -17,6 +18,9 @@ export default function Map({route, navigation} ) {
17 18
     mapflag = route.params.Flag, 
18 19
     i_token = route.params.I_Token,
19 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 24
     View_Only = route.params.View_Only
21 25
     } = route.params
22 26
     
@@ -28,15 +32,39 @@ export default function Map({route, navigation} ) {
28 32
   if(View_Only == true){
29 33
 
30 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 69
     return (
42 70
       <View style={styles.container}>
@@ -54,6 +82,7 @@ export default function Map({route, navigation} ) {
54 82
       </View>
55 83
     );
56 84
   }
85
+}
57 86
   else{
58 87
 
59 88
     const [pin1, setPin1] = React.useState({
@@ -82,7 +111,9 @@ export default function Map({route, navigation} ) {
82 111
           <Marker coordinate={pin1} />
83 112
         </MapView>
84 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 117
           </View>
87 118
       </View>
88 119
       

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

@@ -84,6 +84,7 @@ const Days = [
84 84
 function Search({route, navigation }) {
85 85
 
86 86
   const u_token = route.params.U_Token;
87
+  const username = route.params.Username;
87 88
   console.log("U__token: ", u_token)
88 89
   
89 90
   const [users, setUsers] = useState([])
@@ -115,7 +116,7 @@ function Search({route, navigation }) {
115 116
       //check which tags where called in the search 
116 117
       if (tags[i].id === 'PL') {
117 118
         console.log('Presencial')
118
-        query = query.where('face_to_face', '==', true)
119
+        query = query.where('Modalidad.Presencial', '==', true)
119 120
         mapflag = true
120 121
       }
121 122
       if (tags[i].id == 'ON') {
@@ -250,9 +251,9 @@ function Search({route, navigation }) {
250 251
           return (
251 252
           <View>
252 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 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 257
             </View>
257 258
             <View style={{ borderBottomColor: 'black', borderBottomWidth: 1 }} />
258 259
           </View>
@@ -268,9 +269,9 @@ function Search({route, navigation }) {
268 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 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,6 +18,8 @@ export default class Time extends Component{
18 18
       mapflag: this.props.route.params.mapflag,
19 19
       i_token: this.props.route.params.I_Token,
20 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 23
       pin: this.props.route.params.Pin
22 24
     }
23 25
     console.log(" Time params: ",this.props.route.params)
@@ -125,6 +127,8 @@ export default class Time extends Component{
125 127
     console.log(this.state.u_token)
126 128
     const user = firebase.auth().currentUser;
127 129
     const uid = user.uid
130
+    const username = this.state.username;
131
+    const I_username = this.state.I_username;
128 132
     const u_token = this.state.u_token;
129 133
     const i_token = this.state.i_token;
130 134
     const date = this.state.Appointment
@@ -139,6 +143,8 @@ export default class Time extends Component{
139 143
     firebase.firestore()
140 144
     .collection('APPOINTMENTS')
141 145
     .add({ 
146
+      User: username,
147
+      Interpreter: I_username,
142 148
       participantes: [
143 149
       i_id,
144 150
       uid,