|
@@ -25,10 +25,13 @@ Notifications.setNotificationHandler({
|
25
|
25
|
|
26
|
26
|
|
27
|
27
|
export function Home_page({navigation}) {
|
|
28
|
+
|
28
|
29
|
const [threads, setThreads] = useState([]);
|
29
|
30
|
const [loading, setLoading] = useState(true);
|
30
|
31
|
const [appointments, setAppointments] = useState([]);
|
31
|
32
|
|
|
33
|
+ const[interpreter, setState] = useState();
|
|
34
|
+
|
32
|
35
|
const [expoPushToken, setExpoPushToken] = useState('');
|
33
|
36
|
const [notification, setNotification] = useState(false);
|
34
|
37
|
const notificationListener = useRef();
|
|
@@ -42,7 +45,6 @@ export function Home_page({navigation}) {
|
42
|
45
|
|
43
|
46
|
responseListener.current = Notifications.addNotificationResponseReceivedListener(response => {
|
44
|
47
|
console.log(response);
|
45
|
|
- navigation.navigate('Confirm');
|
46
|
48
|
});
|
47
|
49
|
|
48
|
50
|
const fire = firebase.firestore()
|
|
@@ -106,73 +108,207 @@ export function Home_page({navigation}) {
|
106
|
108
|
})
|
107
|
109
|
}
|
108
|
110
|
|
|
111
|
+ function check_user_type_INT(){
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+ firebase.firestore()
|
|
116
|
+ .collection("Interprete")
|
|
117
|
+ .doc(firebase.auth().currentUser.uid)
|
|
118
|
+ .get()
|
|
119
|
+ .then((snapshot) => {
|
|
120
|
+ if(snapshot.exists){
|
|
121
|
+ setState(true);
|
|
122
|
+ }
|
|
123
|
+ else{
|
|
124
|
+ setState(false);
|
|
125
|
+ }
|
|
126
|
+ })
|
|
127
|
+
|
|
128
|
+ if(loading){
|
|
129
|
+ setLoading(false);
|
|
130
|
+ }
|
|
131
|
+
|
|
132
|
+ }
|
|
133
|
+
|
109
|
134
|
const dimensions = Dimensions.get('window');
|
110
|
135
|
const screenWidth = dimensions.width;
|
111
|
|
-
|
112
|
136
|
|
113
|
|
- return (
|
114
|
|
- <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
|
115
|
|
- <FlatList style={{
|
116
|
|
- flex: 1,
|
117
|
|
- width: screenWidth,
|
118
|
|
- }}
|
119
|
|
- data={appointments}
|
120
|
|
- keyExtractor = {item => item._id}
|
121
|
|
- ItemSeparatorComponent={() => <Divider />}
|
122
|
|
- renderItem = {({item}) => (
|
123
|
|
- <TouchableOpacity
|
124
|
|
- onPress={async () => {
|
125
|
|
- navigation.navigate('Cita')
|
|
137
|
+ check_user_type_INT();
|
|
138
|
+ console.log(interpreter);
|
|
139
|
+ if(interpreter == false){
|
|
140
|
+ return (
|
|
141
|
+ <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
|
|
142
|
+ <FlatList style={{
|
|
143
|
+ flex: 1,
|
|
144
|
+ width: screenWidth,
|
126
|
145
|
}}
|
127
|
|
- >
|
128
|
|
- <List.Item
|
129
|
|
- title={item.Month}
|
130
|
|
- titleNumberOfLines={1}
|
131
|
|
- titleStyle={styles.listTitle}
|
132
|
|
- descriptionStyle={styles.listDescription}
|
133
|
|
- descriptionNumberOfLines={1}
|
134
|
|
- />
|
135
|
|
- <List.Item
|
136
|
|
- title={item.Day}
|
137
|
|
- titleNumberOfLines={1}
|
138
|
|
- titleStyle={styles.listTitle}
|
139
|
|
- descriptionStyle={styles.listDescription}
|
140
|
|
- descriptionNumberOfLines={1}
|
|
146
|
+ data={threads}
|
|
147
|
+ keyExtractor = {item => item._id}
|
|
148
|
+ ItemSeparatorComponent={() => <Divider />}
|
|
149
|
+ renderItem = {({item}) => (
|
|
150
|
+ <TouchableOpacity
|
|
151
|
+ onPress={() => navigation.navigate('Room', {thread: item})}
|
|
152
|
+ >
|
|
153
|
+ <List.Item
|
|
154
|
+ title={item.name}
|
|
155
|
+ titleNumberOfLines={1}
|
|
156
|
+ titleStyle={styles.listTitle}
|
|
157
|
+ descriptionStyle={styles.listDescription}
|
|
158
|
+ descriptionNumberOfLines={1}
|
|
159
|
+ />
|
|
160
|
+ </TouchableOpacity>
|
|
161
|
+ )}
|
|
162
|
+ />
|
|
163
|
+ <FlatList style={{
|
|
164
|
+ flex: 1,
|
|
165
|
+ width: screenWidth,
|
|
166
|
+ }}
|
|
167
|
+ data={appointments}
|
|
168
|
+ keyExtractor = {item => item._id}
|
|
169
|
+ ItemSeparatorComponent={() => <Divider />}
|
|
170
|
+ renderItem = {({item}) => (
|
|
171
|
+ <TouchableOpacity
|
|
172
|
+ onPress={async () => {
|
|
173
|
+ await sendPushNotification(expoPushToken);
|
|
174
|
+ }}
|
|
175
|
+ >
|
|
176
|
+ <List.Item
|
|
177
|
+ title={item.Month}
|
|
178
|
+ titleNumberOfLines={1}
|
|
179
|
+ titleStyle={styles.listTitle}
|
|
180
|
+ descriptionStyle={styles.listDescription}
|
|
181
|
+ descriptionNumberOfLines={1}
|
|
182
|
+ />
|
|
183
|
+ <List.Item
|
|
184
|
+ title={item.Day}
|
|
185
|
+ titleNumberOfLines={1}
|
|
186
|
+ titleStyle={styles.listTitle}
|
|
187
|
+ descriptionStyle={styles.listDescription}
|
|
188
|
+ descriptionNumberOfLines={1}
|
|
189
|
+ />
|
|
190
|
+ <List.Item
|
|
191
|
+ title={item.Time}
|
|
192
|
+ titleNumberOfLines={1}
|
|
193
|
+ titleStyle={styles.listTitle}
|
|
194
|
+ descriptionStyle={styles.listDescription}
|
|
195
|
+ descriptionNumberOfLines={1}
|
|
196
|
+ />
|
|
197
|
+ </TouchableOpacity>
|
|
198
|
+ )}
|
|
199
|
+ />
|
|
200
|
+ <Button
|
|
201
|
+ title ='Send notification'
|
|
202
|
+ onPress={async () => {
|
|
203
|
+ await sendPushNotification(expoPushToken);
|
|
204
|
+ }}
|
|
205
|
+ />
|
|
206
|
+ <Button
|
|
207
|
+ title='CrearChat'
|
|
208
|
+ onPress={() => handleButtonPress()}
|
|
209
|
+ />
|
|
210
|
+ <Button
|
|
211
|
+ title ='Search for Interpreters'
|
|
212
|
+ onPress= {() => navigation.navigate('Search')}
|
|
213
|
+ />
|
|
214
|
+ <Button
|
|
215
|
+ title ='Logout'
|
|
216
|
+ onPress= {() => firebase.auth().signOut()}
|
|
217
|
+ />
|
|
218
|
+ </ImageBackground>
|
|
219
|
+ );
|
|
220
|
+ }
|
|
221
|
+ else{
|
|
222
|
+ return (
|
|
223
|
+ <ImageBackground style={styles.stdcontainer} source={require('../../assets/yellow-white.jpg')}>
|
|
224
|
+ <FlatList style={{
|
|
225
|
+ flex: 1,
|
|
226
|
+ width: screenWidth,
|
|
227
|
+ }}
|
|
228
|
+ data={threads}
|
|
229
|
+ keyExtractor = {item => item._id}
|
|
230
|
+ ItemSeparatorComponent={() => <Divider />}
|
|
231
|
+ renderItem = {({item}) => (
|
|
232
|
+ <TouchableOpacity
|
|
233
|
+ onPress={() => navigation.navigate('Room', {thread: item})}
|
|
234
|
+ >
|
|
235
|
+ <List.Item
|
|
236
|
+ title={item.name}
|
|
237
|
+ titleNumberOfLines={1}
|
|
238
|
+ titleStyle={styles.listTitle}
|
|
239
|
+ descriptionStyle={styles.listDescription}
|
|
240
|
+ descriptionNumberOfLines={1}
|
|
241
|
+ />
|
|
242
|
+ </TouchableOpacity>
|
|
243
|
+ )}
|
141
|
244
|
/>
|
142
|
|
- <List.Item
|
143
|
|
- title={item.Time}
|
144
|
|
- titleNumberOfLines={1}
|
145
|
|
- titleStyle={styles.listTitle}
|
146
|
|
- descriptionStyle={styles.listDescription}
|
147
|
|
- descriptionNumberOfLines={1}
|
|
245
|
+ <FlatList style={{
|
|
246
|
+ flex: 1,
|
|
247
|
+ width: screenWidth,
|
|
248
|
+ }}
|
|
249
|
+ data={appointments}
|
|
250
|
+ keyExtractor = {item => item._id}
|
|
251
|
+ ItemSeparatorComponent={() => <Divider />}
|
|
252
|
+ renderItem = {({item}) => (
|
|
253
|
+ <TouchableOpacity
|
|
254
|
+ onPress={async () => {
|
|
255
|
+ await sendPushNotification(expoPushToken);
|
|
256
|
+ }}
|
|
257
|
+ >
|
|
258
|
+ <List.Item
|
|
259
|
+ title={item.Month}
|
|
260
|
+ titleNumberOfLines={1}
|
|
261
|
+ titleStyle={styles.listTitle}
|
|
262
|
+ descriptionStyle={styles.listDescription}
|
|
263
|
+ descriptionNumberOfLines={1}
|
|
264
|
+ />
|
|
265
|
+ <List.Item
|
|
266
|
+ title={item.Day}
|
|
267
|
+ titleNumberOfLines={1}
|
|
268
|
+ titleStyle={styles.listTitle}
|
|
269
|
+ descriptionStyle={styles.listDescription}
|
|
270
|
+ descriptionNumberOfLines={1}
|
|
271
|
+ />
|
|
272
|
+ <List.Item
|
|
273
|
+ title={item.Time}
|
|
274
|
+ titleNumberOfLines={1}
|
|
275
|
+ titleStyle={styles.listTitle}
|
|
276
|
+ descriptionStyle={styles.listDescription}
|
|
277
|
+ descriptionNumberOfLines={1}
|
|
278
|
+ />
|
|
279
|
+ </TouchableOpacity>
|
|
280
|
+ )}
|
148
|
281
|
/>
|
149
|
|
- </TouchableOpacity>
|
150
|
|
- )}
|
|
282
|
+ <Button
|
|
283
|
+ title ='Send notification'
|
|
284
|
+ onPress={async () => {
|
|
285
|
+ await sendPushNotification(expoPushToken);
|
|
286
|
+ }}
|
|
287
|
+ />
|
|
288
|
+
|
|
289
|
+ <Button
|
|
290
|
+ title='CrearChat'
|
|
291
|
+ onPress={() => handleButtonPress()}
|
|
292
|
+ />
|
|
293
|
+ <Button
|
|
294
|
+ title ='Availability'
|
|
295
|
+ onPress= {() => navigation.navigate('Availability')}
|
151
|
296
|
/>
|
152
|
|
- <Button
|
153
|
|
- title ='Send notification'
|
154
|
|
- onPress={async () => {
|
155
|
|
- await sendPushNotification(expoPushToken);
|
156
|
|
- }}
|
157
|
|
- />
|
158
|
|
- <Button
|
159
|
|
- title ='Hacer Busqueda'
|
160
|
|
- onPress= {() => navigation.navigate('Search')}
|
161
|
|
- />
|
162
|
|
- <Button
|
163
|
|
- title ='Logout'
|
164
|
|
- onPress= {() => firebase.auth().signOut()}
|
165
|
|
- />
|
166
|
|
- </ImageBackground>
|
167
|
|
- );
|
|
297
|
+ <Button
|
|
298
|
+ title ='Logout'
|
|
299
|
+ onPress= {() => firebase.auth().signOut()}
|
|
300
|
+ />
|
|
301
|
+ </ImageBackground>
|
|
302
|
+ );
|
|
303
|
+ }
|
168
|
304
|
}
|
169
|
305
|
// Can use this function below, OR use Expo's Push Notification Tool-> https://expo.dev/notifications
|
170
|
306
|
async function sendPushNotification(expoPushToken) {
|
171
|
307
|
const message = {
|
172
|
308
|
to: expoPushToken,
|
173
|
309
|
sound: 'default',
|
174
|
|
- title: 'Freehand',
|
175
|
|
- body: 'Le solicitan una cita',
|
|
310
|
+ title: 'Original Title',
|
|
311
|
+ body: 'And here is the body!',
|
176
|
312
|
data: { someData: 'goes here' },
|
177
|
313
|
};
|
178
|
314
|
|
|
@@ -201,6 +337,7 @@ async function registerForPushNotificationsAsync() {
|
201
|
337
|
return;
|
202
|
338
|
}
|
203
|
339
|
token = (await Notifications.getExpoPushTokenAsync()).data;
|
|
340
|
+ console.log('Token:')
|
204
|
341
|
console.log(token);
|
205
|
342
|
} else {
|
206
|
343
|
alert('Must use physical device for Push Notifications');
|