-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathNewTicketDesc.tsx
93 lines (86 loc) · 1.93 KB
/
NewTicketDesc.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React, { useState } from 'react'
import { StyleSheet, Text, View, TextInput, TouchableOpacity} from 'react-native'
import { gql, useMutation } from '@apollo/client'
const ADD_TASK = gql`
mutation addTask(
$id: Int!
$typeid: Int
$description: String
) {
addTask(
senior: $id
typeid: $typeid
description: $description
) {
id
}
}
`
const NewTicketDesc = ({navigation, route}) => {
const [value, onChangeText] = React.useState('');
const [addTask, { data, error }] = useMutation(ADD_TASK);
const handleSubmit = async () => {
try {
const mutation = await addTask({
variables: {
id: 3,
typeid: route.params.typeid,
description: value
},
});
navigation.navigate('SeniorDash', {fetch: true});
} catch (e) {
console.log('error in addTask', e)
}
}
console.log('params', route.params)
return (
<View style={styles.container}>
<Text style={styles.text}>Please describe your request.</Text>
<TextInput
multiline
autoFocus={true}
style={styles.textBox}
onChangeText={text => onChangeText(text)}
value={value}
/>
<TouchableOpacity
style={styles.submit}
onPress={handleSubmit}
>
<Text style={styles.text}>Submit</Text>
</TouchableOpacity>
</View>
)
}
export default NewTicketDesc
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center'
},
text: {
fontSize: 27
},
textBox: {
height: '45%',
width: '82%',
fontSize: 30,
borderWidth: 1,
borderColor: 'black',
borderRadius: 10,
borderWidth: 5,
justifyContent: 'flex-start'
},
submit: {
width: '82%',
backgroundColor: 'lightgreen',
borderStyle: 'solid',
padding: 10,
borderRadius: 10,
borderWidth: 5,
borderColor: 'black',
display: 'flex',
alignItems: 'center',
},
})