From 7733c74f00f8950f555b5619b790e5e396e7f9ed Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 14 Dec 2021 11:30:52 +0300 Subject: [PATCH] Updates & fixes --- lib/core/service/client/base_app_client.dart | 20 +++++++++---------- .../PharmacyAddressesViewModel.dart | 17 +++------------- .../pharmacyAddresses/PharmacyAddresses.dart | 15 +++++++------- .../pharmacyAddress_service.dart | 1 + 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 94492c6c..99365d0c 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -232,7 +232,7 @@ class BaseAppClient { Map headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', - 'Authorization': token ?? '', + 'Authorization': pharmacyToken ?? '', 'Mobilenumber': user != null ? Utils.getPhoneNumberWithoutZero(user['MobileNumber'].toString()) : "", 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', 'Username': user != null ? user['PatientID'].toString() : "", @@ -291,20 +291,21 @@ class BaseAppClient { body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : user['PatientID']; body['PatientOutSA'] = user['OutSA']; body['SessionID'] = SESSION_ID; //getSe - headers = { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Authorization': pharmacyToken, - 'Mobilenumber': user['MobileNumber'].toString(), - 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', - 'Username': user['PatientID'].toString(), - }; + // headers = { + // 'Content-Type': 'application/json', + // 'Accept': 'application/json', + // 'Authorization': pharmacyToken, + // 'Mobilenumber': user['MobileNumber'].toString(), + // 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', + // 'Username': user['PatientID'].toString(), + // }; } } } print("URL : $url"); print("Body : ${json.encode(body)}"); + print("Headers : ${json.encode(headers)}"); if (await Utils.checkConnection()) { final response = await http.post(url.trim(), body: json.encode(body), headers: headers); @@ -709,7 +710,6 @@ class BaseAppClient { body['PatientTypeID'] = body.containsKey('PatientTypeID') ? body['PatientTypeID'] != null - ? body['PatientTypeID'] : user['PatientType'] != null ? user['PatientType'] diff --git a/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart b/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart index dae79ac1..2e883e5e 100644 --- a/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart @@ -1,11 +1,9 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Country.dart'; import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/customer_addresses_service.dart'; import 'package:diplomaticquarterapp/services/pharmacy_services/pharmacyAddress_service.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:google_maps_place_picker/google_maps_place_picker.dart'; import '../../../locator.dart'; @@ -76,27 +74,18 @@ class PharmacyAddressesViewModel extends BaseViewModel { sendingAddress.customerAttributes = ""; sendingAddress.createdOnUtc = DateTime.now().toString(); if (editedAddress == null) { - - ///TODO Fatima* await _pharmacyAddressService.addCustomerAddress(sendingAddress); - } else { - await _pharmacyAddressService.editCustomerAddress(sendingAddress); - + await _pharmacyAddressService.editCustomerAddress(sendingAddress).then((value) async { + // await _pharmacyAddressService.getAddresses(); + }); } if (_pharmacyAddressService.hasError) { - await _pharmacyAddressService.getAddresses(); setState(ViewState.Idle); - - - // setState(ViewState.Error); } else { setState(ViewState.Idle); } - - - } Future deleteAddresses(AddressInfo address) async { diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index c5edac52..3a9c4da4 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -37,10 +37,10 @@ class _PharmacyAddressesState extends State { ctx, FadePage( page: AddAddressPage(address, (pickResult) async { - model.addEditAddress(pickResult, address); - await model.getAddressesList(); - - }))); + await model.addEditAddress(pickResult, address); + }))).then((value) async { + // await model.getAddressesList(); + }); } Widget build(BuildContext context) { @@ -314,7 +314,7 @@ class _AddressItemWidgetState extends State { textColor: Color(0x99FF0000), handler: () { ConfirmDialog dialog = new ConfirmDialog( - // context: context, + // context: context, title: TranslationBase.of(context).deleteAddress, //"Are you sure want to delete", confirmMessage: "${widget.address.address1} ${widget.address.address2}", @@ -323,8 +323,9 @@ class _AddressItemWidgetState extends State { okFunction: () => { widget.model.deleteAddresses(widget.address).then((_) { ConfirmDialog.closeAlertDialog(context); - AppToast.showErrorToast(message: TranslationBase.of(context).deletedAddress, - // "Address has been deleted" + AppToast.showErrorToast( + message: TranslationBase.of(context).deletedAddress, + // "Address has been deleted" ); }) }, diff --git a/lib/services/pharmacy_services/pharmacyAddress_service.dart b/lib/services/pharmacy_services/pharmacyAddress_service.dart index 5329c658..352473e4 100644 --- a/lib/services/pharmacy_services/pharmacyAddress_service.dart +++ b/lib/services/pharmacy_services/pharmacyAddress_service.dart @@ -104,6 +104,7 @@ class PharmacyAddressService extends BaseService { response['customers'][0]['addresses'].forEach((item) { addresses.add(AddressInfo.fromJson(item)); }); + getAddresses(); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error;