-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeleteRestaurants.js
85 lines (78 loc) · 2.21 KB
/
DeleteRestaurants.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
import React, { Component } from 'react';
import {View, StyleSheet, TextInput, Button, Alert} from 'react-native';
export default class UpdateRestaurant extends Component {
static navigationOptions = {
title: 'Delete Restaurants',
};
constructor(props){
super(props)
this.state = {
name: '',
}
}
makeDelete(){
fetch('http://10.0.2.2:2000/api/veggierestaurants/delete', {
method: 'DELETE',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: this.state.name,
}),
}).then(res => {
return res;
}).catch(err => err);
Alert.alert(
'Restaurant Deleted',
(this.state.name+' was successfully deleted from the database!'),
[
{text: 'OK'},
],
{cancelable: false},
);
}
render() {
return (
<View styles={styles.container}>
<TextInput
style={styles.box}
placeholder=" Enter the Name of the Restaurant to delete"
onChangeText={(name) => this.setState({name})}
value={this.state.name}
/>
<View style = {styles.button}>
<Button color="#228b22" variant="raised" title="Delete" onPress={() => this.makeDelete()}
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#ffffff",
},
box: {
height: 40,
width: '85%',
backgroundColor: '#ffffff',
alignSelf: 'center',
borderTopColor: '#ffffff',
borderBottomColor: '#39fe66',
borderLeftColor: '#ffffff',
borderRightColor: '#ffffff',
borderWidth: 2,
marginTop: 20,
marginBottom: 20,
},
button:{
paddingTop:15,
paddingBottom: 15,
width: '60%',
alignSelf: 'center'
}
});