check existing event before add
This commit is contained in:
parent
76f1de27ec
commit
cf100651eb
@ -9,6 +9,7 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'ItemMenu.dart';
|
||||
import '../classes/alert.dart';
|
||||
import '../classes/eventAdded.dart';
|
||||
|
||||
@ -176,6 +177,42 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
data['features'][0]['geometry']['coordinates'];
|
||||
final longitude = coordinates[0]; // Longitude
|
||||
final latitude = coordinates[1]; // Latitude
|
||||
var urlGet = Uri.parse(
|
||||
"${globals.api}/events/search?item=${name}&date_event=${startDate}");
|
||||
|
||||
var responseGet = await http.get(urlGet, headers: {
|
||||
HttpHeaders.cookieHeader: 'access_token=${accessToken}'
|
||||
});
|
||||
if (responseGet.statusCode == 200) {
|
||||
var events = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
||||
print("reponse http : ${events.length}");
|
||||
if (events.length == 0) {
|
||||
urlGet = Uri.parse(
|
||||
"${globals.api}/events/search?min_lat=$latitude&max_lat=$latitude"
|
||||
"&min_lon=$longitude&max_lon=$longitude&date_event=${startDate}");
|
||||
responseGet = await http.get(urlGet, headers: {
|
||||
HttpHeaders.cookieHeader: 'access_token=${accessToken}'
|
||||
});
|
||||
if (responseGet.statusCode == 200) {
|
||||
events = jsonDecode(utf8.decode(responseGet.bodyBytes));
|
||||
print("reponse http : ${events.length}");
|
||||
if (events.length != 0) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
ItemMenu(title: events[0]["id"])));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => ItemMenu(title: events[0]["id"])));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final params = {
|
||||
'expiration': '15552000',
|
||||
|
Loading…
x
Reference in New Issue
Block a user