Merge pull request 'feature/fix-search' (#27) from feature/fix-search into main
Reviewed-on: #27
This commit is contained in:
commit
1cc14277e8
@ -94,10 +94,12 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
|||||||
var name = jsonData["name"];
|
var name = jsonData["name"];
|
||||||
print("name : ${name}");
|
print("name : ${name}");
|
||||||
var place = jsonData["place"];
|
var place = jsonData["place"];
|
||||||
|
var date = jsonData["start_date"];
|
||||||
var accessToken = prefs.getString("access_token") ?? "";
|
var accessToken = prefs.getString("access_token") ?? "";
|
||||||
|
|
||||||
if (accessToken.isNotEmpty) {
|
if (accessToken.isNotEmpty) {
|
||||||
var urlGet = Uri.parse("${globals.api}/events?name=${name}");
|
var urlGet = Uri.parse(
|
||||||
|
"${globals.api}/events/search?item=${name}&date_event=${date}");
|
||||||
|
|
||||||
var responseGet = await http.get(urlGet,
|
var responseGet = await http.get(urlGet,
|
||||||
headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
|
headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'});
|
||||||
@ -116,6 +118,9 @@ class DisplayPictureScreenState extends State<DisplayPictureScreen>
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => ItemMenu(title: events[0]["id"])));
|
builder: (_) => ItemMenu(title: events[0]["id"])));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
showErrorDialog(context,
|
||||||
|
"response status code update : ${responseGet.statusCode}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showErrorDialog(context, "Erreur de token");
|
showErrorDialog(context, "Erreur de token");
|
||||||
|
@ -9,6 +9,7 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'ItemMenu.dart';
|
||||||
import '../classes/alert.dart';
|
import '../classes/alert.dart';
|
||||||
import '../classes/eventAdded.dart';
|
import '../classes/eventAdded.dart';
|
||||||
|
|
||||||
@ -137,7 +138,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 +146,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,9 +173,46 @@ 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
|
||||||
|
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 = {
|
final params = {
|
||||||
'expiration': '15552000',
|
'expiration': '15552000',
|
||||||
@ -282,6 +320,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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user