From a2cc6baa802aff3607de812859cc9628012741e0 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Tue, 3 Sep 2024 15:54:37 +0200 Subject: [PATCH] more detail for a event --- covas_mobile/lib/pages/UpdateEventImage.dart | 31 ++++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index 38b1248..d770ab3 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -86,10 +86,31 @@ class _UpdateeventImageState extends State } } + String formatDate(String date) { + var splitedDate = date.split("-"); + var day = splitedDate[0]; + var month = splitedDate[1]; + var year = splitedDate[2]; + + return "${year}-${month}-${day}"; + } + Future _updateEvent(BuildContext context) async { var url = Uri.parse("${globals.api}/token"); var name = inputName.text; - var place = inputCity.text; + var place = inputAddress.text; + var city = inputCity.text; + var country = inputCountry.text; + var zipCode = inputZipCode.text; + var description = inputDesc.text; + + var startDateFormat = formatDate(startDatepicker.text); + var endDateFormat = formatDate(endDatepicker.text); + var startDate = + "${startDateFormat}T${startTimepicker.text.replaceAll('-', ':')}"; + var endDate = "${endDateFormat}T${endTimepicker.text.replaceAll('-', ':')}"; + print("start date : ${startDate}"); + print("end date : ${endDate}"); SharedPreferences prefs = await SharedPreferences.getInstance(); var accessToken = prefs.getString("access_token") ?? ""; List send = ["toto"]; @@ -108,11 +129,15 @@ class _UpdateeventImageState extends State body: jsonEncode({ 'name': name, 'place': place, - 'start_date': widget.events["start_date"], - 'end_date': widget.events['end_date'], + 'start_date': startDate, + 'end_date': endDate, + 'zip_code': zipCode, + 'country': country, + 'city': city, 'organizers': send, 'latitude': '0.0', 'longitude': '0.0', + 'description': description })); print(responsePut.statusCode); if ((responsePut.statusCode == 200) ||