-
Notifications
You must be signed in to change notification settings - Fork 0
/
addDataScreen.js
106 lines (85 loc) · 2.04 KB
/
addDataScreen.js
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
94
95
96
97
98
99
100
101
102
103
104
105
106
import React from "react";
import { View, Text, StyleSheet, TextInput } from 'react-native';
import { Button } from "react-native-elements";
import { useAddDataMutation } from "./apiSlice";
export default function AddDataScreen({ navigation }) {
const [channel, setChannel] = React.useState('');
const [event, setEvent] = React.useState('');
const [message, setMessage] = React.useState('');
const [addData] = useAddDataMutation();
const handleAddData = () => {
const data = {
meli: {
channel: channel,
event: event,
send_message: message,
},
}
addData(data)
navigation.navigate('Home');
}
return (
<View>
<Text style={styles.heading}>Add Data</Text>
<TextInput
style={styles.input}
placeholder="Enter Channel"
value={channel}
onChangeText={setChannel}
/>
<TextInput
style={styles.input}
placeholder="Enter Event"
value={event}
onChangeText={setEvent}
/>
<TextInput
style={styles.input}
placeholder="Enter Message"
value={message}
onChangeText={setMessage}
/>
<Button title="Add" onPress={handleAddData}
buttonStyle={{
borderColor: 'rgb(247, 167, 38)',
}}
type="outline"
raised
titleStyle={{ color: 'rgb(247, 167, 38)', textAlign: 'center' }}
containerStyle={{
width: 200,
marginHorizontal: 85,
marginVertical: 10,
}}
/>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
paddingTop: 50,
paddingHorizontal: 20,
},
heading: {
fontSize: 24,
fontWeight: 'bold',
},
input: {
borderWidth: 1,
borderColor: '#ccc',
padding: 10,
borderRadius: 5,
marginBottom: 10,
width: '100%',
},
heading: {
color: 'orange',
fontSize: 22,
fontWeight: 'bold',
alignSelf: 'center',
},
});