diff --git a/lib/dashboard.dart b/lib/dashboard.dart index 9ec836c..61bf476 100644 --- a/lib/dashboard.dart +++ b/lib/dashboard.dart @@ -41,14 +41,14 @@ class _DashboardState extends State { - /*Future uploadProfileApi(image) async { + Future uploadProfileApi(image) async { var payload = new Map(); payload["picture"] = image.toString(); var response1= await AppSettings.updateProfilePicture(payload); print(response1); - }*/ + } @override void initState() { @@ -100,7 +100,7 @@ class _DashboardState extends State { setState(() { AppSettings.updatedImage = imageTemp; }); - // uploadProfileApi(AppSettings.updatedImage); + uploadProfileApi(AppSettings.updatedImage); AppSettings.saveProfile(image.path); @@ -118,7 +118,7 @@ class _DashboardState extends State { AppSettings.updatedImage = imageTemp; }); - //uploadProfileApi(AppSettings.updatedImage); + uploadProfileApi(AppSettings.updatedImage); AppSettings.saveProfile(image.path); } on PlatformException catch (e) { diff --git a/lib/settings.dart b/lib/settings.dart index 6eecdcb..b800b03 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -102,6 +102,7 @@ class AppSettings { static String acceptBookingRequestsUrl = host + 'ordernow'; static String acceptRequestUrl = host +"friend-request/accept"; static String rejectRequestUrl = host +"friend-request/reject"; + static String profilePicUrl = host + 'supplier/profile-picture'; @@ -337,6 +338,25 @@ class AppSettings { } } + static Future updateProfilePicture(payload) async { + var uri = Uri.parse(profilePicUrl + '/' + supplierId); + var response = await http.post(uri, + body: json.encode(payload), headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + try { + var _response = json.decode(response.body); + print(_response); + return true; + } catch (e) { + // display error toast + return false; + } + } else { + return false; + } + } + static Future addTankers(payload) async { var response = await http.post(Uri.parse(addTankerUrl + '/' + supplierId),