fix date and orga

This commit is contained in:
Valentin CZERYBA 2024-07-06 00:10:12 +02:00
parent 4de6603b91
commit 34c2b5d322

View File

@ -65,6 +65,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
String listUser = ""; String listUser = "";
String eventName = ""; String eventName = "";
String eventStartDate = ""; String eventStartDate = "";
String organizers = "";
Events? events; Events? events;
@override @override
@ -79,7 +80,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
var accessToken = prefs.getString("access_token") ?? ""; var accessToken = prefs.getString("access_token") ?? "";
String formerName = ""; String formerName = "";
String formerDate = ""; String formerDate = "";
print("${accessToken}"); String formerOrga = "";
if (accessToken.isNotEmpty) { if (accessToken.isNotEmpty) {
var urlGet = Uri.parse("${globals.api}/events/${widget.title}"); var urlGet = Uri.parse("${globals.api}/events/${widget.title}");
@ -94,7 +95,18 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
final startDate = DateTime.parse(events["start_date"]); final startDate = DateTime.parse(events["start_date"]);
final date = DateFormat.yMd().format(startDate); final date = DateFormat.yMd().format(startDate);
final time = DateFormat.Hm().format(startDate); final time = DateFormat.Hm().format(startDate);
formerDate = "${date} - ${time}";
final endDate = DateTime.parse(events["end_date"]);
final dateE = DateFormat.yMd().format(endDate);
final timeE = DateFormat.Hm().format(endDate);
formerDate = "${date} ${time} à ${dateE} ${timeE}";
if (events["organizers"].length > 1) {
for (var orga in events["organizers"]) {
formerOrga = "${formerOrga}, ${orga}";
}
} else {
formerOrga = "${events['organizers'][0]}";
}
} else { } else {
var text = ""; var text = "";
switch (responseGet.statusCode) { switch (responseGet.statusCode) {
@ -148,6 +160,7 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
// called again, and so nothing would appear to happen. // called again, and so nothing would appear to happen.
eventName = formerName; eventName = formerName;
eventStartDate = formerDate; eventStartDate = formerDate;
organizers = formerOrga;
}); });
} }
@ -188,7 +201,8 @@ class _ItemMenuState extends State<ItemMenu> with ShowErrorDialog {
), ),
Row(children: [ Row(children: [
Icon(Icons.group), Icon(Icons.group),
Text("Organisateurs : ", style: TextStyle(fontSize: 15.0)) Text("Organisateurs : ${organizers}",
style: TextStyle(fontSize: 15.0))
]), ]),
Row(children: [ Row(children: [
Icon(Icons.description), Icon(Icons.description),