diff --git a/covas_mobile/lib/classes/descriptionImage.dart b/covas_mobile/lib/classes/descriptionImage.dart index ccad849..cbce573 100644 --- a/covas_mobile/lib/classes/descriptionImage.dart +++ b/covas_mobile/lib/classes/descriptionImage.dart @@ -3,6 +3,7 @@ import 'events.dart'; import '../variable/globals.dart' as globals; import 'package:http/http.dart' as http; import 'dart:io'; +import 'dart:convert'; import 'package:shared_preferences/shared_preferences.dart'; @@ -10,10 +11,24 @@ mixin ShowDescImageAdd on State { Future addEvents(var events) async { SharedPreferences prefs = await SharedPreferences.getInstance(); var accessToken = prefs.getString("access_token") ?? ""; + List send = ["toto"]; + if (accessToken.isNotEmpty) { - var urlGet = Uri.parse("${globals.api}/events"); - var responseGet = await http.get(urlGet, - headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'}); + var urlPut = Uri.parse("${globals.api}/events"); + var responsePut = await http.put(urlPut, + headers: {HttpHeaders.cookieHeader: 'access_token=${accessToken}'}, + body: jsonEncode({ + 'name': events["name"], + 'place': events["place"], + 'start_date': events['start_date'], + 'end_date': events['start_date'], + 'organizers': send, + 'latitude': '0.0', + 'longitude': '0.0', + })); + + print("http put code status : ${responsePut.statusCode}"); + print("http put body : ${responsePut.body}"); } }