|
@@ -1,5 +1,5 @@
|
1
|
1
|
import React from 'react';
|
2
|
|
-import { StyleSheet, Text, View, TextInput, Button, Pressable } from 'react-native';
|
|
2
|
+import { StyleSheet, Text, View, TextInput, Alert, Pressable } from 'react-native';
|
3
|
3
|
import { sqlite_exec_parameterised } from '../../db/query';
|
4
|
4
|
import DateTimePicker from '@react-native-community/datetimepicker';
|
5
|
5
|
|
|
@@ -97,6 +97,34 @@ export default function DepenseForm(props){
|
97
|
97
|
}}>
|
98
|
98
|
<Text>{update_depense ? "Update" : "Add"}</Text>
|
99
|
99
|
</Pressable>
|
|
100
|
+ {
|
|
101
|
+ update_depense ?
|
|
102
|
+ <Pressable
|
|
103
|
+ style={ [depense_form_styles.button_add, depense_form_styles.button_delete]}
|
|
104
|
+ onPress={ () => {
|
|
105
|
+ console.log("delete");
|
|
106
|
+ Alert.alert(
|
|
107
|
+ "Delete ?",
|
|
108
|
+ "Ciao bye bye ?",
|
|
109
|
+ [
|
|
110
|
+ {text: "Oopsie", style: "cancel"},
|
|
111
|
+ {text: "Oui oui", style: "destructive", onPress: () => {
|
|
112
|
+ sqlite_exec_parameterised(
|
|
113
|
+ "DELETE FROM expense WHERE id = ?",
|
|
114
|
+ [props.depense.id],(res) =>
|
|
115
|
+ {
|
|
116
|
+ props.fetchDepenses();
|
|
117
|
+ }
|
|
118
|
+ )
|
|
119
|
+ }}
|
|
120
|
+ ])
|
|
121
|
+ }}
|
|
122
|
+ >
|
|
123
|
+ <Text>💣</Text>
|
|
124
|
+ </Pressable> :
|
|
125
|
+ <View/>
|
|
126
|
+ }
|
|
127
|
+
|
100
|
128
|
</View>
|
101
|
129
|
);
|
102
|
130
|
}
|
|
@@ -125,5 +153,11 @@ const depense_form_styles = StyleSheet.create({
|
125
|
153
|
button_add: {
|
126
|
154
|
borderWidth: 1,
|
127
|
155
|
padding: 10,
|
|
156
|
+ margin: 1,
|
128
|
157
|
},
|
|
158
|
+ button_delete: {
|
|
159
|
+ position: 'absolute',
|
|
160
|
+ right: 1,
|
|
161
|
+ borderColor: "#CC5555",
|
|
162
|
+ }
|
129
|
163
|
})
|