ErnestoOrtiz2 3 år sedan
förälder
incheckning
301a5643df
3 ändrade filer med 65 tillägg och 42 borttagningar
  1. 29
    4
      screens/main/Cita.js
  2. 5
    26
      screens/main/Confirm.js
  3. 31
    12
      screens/main/Home_page.js

+ 29
- 4
screens/main/Cita.js Visa fil

@@ -12,14 +12,39 @@ import { connect } from 'react-redux'
12 12
 import { bindActionCreators } from 'redux' 
13 13
 import { fetchUser } from '../../redux/actions/index'
14 14
 
15
-import Constants from 'expo-constants';
16
-import * as Notifications from 'expo-notifications';
17 15
 
16
+export function Cita({navigation, route}) {
17
+   /*const [threads, setThreads] = useState([]);  
18
+    const [loading, setLoading] = useState(true);
19
+  useEffect(() => { 
20
+    const fire = firebase.firestore()
21
+    .collection('THREADS')
22
+    .where("cita", "==", route.params.appointment_id)
23
+    .onSnapshot(querySnapshot => {
24
+      const threads = querySnapshot.docs.map(documentSnapshot => {
25
+        return{
26
+          _id:documentSnapshot.id,
27
+          name:'',
28
+          ...documentSnapshot.data()
29
+        };
30
+      });
18 31
 
32
+      setThreads(threads);
33
+      console.log(threads);
19 34
 
20
-export function Cita({navigation}) {
21
-   
35
+      if(loading){
36
+        setLoading(false);
37
+      }
38
+    });
22 39
 
40
+    return () => {
41
+      fire();
42
+    }
43
+  }, []);*/
44
+    
45
+    
46
+    
47
+  
23 48
   
24 49
 
25 50
   const dimensions = Dimensions.get('window');

+ 5
- 26
screens/main/Confirm.js Visa fil

@@ -45,26 +45,6 @@ export function Confirm({navigation}) {
45 45
       navigation.navigate('Search');
46 46
     });
47 47
 
48
-    const fire = firebase.firestore()
49
-    .collection('THREADS')
50
-    .where("members", "array-contains", firebase.auth().currentUser.uid)
51
-    .onSnapshot(querySnapshot => {
52
-      const threads = querySnapshot.docs.map(documentSnapshot => {
53
-        return{
54
-          _id:documentSnapshot.id,
55
-          name:'',
56
-          ...documentSnapshot.data()
57
-        };
58
-      });
59
-
60
-      setThreads(threads);
61
-      console.log(threads);
62
-
63
-      if(loading){
64
-        setLoading(false);
65
-      }
66
-    });
67
-
68 48
     const cita = firebase.firestore().collection('APPOINTMENTS').where("new", "==", 'true').onSnapshot(snapShot => {
69 49
       const appointments = snapShot.docs.map(docSnap => {
70 50
         return{
@@ -81,20 +61,19 @@ export function Confirm({navigation}) {
81 61
       });
82 62
       setAppointments(appointments);
83 63
       console.log("appointment", appointments);
84
-      //console.log(appointments.Day);
85 64
     });
86 65
       
87 66
     return () => {
88 67
       Notifications.removeNotificationSubscription(notificationListener.current);
89 68
       Notifications.removeNotificationSubscription(responseListener.current);
90
-      fire();
69
+      //fire();
91 70
       cita();
92 71
     }
93 72
   }, []);
94 73
   
95
-  if (loading) {
74
+ /* if (loading) {
96 75
     return <Loading />;
97
-  }
76
+  }*/
98 77
 
99 78
 
100 79
   function crearChat(cliente, citaID) {
@@ -142,8 +121,8 @@ export function Confirm({navigation}) {
142 121
           ItemSeparatorComponent={() => <Divider />}
143 122
           renderItem = {({item}) => (
144 123
           <TouchableOpacity
145
-          onPress={async () => {
146
-            await sendPushNotification(expoPushToken); //item.push_token
124
+          onPress={() => {
125
+            console.log("date");
147 126
           }}
148 127
           >
149 128
             <List.Item

+ 31
- 12
screens/main/Home_page.js Visa fil

@@ -170,6 +170,26 @@ export function Home_page({navigation}) {
170 170
         </TouchableOpacity>
171 171
       )}
172 172
           />
173
+          <FlatList style={{
174
+             flex: 1,
175
+             width: screenWidth,
176
+         }}
177
+          data={appointments}
178
+          keyExtractor = {item => item._id}
179
+          ItemSeparatorComponent={() => <Divider />}
180
+          renderItem={({ item }) => {
181
+            if(item.new){
182
+            return (
183
+              <Button
184
+              title ='Pedir Cita'
185
+              onPress={ async () => {
186
+                await sendPushNotification(item.i_token);
187
+                }
188
+              }
189
+            /> 
190
+            )
191
+          }}}
192
+            />
173 193
         <Button
174 194
           title ='Hacer Busqueda'
175 195
           onPress= {() => navigation.navigate('Search')}
@@ -226,22 +246,21 @@ export function Home_page({navigation}) {
226 246
             <FlatList style={{
227 247
              flex: 1,
228 248
              width: screenWidth,
229
-         }}
230
-          data={appointments}
231
-          keyExtractor = {item => item._id}
232
-          ItemSeparatorComponent={() => <Divider />}
233
-          renderItem={({ item }) => {
234
-            if(item.new){
249
+            }}
250
+            data={appointments}
251
+            keyExtractor = {item => item._id}
252
+            renderItem={({ item }) => {
253
+            if(item.new == true){
235 254
             return (
236 255
               <Button
237
-              title ='Pedir Cita'
238
-              onPress={ async () => {
239
-                await sendPushNotification(item.i_token);
256
+                title ='Pedir Cita'
257
+                onPress={ async () => {
258
+                  await sendPushNotification(item.i_token);
259
+                  }
240 260
                 }
241
-              }
242
-            /> 
261
+              /> 
243 262
             )
244
-          }}}
263
+            }}}
245 264
             />
246 265
 
247 266