add future event only

This commit is contained in:
Valentin CZERYBA 2024-12-04 23:01:06 +01:00
parent eef7e44999
commit 76f1de27ec

View File

@ -137,7 +137,6 @@ class _UpdateeventImageState extends State<UpdateeventImage>
} }
Future<void> _updateEvent(BuildContext context) async { Future<void> _updateEvent(BuildContext context) async {
var url = Uri.parse("${globals.api}/token");
var name = inputName.text; var name = inputName.text;
var place = inputGeo.text; var place = inputGeo.text;
var description = inputDesc.text; var description = inputDesc.text;
@ -146,12 +145,13 @@ class _UpdateeventImageState extends State<UpdateeventImage>
List<String>.from(_stringOrgaController.getTags as List); List<String>.from(_stringOrgaController.getTags as List);
var startDateFormat = formatDate(startDatepicker.text); var startDateFormat = formatDate(startDatepicker.text);
DateTime startDateCompare = DateTime.parse(startDateFormat);
DateTime dateNow = DateTime.now();
var endDateFormat = formatDate(endDatepicker.text); var endDateFormat = formatDate(endDatepicker.text);
var startDate = var startDate =
"${startDateFormat}T${startTimepicker.text.replaceAll('-', ':')}"; "${startDateFormat}T${startTimepicker.text.replaceAll('-', ':')}";
var endDate = "${endDateFormat}T${endTimepicker.text.replaceAll('-', ':')}"; var endDate = "${endDateFormat}T${endTimepicker.text.replaceAll('-', ':')}";
print("start date : ${startDate}"); if (startDateCompare.isAfter(dateNow)) {
print("end date : ${endDate}");
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
var accessToken = prefs.getString("access_token") ?? ""; var accessToken = prefs.getString("access_token") ?? "";
@ -172,7 +172,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
if (data['features'].isNotEmpty) { if (data['features'].isNotEmpty) {
place = data['features'][0]['place_name']; place = data['features'][0]['place_name'];
final coordinates = data['features'][0]['geometry']['coordinates']; final coordinates =
data['features'][0]['geometry']['coordinates'];
final longitude = coordinates[0]; // Longitude final longitude = coordinates[0]; // Longitude
final latitude = coordinates[1]; // Latitude final latitude = coordinates[1]; // Latitude
@ -282,6 +283,9 @@ class _UpdateeventImageState extends State<UpdateeventImage>
} else { } else {
showErrorDialog(context, "Champ vide"); showErrorDialog(context, "Champ vide");
} }
} else {
showErrorDialog(context, "Evenement non futur");
}
} }
void start() async { void start() async {