-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJuniorTickets.tsx
48 lines (40 loc) · 1.14 KB
/
JuniorTickets.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';
import {StyleSheet, Text, View, TouchableOpacity} from 'react-native';
import {gql, useQuery} from '@apollo/client';
import Ticket from './Ticket';
// TODO: get ID of whoever is logged in so that we can query the tasks assigned to specific id
const GET_TASK_FOR_HELPER = gql`
query Helper($id: Int!) {
helper(id: $id) {
tasks {
seniorname
description
type
}
}
}
`;
const JuniorTickets = ({authID}) => {
console.log('authID in junior ticketss', authID);
const {loading, error, data} = useQuery(GET_TASK_FOR_HELPER, {
// userID hardcoded to 34, we need to figure out why dynamic authID isn't working
variables: {id: 34},
});
if (error) return <Text>`Error! ${error.message}`</Text>;
console.log('data from query', data);
const tickets = data.helper.tasks.map(task => (
<Ticket task={task} key={task.id} />
));
return <View style={styles.container}>{tickets}</View>;
};
export default JuniorTickets;
const styles = StyleSheet.create({
container: {
width: '100%',
},
text: {
marginVertical: 10,
fontSize: 25,
alignSelf: 'center',
},
});