File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -91,16 +91,18 @@ class APIConnection {
91
91
}
92
92
93
93
// Remove product from database
94
- Future <void > removeProduct ( String name ) async {
94
+ Future <void > removeCurrentProduct ( ) async {
95
95
final response = await http.delete (
96
- Uri .parse ('$baseUrl /products/$name ' ),
96
+ Uri .parse ('$baseUrl /products/$selectedCategory ' ),
97
97
headers: < String , String > {
98
98
'Content-Type' : 'application/json; charset=UTF-8' ,
99
99
},
100
100
);
101
-
102
101
if (response.statusCode != 200 ) {
103
102
throw Exception ('Failed to remove product' );
104
103
}
104
+
105
+ categories = fetchCategories ();
106
+ await categories;
105
107
}
106
108
}
Original file line number Diff line number Diff line change @@ -89,6 +89,23 @@ class _ProductSearchState extends State<ProductSearch> {
89
89
child: const Text ('Add Product' ),
90
90
),
91
91
),
92
+ Padding (
93
+ padding: const EdgeInsets .all (8.0 ),
94
+ child: ElevatedButton (
95
+ onPressed: () {
96
+ GetIt .I .get <APIConnection >().removeCurrentProduct ().then (
97
+ (value) {
98
+ ScaffoldMessenger .of (context).showSnackBar (
99
+ const SnackBar (
100
+ content: Text ('Removed current product' ),
101
+ ),
102
+ );
103
+ },
104
+ );
105
+ },
106
+ child: const Text ('Remove current Product' ),
107
+ ),
108
+ )
92
109
],
93
110
),
94
111
);
You can’t perform that action at this time.
0 commit comments