Commit 2ab7e9e2 authored by Tohap Maruli Pasaribu's avatar Tohap Maruli Pasaribu
parents 0fdc896b 24c4d453
......@@ -30,3 +30,17 @@ Future<bool> savecontact(nama, email, nohp, message) async {
// return response.statusCode;
}
Future<bool> deleteContact(id) async {
final response = await http.delete(
Uri.parse('$cmd/contact/delete/$id'),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
return true;
} else {
return false;
}
}
......@@ -91,12 +91,11 @@ class _Dashboard4State extends State<Dashboard4> {
decoration: const BoxDecoration(color: Colors.white),
columnSpacing: 105,
columns: const [
DataColumn(label: Text("ID")),
DataColumn(label: Text("Date")),
DataColumn(label: Text("Name")),
DataColumn(label: Text("Email")),
DataColumn(label: Text("Message")),
DataColumn(label: Text("Number")),
DataColumn(label: Text("Email")),
DataColumn(label: Text("Action")),
],
rows: List.generate(
snapshot.data.length,
......@@ -105,85 +104,191 @@ class _Dashboard4State extends State<Dashboard4> {
return DataRow(
cells: [
DataCell(
Text(pgm['idContact'].toString()),
Text(pgm['dateContact']),
),
DataCell(
Text(pgm['namaContact']),
),
DataCell(
Text(pgm['dateContact']),
Text(pgm['noHp']),
),
DataCell(
Text(pgm['emailContact']),
),
DataCell(
Text(pgm['messageContact']),
),
DataCell(
Text(pgm['noHp']),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextButton(
style: TextButton.styleFrom(
padding:
const EdgeInsets.all(16.0),
primary: Colors.white,
backgroundColor: Color.fromARGB(
255, 15, 102, 223),
textStyle:
const TextStyle(fontSize: 15),
),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
"Information",
style: GoogleFonts.poppins(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
content: Container(
height:
screenSize.height *
0.3,
width: screenSize.width *
0.33,
child: Column(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
crossAxisAlignment:
CrossAxisAlignment
.start,
children: [
Text(
"Date : ${pgm['dateContact']}"),
Text(
"Nama : ${pgm['namaContact']}"),
Text(
"No.Telp : ${pgm['noHp']}"),
Text(
"Email : ${pgm['emailContact']}"),
Text(
"Message : ${pgm['messageContact']}"),
],
),
),
actions: <Widget>[
TextButton(
style: TextButton
.styleFrom(
padding:
const EdgeInsets
.all(16.0),
primary: Colors.white,
backgroundColor:
Color.fromARGB(
255,
15,
102,
223),
textStyle:
const TextStyle(
fontSize: 15),
),
child:
const Text("Back"),
onPressed: () {
Navigator.pop(
context);
},
),
],
);
},
);
},
child: const Text("View"),
),
],
),
SizedBox(
width: 3,
),
Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextButton(
style: TextButton.styleFrom(
padding:
const EdgeInsets.all(16.0),
primary: Colors.white,
backgroundColor:
const Color.fromARGB(
255, 245, 27, 27),
textStyle:
const TextStyle(fontSize: 15),
),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title:
const Text("Warning"),
content: Text(
"Are you sure want to delete data user ${pgm['namaContact']}?"),
actions: <Widget>[
TextButton(
child:
const Text("Yes"),
onPressed: () {
Navigator.pop(
context);
deleteContact(pgm[
'idContact'])
.then(
(isSuccess) {
if (isSuccess) {
setState(() {});
Scaffold.of(this
.context)
.showSnackBar(
const SnackBar(
content:
Text("Delete data success")));
} else {
Scaffold.of(this
.context)
.showSnackBar(
const SnackBar(
content:
Text("Delete data failed")));
}
});
},
),
TextButton(
child: const Text("No"),
onPressed: () {
Navigator.pop(
context);
},
),
],
);
},
);
},
child: const Text("Delete"),
),
],
),
],
),
),
// DataCell(
// Row(
// children: [
// TextButton(
// style: TextButton.styleFrom(
// padding: const EdgeInsets.all(16.0),
// primary: Colors.white,
// backgroundColor: const Color.fromARGB(
// 255, 245, 27, 27),
// textStyle:
// const TextStyle(fontSize: 15),
// ),
// onPressed: () {
// showDialog(
// context: context,
// builder: (context) {
// return AlertDialog(
// title: const Text("Warning"),
// content: Text(
// "Are you sure want to delete data page ${pgm['title']}?"),
// actions: <Widget>[
// TextButton(
// child: const Text("Yes"),
// onPressed: () {
// Navigator.pop(context);
// deletePage(pgm['idpage'])
// .then((isSuccess) {
// if (isSuccess) {
// setState(() {});
// Scaffold.of(
// this.context)
// .showSnackBar(
// const SnackBar(
// content: Text(
// "Delete data success")));
// } else {
// Scaffold.of(
// this.context)
// .showSnackBar(
// const SnackBar(
// content: Text(
// "Delete data failed")));
// }
// });
// },
// ),
// TextButton(
// child: const Text("No"),
// onPressed: () {
// Navigator.pop(context);
// },
// ),
// ],
// );
// },
// );
// },
// child: const Text("Delete"),
// ),
// ],
// ),
// ),
],
);
},
......@@ -194,7 +299,6 @@ class _Dashboard4State extends State<Dashboard4> {
],
),
),
],
),
),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment