diff --git a/lib/config/config.dart b/lib/config/config.dart index cd51694d..755c9739 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -21,8 +21,8 @@ var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; // var BASE_URL = 'http://10.50.100.198:2018/'; -// var BASE_URL = 'https://uat.hmgwebservices.com/'; -var BASE_URL = 'https://hmgwebservices.com/'; +var BASE_URL = 'https://uat.hmgwebservices.com/'; +// var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'http://10.201.204.103/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; @@ -357,7 +357,7 @@ var CAN_PAY_FOR_FOR_WALKIN_APPOINTMENT = 'Services/Doctors.svc/REST/CanPayForWal var CHANNEL = 3; var GENERAL_ID = 'Cs2020@2016\$2958'; var IP_ADDRESS = '10.20.10.20'; -var VERSION_ID = 19.4; +var VERSION_ID = 20.5; var SETUP_ID = '91877'; var LANGUAGE = 2; // var PATIENT_OUT_SA = 0; diff --git a/lib/models/Authentication/check_activation_code_request.dart b/lib/models/Authentication/check_activation_code_request.dart index 8d2cd71e..b81c0670 100644 --- a/lib/models/Authentication/check_activation_code_request.dart +++ b/lib/models/Authentication/check_activation_code_request.dart @@ -1,5 +1,6 @@ class CheckActivationCodeReq { int? patientMobileNumber; + String? patientMobileNumberOthers; // For Others country - string mobile number String? mobileNo; String? deviceToken; bool? projectOutSA; @@ -26,6 +27,7 @@ class CheckActivationCodeReq { CheckActivationCodeReq({ this.patientMobileNumber, + this.patientMobileNumberOthers, this.mobileNo, this.deviceToken, this.projectOutSA, @@ -53,6 +55,7 @@ class CheckActivationCodeReq { CheckActivationCodeReq.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; + patientMobileNumberOthers = json['PatientMobileNumber_Others']; mobileNo = json['MobileNo']; deviceToken = json['DeviceToken']; projectOutSA = json['ProjectOutSA']; @@ -81,7 +84,12 @@ class CheckActivationCodeReq { Map toJson() { final Map data = new Map(); data['PatientMobileNumber'] = this.patientMobileNumber; - data['MobileNo'] = this.mobileNo; + if (this.patientMobileNumberOthers != null) { + data['PatientMobileNumber_Others'] = this.patientMobileNumberOthers; + // Don't include MobileNo for Others country + } else { + data['MobileNo'] = this.mobileNo; + } data['DeviceToken'] = this.deviceToken; data['ProjectOutSA'] = this.projectOutSA; data['LoginType'] = this.loginType; diff --git a/lib/models/Authentication/check_paitent_authentication_req.dart b/lib/models/Authentication/check_paitent_authentication_req.dart index 8aa348c1..0ed7b3cf 100644 --- a/lib/models/Authentication/check_paitent_authentication_req.dart +++ b/lib/models/Authentication/check_paitent_authentication_req.dart @@ -1,5 +1,6 @@ class CheckPatientAuthenticationReq { int? patientMobileNumber; + String? patientMobileNumberOthers; String? zipCode; bool? isRegister; String? tokenID; @@ -20,6 +21,7 @@ class CheckPatientAuthenticationReq { String? healthId; CheckPatientAuthenticationReq( {this.patientMobileNumber, + this.patientMobileNumberOthers, this.zipCode, this.isRegister, this.tokenID, @@ -42,6 +44,7 @@ class CheckPatientAuthenticationReq { CheckPatientAuthenticationReq.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; + patientMobileNumberOthers = json['PatientMobileNumber_Others']; zipCode = json['ZipCode']; isRegister = json['isRegister']; tokenID = json['TokenID']; @@ -65,6 +68,7 @@ class CheckPatientAuthenticationReq { Map toJson() { final Map data = new Map(); data['PatientMobileNumber'] = this.patientMobileNumber; + data['PatientMobileNumber_Others'] = this.patientMobileNumberOthers; data['ZipCode'] = this.zipCode; data['isRegister'] = this.isRegister; data['TokenID'] = this.tokenID; diff --git a/lib/models/Authentication/select_device_imei_res.dart b/lib/models/Authentication/select_device_imei_res.dart index 979dfca1..c4eac58c 100644 --- a/lib/models/Authentication/select_device_imei_res.dart +++ b/lib/models/Authentication/select_device_imei_res.dart @@ -13,7 +13,7 @@ class SelectDeviceIMEIRES { int? patientID; int? patientType; int? preferredLanguage; - + bool? isOther; SelectDeviceIMEIRES( {this.biometricEnabled, this.createdOn, @@ -28,7 +28,9 @@ class SelectDeviceIMEIRES { this.outSA, this.patientID, this.patientType, - this.preferredLanguage}); + this.preferredLanguage, + this.isOther + }); SelectDeviceIMEIRES.fromJson(Map json) { biometricEnabled = json['BiometricEnabled']; @@ -45,6 +47,7 @@ class SelectDeviceIMEIRES { patientID = json['PatientID']; patientType = json['PatientType']; preferredLanguage = json['PreferredLanguage']; + isOther =json["IsOther"]; } Map toJson() { @@ -63,6 +66,8 @@ class SelectDeviceIMEIRES { data['PatientID'] = this.patientID; data['PatientType'] = this.patientType; data['PreferredLanguage'] = this.preferredLanguage; + data['IsOther'] = this.isOther; + return data; } diff --git a/lib/models/Authentication/send_activation_request.dart b/lib/models/Authentication/send_activation_request.dart index 04e684e9..8f9caa60 100644 --- a/lib/models/Authentication/send_activation_request.dart +++ b/lib/models/Authentication/send_activation_request.dart @@ -1,5 +1,6 @@ class SendActivationRequest { int? patientMobileNumber; + String? patientMobileNumberOthers; String? mobileNo; String? deviceToken; bool? projectOutSA; @@ -31,6 +32,7 @@ class SendActivationRequest { bool? isPatientExcluded; SendActivationRequest( {this.patientMobileNumber, + this.patientMobileNumberOthers, this.mobileNo, this.deviceToken, this.projectOutSA, @@ -64,6 +66,7 @@ class SendActivationRequest { SendActivationRequest.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; + patientMobileNumberOthers = json['PatientMobileNumber_Others']; mobileNo = json['MobileNo']; deviceToken = json['DeviceToken']; projectOutSA = json['ProjectOutSA']; @@ -98,6 +101,7 @@ class SendActivationRequest { Map toJson() { final Map data = new Map(); data['PatientMobileNumber'] = this.patientMobileNumber; + data['PatientMobileNumber_Others'] = this.patientMobileNumberOthers; data['MobileNo'] = this.mobileNo; data['DeviceToken'] = this.deviceToken; data['ProjectOutSA'] = this.projectOutSA; diff --git a/lib/models/mobile_number.dart b/lib/models/mobile_number.dart index f973aad9..a5908a8d 100644 --- a/lib/models/mobile_number.dart +++ b/lib/models/mobile_number.dart @@ -57,1031 +57,15 @@ List> countriesData = [ "pattern": "5xxxxxxxx", "maxLength": 9 }, - // { - // "name": "Bahrain", - // "name_ar": "البحرين", - // "code": "+973", - // "countryCode": "BH", - // "maxLength": 8 - // }, - // {"name": "Kuwait", "name_ar": "الكويت", "code": "+965", "countryCode": "KW"}, - // { - // "name": "Afghanistan", - // "name_ar": "أفغانستان", - // "code": "+93", - // "countryCode": "AF" - // }, - // { - // "name": "Aland Islands", - // "name_ar": "جزر آلاند", - // "code": "+358", - // "countryCode": "AX" - // }, - // { - // "name": "Albania", - // "name_ar": "ألبانيا", - // "code": "+355", - // "countryCode": "AL" - // }, - // { - // "name": "Algeria", - // "name_ar": "الجزائر", - // "code": "+213", - // "countryCode": "DZ" - // }, - // { - // "name": "AmericanSamoa", - // "name_ar": "ساموا الأمريكية", - // "code": "+1 684", - // "countryCode": "AS" - // }, - // {"name": "Andorra", "name_ar": "أندورا", "code": "+376", "countryCode": "AD"}, - // {"name": "Angola", "name_ar": "أنغولا", "code": "+244", "countryCode": "AO"}, - // { - // "name": "Anguilla", - // "name_ar": "أنغيلا", - // "code": "+1 264", - // "countryCode": "AI" - // }, - // { - // "name": "Antarctica", - // "name_ar": "القارة القطبية الجنوبية", - // "code": "+672", - // "countryCode": "AQ" - // }, - // { - // "name": "Antigua and Barbuda", - // "name_ar": "أنتيغوا وبربودا", - // "code": "+1268", - // "countryCode": "AG" - // }, - // { - // "name": "Argentina", - // "name_ar": "الأرجنتين", - // "code": "+54", - // "countryCode": "AR" - // }, - // { - // "name": "Armenia", - // "name_ar": "أرمينيا", - // "code": "+374", - // "countryCode": "AM" - // }, - // {"name": "Aruba", "name_ar": "أروبا", "code": "+297", "countryCode": "AW"}, - // { - // "name": "Australia", - // "name_ar": "أستراليا", - // "code": "+61", - // "countryCode": "AU" - // }, - // {"name": "Austria", "name_ar": "النمسا", "code": "+43", "countryCode": "AT"}, - // { - // "name": "Azerbaijan", - // "name_ar": "أذربيجان", - // "code": "+994", - // "countryCode": "AZ" - // }, - // { - // "name": "Bahamas", - // "name_ar": "الباهاما", - // "code": "+1 242", - // "countryCode": "BS" - // }, - // { - // "name": "Bangladesh", - // "name_ar": "بنغلاديش", - // "code": "+880", - // "countryCode": "BD" - // }, - // { - // "name": "Barbados", - // "name_ar": "بربادوس", - // "code": "+1 246", - // "countryCode": "BB" - // }, - // { - // "name": "Belarus", - // "name_ar": "روسيا البيضاء", - // "code": "+375", - // "countryCode": "BY" - // }, - // {"name": "Belgium", "name_ar": "بلجيكا", "code": "+32", "countryCode": "BE"}, - // {"name": "Belize", "name_ar": "بليز", "code": "+501", "countryCode": "BZ"}, - // {"name": "Benin", "name_ar": "بنين", "code": "+229", "countryCode": "BJ"}, - // { - // "name": "Bermuda", - // "name_ar": "برمودا", - // "code": "+1 441", - // "countryCode": "BM" - // }, - // {"name": "Bhutan", "name_ar": "بوتان", "code": "+975", "countryCode": "BT"}, - // { - // "name": "Bolivia, Plurinational State of", - // "name_ar": "دولة بوليفيا المتعددة القوميات", - // "code": "+591", - // "countryCode": "BO" - // }, - // { - // "name": "Bosnia and Herzegovina", - // "name_ar": "البوسنة والهرسك", - // "code": "+387", - // "countryCode": "BA" - // }, - // { - // "name": "Botswana", - // "name_ar": "بوتسوانا", - // "code": "+267", - // "countryCode": "BW" - // }, - // {"name": "Brazil", "name_ar": "البرازيل", "code": "+55", "countryCode": "BR"}, - // { - // "name": "British Indian Ocean Territory", - // "name_ar": "إقليم المحيط البريطاني الهندي", - // "code": "+246", - // "countryCode": "IO" - // }, - // { - // "name": "Brunei Darussalam", - // "name_ar": "بروناي دار السلام", - // "code": "+673", - // "countryCode": "BN" - // }, - // { - // "name": "Bulgaria", - // "name_ar": "بلغاريا", - // "code": "+359", - // "countryCode": "BG" - // }, - // { - // "name": "Burkina Faso", - // "name_ar": "بوركينا فاسو", - // "code": "+226", - // "countryCode": "BF" - // }, - // { - // "name": "Burundi", - // "name_ar": "بوروندي", - // "code": "+257", - // "countryCode": "BI" - // }, - // { - // "name": "Cambodia", - // "name_ar": "كمبوديا", - // "code": "+855", - // "countryCode": "KH" - // }, - // { - // "name": "Cameroon", - // "name_ar": "الكاميرون", - // "code": "+237", - // "countryCode": "CM" - // }, - // {"name": "Canada", "name_ar": "كندا", "code": "+1", "countryCode": "CA"}, - // { - // "name": "Cape Verde", - // "name_ar": "الرأس الأخضر", - // "code": "+238", - // "countryCode": "CV" - // }, - // { - // "name": "Cayman Islands", - // "name_ar": "جزر كايمان", - // "code": "+345", - // "countryCode": "KY" - // }, - // { - // "name": "Central African Republic", - // "name_ar": "جمهورية افريقيا الوسطى", - // "code": "+236", - // "countryCode": "CF" - // }, - // {"name": "Chad", "name_ar": "تشاد", "code": "+235", "countryCode": "TD"}, - // {"name": "Chile", "name_ar": "تشيلي", "code": "+56", "countryCode": "CL"}, - // {"name": "China", "name_ar": "الصين", "code": "+86", "countryCode": "CN"}, - // { - // "name": "Christmas Island", - // "name_ar": "جزيرة الكريسماس", - // "code": "+61", - // "countryCode": "CX" - // }, - // { - // "name": "Cocos (Keeling) Islands", - // "name_ar": "جزر كوكوس كيلينغ", - // "code": "+61", - // "countryCode": "CC" - // }, - // { - // "name": "Colombia", - // "name_ar": "كولومبيا", - // "code": "+57", - // "countryCode": "CO" - // }, - // { - // "name": "Comoros", - // "name_ar": "جزر القمر", - // "code": "+269", - // "countryCode": "KM" - // }, - // {"name": "Congo", "name_ar": "الكونغو", "code": "+242", "countryCode": "CG"}, - // { - // "name": "Congo, The Democratic Republic of the Congo", - // "name_ar": "الكونغو ، جمهورية الكونغو الديمقراطية", - // "code": "+243", - // "countryCode": "CD" - // }, - // { - // "name": "Cook Islands", - // "name_ar": "جزر كوك", - // "code": "+682", - // "countryCode": "CK" - // }, - // { - // "name": "Costa Rica", - // "name_ar": "كوستا ريكا", - // "code": "+506", - // "countryCode": "CR" - // }, - // { - // "name": "Cote d'Ivoire", - // "name_ar": "ساحل العاج", - // "code": "+225", - // "countryCode": "CI" - // }, - // { - // "name": "Croatia", - // "name_ar": "كرواتيا", - // "code": "+385", - // "countryCode": "HR" - // }, - // {"name": "Cuba", "name_ar": "كوبا", "code": "+53", "countryCode": "CU"}, - // {"name": "Cyprus", "name_ar": "قبرص", "code": "+357", "countryCode": "CY"}, - // { - // "name": "Czech Republic", - // "name_ar": "جمهورية التشيك", - // "code": "+420", - // "countryCode": "CZ" - // }, - // { - // "name": "Denmark", - // "name_ar": "الدنمارك", - // "code": "+45", - // "countryCode": "DK" - // }, - // { - // "name": "Djibouti", - // "name_ar": "جيبوتي", - // "code": "+253", - // "countryCode": "DJ" - // }, - // { - // "name": "Dominica", - // "name_ar": "دومينيكا", - // "code": "+1 767", - // "countryCode": "DM" - // }, - // { - // "name": "Dominican Republic", - // "name_ar": "جمهورية الدومنيكان", - // "code": "+1 849", - // "countryCode": "DO" - // }, - // { - // "name": "Ecuador", - // "name_ar": "الإكوادور", - // "code": "+593", - // "countryCode": "EC" - // }, - // {"name": "Egypt", "name_ar": "مصر", "code": "+20", "countryCode": "EG"}, - // { - // "name": "El Salvador", - // "name_ar": "السلفادور", - // "code": "+503", - // "countryCode": "SV" - // }, - // { - // "name": "Equatorial Guinea", - // "name_ar": "غينيا الإستوائية", - // "code": "+240", - // "countryCode": "GQ" - // }, - // { - // "name": "Eritrea", - // "name_ar": "إريتريا", - // "code": "+291", - // "countryCode": "ER" - // }, - // { - // "name": "Estonia", - // "name_ar": "استونيا", - // "code": "+372", - // "countryCode": "EE" - // }, - // { - // "name": "Ethiopia", - // "name_ar": "أثيوبيا", - // "code": "+251", - // "countryCode": "ET" - // }, - // { - // "name": "Falkland Islands (Malvinas)", - // "name_ar": "جزر فوكلاند مالفيناس", - // "code": "+500", - // "countryCode": "FK" - // }, - // { - // "name": "Faroe Islands", - // "name_ar": "جزر صناعية", - // "code": "+298", - // "countryCode": "FO" - // }, - // {"name": "Fiji", "name_ar": "فيجي", "code": "+679", "countryCode": "FJ"}, - // {"name": "Finland", "name_ar": "فنلندا", "code": "+358", "countryCode": "FI"}, - // {"name": "France", "name_ar": "فرنسا", "code": "+33", "countryCode": "FR"}, - // { - // "name": "French Guiana", - // "name_ar": "غيانا الفرنسية", - // "code": "+594", - // "countryCode": "GF" - // }, - // { - // "name": "French Polynesia", - // "name_ar": "بولينيزيا الفرنسية", - // "code": "+689", - // "countryCode": "PF" - // }, - // {"name": "Gabon", "name_ar": "الغابون", "code": "+241", "countryCode": "GA"}, - // {"name": "Gambia", "name_ar": "غامبيا", "code": "+220", "countryCode": "GM"}, - // {"name": "Georgia", "name_ar": "جورجيا", "code": "+995", "countryCode": "GE"}, - // {"name": "Germany", "name_ar": "ألمانيا", "code": "+49", "countryCode": "DE"}, - // {"name": "Ghana", "name_ar": "غانا", "code": "+233", "countryCode": "GH"}, - // { - // "name": "Gibraltar", - // "name_ar": "جبل طارق", - // "code": "+350", - // "countryCode": "GI" - // }, - // {"name": "Greece", "name_ar": "اليونان", "code": "+30", "countryCode": "GR"}, - // { - // "name": "Greenland", - // "name_ar": "الأرض الخضراء", - // "code": "+299", - // "countryCode": "GL" - // }, - // { - // "name": "Grenada", - // "name_ar": "غرينادا", - // "code": "+1 473", - // "countryCode": "GD" - // }, - // { - // "name": "Guadeloupe", - // "name_ar": "جوادلوب", - // "code": "+590", - // "countryCode": "GP" - // }, - // {"name": "Guam", "name_ar": "غوام", "code": "+1 671", "countryCode": "GU"}, - // { - // "name": "Guatemala", - // "name_ar": "غواتيمالا", - // "code": "+502", - // "countryCode": "GT" - // }, - // {"name": "Guernsey", "name_ar": "غيرنسي", "code": "+44", "countryCode": "GG"}, - // {"name": "Guinea", "name_ar": "غينيا", "code": "+224", "countryCode": "GN"}, - // { - // "name": "Guinea-Bissau", - // "name_ar": "غينيا بيساو", - // "code": "+245", - // "countryCode": "GW" - // }, - // {"name": "Guyana", "name_ar": "غيانا", "code": "+595", "countryCode": "GY"}, - // {"name": "Haiti", "name_ar": "هايتي", "code": "+509", "countryCode": "HT"}, - // { - // "name": "Holy See (Vatican City State)", - // "name_ar": "الكرسي الرسولي دولة الفاتيكان", - // "code": "+379", - // "countryCode": "VA" - // }, - // { - // "name": "Honduras", - // "name_ar": "هندوراس", - // "code": "+504", - // "countryCode": "HN" - // }, - // { - // "name": "Hong Kong", - // "name_ar": "هونج كونج", - // "code": "+852", - // "countryCode": "HK" - // }, - // {"name": "Hungary", "name_ar": "اليونان", "code": "+36", "countryCode": "HU"}, - // { - // "name": "Iceland", - // "name_ar": "أيسلندا", - // "code": "+354", - // "countryCode": "IS" - // }, - // {"name": "India", "name_ar": "الهند", "code": "+91", "countryCode": "IN"}, - // { - // "name": "Indonesia", - // "name_ar": "أندونيسيا", - // "code": "+62", - // "countryCode": "ID" - // }, - // { - // "name": "Iran, Islamic Republic of Persian Gulf", - // "name_ar": "جمهورية إيران الإسلامية الخليج الفارسي", - // "code": "+98", - // "countryCode": "IR" - // }, - // {"name": "Iraq", "name_ar": "العراق", "code": "+964", "countryCode": "IQ"}, - // { - // "name": "Ireland", - // "name_ar": "أيرلندا", - // "code": "+353", - // "countryCode": "IE" - // }, - // { - // "name": "Isle of Man", - // "name_ar": "جزيرة آيل أوف مان", - // "code": "+44", - // "countryCode": "IM" - // }, - // {"name": "Israel", "name_ar": "إسرائيل", "code": "+972", "countryCode": "IL"}, - // {"name": "Italy", "name_ar": "إيطاليا", "code": "+39", "countryCode": "IT"}, - // { - // "name": "Jamaica", - // "name_ar": "جامايكا", - // "code": "+1 876", - // "countryCode": "JM" - // }, - // {"name": "Japan", "name_ar": "اليابان", "code": "+81", "countryCode": "JP"}, - // {"name": "Jersey", "name_ar": "جيرسي", "code": "+44", "countryCode": "JE"}, - // {"name": "Jordan", "name_ar": "الأردن", "code": "+962", "countryCode": "JO"}, - // { - // "name": "Kazakhstan", - // "name_ar": "كازاخستان", - // "code": "+77", - // "countryCode": "KZ" - // }, - // {"name": "Kenya", "name_ar": "كينيا", "code": "+254", "countryCode": "KE"}, - // { - // "name": "Kiribati", - // "name_ar": "كيريباس", - // "code": "+686", - // "countryCode": "KI" - // }, - // { - // "name": "Korea, Democratic People's Republic of Korea", - // "name_ar": "جمهورية كوريا الديمقراطية الشعبية", - // "code": "+850", - // "countryCode": "KP" - // }, - // { - // "name": "Korea, Republic of South Korea", - // "name_ar": "جمهورية كوريا الديمقراطية الشعبية", - // "code": "+82", - // "countryCode": "KR" - // }, - // { - // "name": "Kyrgyzstan", - // "name_ar": "قرغيزستان", - // "code": "+996", - // "countryCode": "KG" - // }, - // {"name": "Laos", "name_ar": "لاوس", "code": "+856", "countryCode": "LA"}, - // {"name": "Latvia", "name_ar": "لاتفيا", "code": "+371", "countryCode": "LV"}, - // {"name": "Lebanon", "name_ar": "لبنان", "code": "+961", "countryCode": "LB"}, - // {"name": "Lesotho", "name_ar": "ليسوتو", "code": "+266", "countryCode": "LS"}, - // { - // "name": "Liberia", - // "name_ar": "ليبيريا", - // "code": "+231", - // "countryCode": "LR" - // }, - // { - // "name": "Libyan Arab Jamahiriya", - // "name_ar": "الجماهيرية العربية الليبية", - // "code": "+218", - // "countryCode": "LY" - // }, - // { - // "name": "Liechtenstein", - // "name_ar": "ليختنشتاين", - // "code": "+423", - // "countryCode": "LI" - // }, - // { - // "name": "Lithuania", - // "name_ar": "ليتوانيا", - // "code": "+370", - // "countryCode": "LT" - // }, - // { - // "name": "Luxembourg", - // "name_ar": "لوكسمبورغ", - // "code": "+352", - // "countryCode": "LU" - // }, - // {"name": "Macao", "name_ar": "ماكاو", "code": "+853", "countryCode": "MO"}, - // { - // "name": "Macedonia", - // "name_ar": "مقدونيا", - // "code": "+389", - // "countryCode": "MK" - // }, - // { - // "name": "Madagascar", - // "name_ar": "مدغشقر", - // "code": "+261", - // "countryCode": "MG" - // }, - // {"name": "Malawi", "name_ar": "مالاوي", "code": "+265", "countryCode": "MW"}, - // { - // "name": "Malaysia", - // "name_ar": "ماليزيا", - // "code": "+60", - // "countryCode": "MY" - // }, - // { - // "name": "Maldives", - // "name_ar": "جزر المالديف", - // "code": "+960", - // "countryCode": "MV" - // }, - // {"name": "Mali", "name_ar": "مالي", "code": "+223", "countryCode": "ML"}, - // {"name": "Malta", "name_ar": "مالطا", "code": "+356", "countryCode": "MT"}, - // { - // "name": "Marshall Islands", - // "name_ar": "جزر مارشال", - // "code": "+692", - // "countryCode": "MH" - // }, - // { - // "name": "Martinique", - // "name_ar": "مارتينيك", - // "code": "+596", - // "countryCode": "MQ" - // }, - // { - // "name": "Mauritania", - // "name_ar": "موريتانيا", - // "code": "+222", - // "countryCode": "MR" - // }, - // { - // "name": "Mauritius", - // "name_ar": "موريشيوس", - // "code": "+230", - // "countryCode": "MU" - // }, - // {"name": "Mayotte", "name_ar": "مايوت", "code": "+262", "countryCode": "YT"}, - // {"name": "Mexico", "name_ar": "المكسيك", "code": "+52", "countryCode": "MX"}, - // { - // "name": "Micronesia, Federated States of Micronesia", - // "name_ar": "ميكرونيزيا ، ولايات ميكرونيزيا الموحدة", - // "code": "+691", - // "countryCode": "FM" - // }, - // { - // "name": "Moldova", - // "name_ar": "مولدوفا", - // "code": "+373", - // "countryCode": "MD" - // }, - // {"name": "Monaco", "name_ar": "موناكو", "code": "+377", "countryCode": "MC"}, - // { - // "name": "Mongolia", - // "name_ar": "منغوليا", - // "code": "+976", - // "countryCode": "MN" - // }, - // { - // "name": "Montenegro", - // "name_ar": "الجبل الأسود", - // "code": "+382", - // "countryCode": "ME" - // }, - // { - // "name": "Montserrat", - // "name_ar": "مونتسيرات", - // "code": "+1664", - // "countryCode": "MS" - // }, - // {"name": "Morocco", "name_ar": "المغرب", "code": "+212", "countryCode": "MA"}, - // { - // "name": "Mozambique", - // "name_ar": "موزمبيق", - // "code": "+258", - // "countryCode": "MZ" - // }, - // {"name": "Myanmar", "name_ar": "ميانمار", "code": "+95", "countryCode": "MM"}, - // { - // "name": "Namibia", - // "name_ar": "ناميبيا", - // "code": "+264", - // "countryCode": "NA" - // }, - // {"name": "Nauru", "name_ar": "ناورو", "code": "+674", "countryCode": "NR"}, - // {"name": "Nepal", "name_ar": "نيبال", "code": "+977", "countryCode": "NP"}, - // { - // "name": "Netherlands", - // "name_ar": "هولندا", - // "code": "+31", - // "countryCode": "NL" - // }, - // { - // "name": "Netherlands Antilles", - // "name_ar": "جزر الأنتيل الهولندية", - // "code": "+599", - // "countryCode": "AN" - // }, - // { - // "name": "New Caledonia", - // "name_ar": "كاليدونيا الجديدة", - // "code": "+687", - // "countryCode": "NC" - // }, - // { - // "name": "New Zealand", - // "name_ar": "نيوزيلندا", - // "code": "+64", - // "countryCode": "NZ" - // }, - // { - // "name": "Nicaragua", - // "name_ar": "نيكاراغوا", - // "code": "+505", - // "countryCode": "NI" - // }, - // {"name": "Niger", "name_ar": "النيجر", "code": "+227", "countryCode": "NE"}, - // { - // "name": "Nigeria", - // "name_ar": "نيجيريا", - // "code": "+234", - // "countryCode": "NG" - // }, - // {"name": "Niue", "name_ar": "نيوي", "code": "+683", "countryCode": "NU"}, - // { - // "name": "Norfolk Island", - // "name_ar": "جزيرة نورفولك", - // "code": "+672", - // "countryCode": "NF" - // }, - // { - // "name": "Northern Mariana Islands", - // "name_ar": "جزر مريانا الشمالية", - // "code": "+1 670", - // "countryCode": "MP" - // }, - // {"name": "Norway", "name_ar": "النرويج", "code": "+47", "countryCode": "NO"}, - // { - // "name": "Oman", - // "name_ar": "سلطنة عمان", - // "code": "+968", - // "countryCode": "OM" - // }, - // { - // "name": "Pakistan", - // "name_ar": "باكستان", - // "code": "+92", - // "countryCode": "PK" - // }, - // {"name": "Palau", "name_ar": "بالاو", "code": "+680", "countryCode": "PW"}, - // { - // "name": "Palestinian Territory, Occupied", - // "name_ar": "الأراضي الفلسطينية المحتلة", - // "code": "+970", - // "countryCode": "PS" - // }, - // {"name": "Panama", "name_ar": "بناما", "code": "+507", "countryCode": "PA"}, - // { - // "name": "Papua New Guinea", - // "name_ar": "بابوا غينيا الجديدة", - // "code": "+675", - // "countryCode": "PG" - // }, - // { - // "name": "Paraguay", - // "name_ar": "باراغواي", - // "code": "+595", - // "countryCode": "PY" - // }, - // {"name": "Peru", "name_ar": "بيرو", "code": "+51", "countryCode": "PE"}, - // { - // "name": "Philippines", - // "name_ar": "الفلبين", - // "code": "+63", - // "countryCode": "PH" - // }, - // { - // "name": "Pitcairn", - // "name_ar": "بيتكيرن", - // "code": "+872", - // "countryCode": "PN" - // }, - // {"name": "Poland", "name_ar": "بولندا", "code": "+48", "countryCode": "PL"}, - // { - // "name": "Portugal", - // "name_ar": "البرتغال", - // "code": "+351", - // "countryCode": "PT" - // }, - // { - // "name": "Puerto Rico", - // "name_ar": "بورتوريكو", - // "code": "+1 939", - // "countryCode": "PR" - // }, - // {"name": "Qatar", "name_ar": "دولة قطر", "code": "+974", "countryCode": "QA"}, - // {"name": "Romania", "name_ar": "رومانيا", "code": "+40", "countryCode": "RO"}, - // {"name": "Russia", "name_ar": "روسيا", "code": "+7", "countryCode": "RU"}, - // {"name": "Rwanda", "name_ar": "رواندا", "code": "+250", "countryCode": "RW"}, - // { - // "name": "Reunion", - // "name_ar": "جمع شمل", - // "code": "+262", - // "countryCode": "RE" - // }, - // { - // "name": "Saint Barthelemy", - // "name_ar": "سانت بارتيليمي", - // "code": "+590", - // "countryCode": "BL" - // }, - // { - // "name": "Saint Helena, Ascension and Tristan Da Cunha", - // "name_ar": "سانت هيلانة ، أسنشن وتريستان دا كونها", - // "code": "+290", - // "countryCode": "SH" - // }, - // { - // "name": "Saint Kitts and Nevis", - // "name_ar": "سانت كيتس ونيفيس", - // "code": "+1 869", - // "countryCode": "KN" - // }, - // { - // "name": "Saint Lucia", - // "name_ar": "القديسة لوسيا", - // "code": "+1 758", - // "countryCode": "LC" - // }, - // { - // "name": "Saint Martin", - // "name_ar": "القديس مارتن", - // "code": "+590", - // "countryCode": "MF" - // }, - // { - // "name": "Saint Pierre and Miquelon", - // "name_ar": "سانت بيير وميكلون", - // "code": "+508", - // "countryCode": "PM" - // }, - // { - // "name": "Saint Vincent and the Grenadines", - // "name_ar": "سانت فنسنت وجزر غرينادين", - // "code": "+1 784", - // "countryCode": "VC" - // }, - // {"name": "Samoa", "name_ar": "ساموا", "code": "+685", "countryCode": "WS"}, - // { - // "name": "San Marino", - // "name_ar": "سان مارينو", - // "code": "+378", - // "countryCode": "SM" - // }, - // { - // "name": "Sao Tome and Principe", - // "name_ar": "ساو تومي وبرينسيبي", - // "code": "+239", - // "countryCode": "ST" - // }, - // { - // "name": "Senegal", - // "name_ar": "السنغال", - // "code": "+221", - // "countryCode": "SN" - // }, - // {"name": "Serbia", "name_ar": "صربيا", "code": "+381", "countryCode": "RS"}, - // { - // "name": "Seychelles", - // "name_ar": "سيشيل", - // "code": "+248", - // "countryCode": "SC" - // }, - // { - // "name": "Sierra Leone", - // "name_ar": "سيرا ليون", - // "code": "+232", - // "countryCode": "SL" - // }, - // { - // "name": "Singapore", - // "name_ar": "سنغافورة", - // "code": "+65", - // "countryCode": "SG" - // }, - // { - // "name": "Slovakia", - // "name_ar": "سلوفاكيا", - // "code": "+421", - // "countryCode": "SK" - // }, - // { - // "name": "Slovenia", - // "name_ar": "سلوفينيا", - // "code": "+386", - // "countryCode": "SI" - // }, - // { - // "name": "Solomon Islands", - // "name_ar": "جزر سليمان", - // "code": "+677", - // "countryCode": "SB" - // }, - // { - // "name": "Somalia", - // "name_ar": "الصومال", - // "code": "+252", - // "countryCode": "SO" - // }, - // { - // "name": "South Africa", - // "name_ar": "جنوب أفريقيا", - // "code": "+27", - // "countryCode": "ZA" - // }, - // { - // "name": "South Georgia and the South Sandwich Islands", - // "name_ar": "جورجيا الجنوبية وجزر ساندويتش الجنوبية", - // "code": "+500", - // "countryCode": "GS" - // }, - // {"name": "Spain", "name_ar": "إسبانيا", "code": "+34", "countryCode": "ES"}, - // { - // "name": "Sri Lanka", - // "name_ar": "سيريلانكا", - // "code": "+94", - // "countryCode": "LK" - // }, - // {"name": "Sudan", "name_ar": "سودان", "code": "+249", "countryCode": "SD"}, - // { - // "name": "Suriname", - // "name_ar": "سورينام", - // "code": "+597", - // "countryCode": "SR" - // }, - // { - // "name": "Svalbard and Jan Mayen", - // "name_ar": "سفالبارد وجان ماين", - // "code": "+47", - // "countryCode": "SJ" - // }, - // { - // "name": "Swaziland", - // "name_ar": "سوازيلاند", - // "code": "+268", - // "countryCode": "SZ" - // }, - // {"name": "Sweden", "name_ar": "السويد", "code": "+46", "countryCode": "SE"}, - // { - // "name": "Switzerland", - // "name_ar": "سويسرا", - // "code": "+41", - // "countryCode": "CH" - // }, - // { - // "name": "Syrian Arab Republic", - // "name_ar": "الجمهورية العربية السورية", - // "code": "+963", - // "countryCode": "SY" - // }, - // {"name": "Taiwan", "name_ar": "تايوان", "code": "+886", "countryCode": "TW"}, - // { - // "name": "Tajikistan", - // "name_ar": "طاجيكستان", - // "code": "+992", - // "countryCode": "TJ" - // }, - // { - // "name": "Tanzania, United Republic of Tanzania", - // "name_ar": "تنزانيا ، جمهورية تنزانيا المتحدة", - // "code": "+255", - // "countryCode": "TZ" - // }, - // { - // "name": "Thailand", - // "name_ar": "تايلاند", - // "code": "+66", - // "countryCode": "TH" - // }, - // { - // "name": "Timor-Leste", - // "name_ar": "تيمور الشرقية", - // "code": "+670", - // "countryCode": "TL" - // }, - // {"name": "Togo", "name_ar": "ليذهب", "code": "+228", "countryCode": "TG"}, - // { - // "name": "Tokelau", - // "name_ar": "توكيلاو", - // "code": "+690", - // "countryCode": "TK" - // }, - // {"name": "Tonga", "name_ar": "تونغا", "code": "+676", "countryCode": "TO"}, - // { - // "name": "Trinidad and Tobago", - // "name_ar": "ترينداد وتوباغو", - // "code": "+1 868", - // "countryCode": "TT" - // }, - // {"name": "Tunisia", "name_ar": "تونس", "code": "+216", "countryCode": "TN"}, - // {"name": "Turkey", "name_ar": "ديك رومي", "code": "+90", "countryCode": "TR"}, - // { - // "name": "Turkmenistan", - // "name_ar": "تركمانستان", - // "code": "+993", - // "countryCode": "TM" - // }, - // { - // "name": "Turks and Caicos Islands", - // "name_ar": "جزر تركس وكايكوس", - // "code": "+1 649", - // "countryCode": "TC" - // }, - // {"name": "Tuvalu", "name_ar": "توفالو", "code": "+688", "countryCode": "TV"}, - // {"name": "Uganda", "name_ar": "أوغندا", "code": "+256", "countryCode": "UG"}, - // { - // "name": "Ukraine", - // "name_ar": "أوكرانيا", - // "code": "+380", - // "countryCode": "UA" - // }, - // { - // "name": "United Kingdom", - // "name_ar": "المملكة المتحدة", - // "code": "+44", - // "countryCode": "GB" - // }, - // { - // "name": "United States", - // "name_ar": "الولايات المتحدة الامريكانية", - // "code": "+1", - // "countryCode": "US" - // }, - // { - // "name": "Uruguay", - // "name_ar": "أوروغواي", - // "code": "+598", - // "countryCode": "UY" - // }, - // { - // "name": "Uzbekistan", - // "name_ar": "أوزبكستان", - // "code": "+998", - // "countryCode": "UZ" - // }, - // { - // "name": "Vanuatu", - // "name_ar": "فانواتو", - // "code": "+678", - // "countryCode": "VU" - // }, - // { - // "name": "Venezuela, Bolivarian Republic of Venezuela", - // "name_ar": "فنزويلا ، جمهورية فنزويلا البوليفارية", - // "code": "+58", - // "countryCode": "VE" - // }, - // {"name": "Vietnam", "name_ar": "فيتنام", "code": "+84", "countryCode": "VN"}, - // { - // "name": "Virgin Islands, British", - // "name_ar": "جزر العذراء البريطانية", - // "code": "+1 284", - // "countryCode": "VG" - // }, - // { - // "name": "Virgin Islands, U.S.", - // "name_ar": "جزر فيرجن ، الولايات المتحدة", - // "code": "+1 340", - // "countryCode": "VI" - // }, - // { - // "name": "Wallis and Futuna", - // "name_ar": "واليس وفوتونا", - // "code": "+681", - // "countryCode": "WF" - // }, - // {"name": "Yemen", "name_ar": "اليمن", "code": "+967", "countryCode": "YE"}, - // {"name": "Zambia", "name_ar": "زامبيا", "code": "+260", "countryCode": "ZM"}, - // { - // "name": "Zimbabwe", - // "name_ar": "زيمبابوي", - // "code": "+263", - // "countryCode": "ZW" - // } + { + "name": "Others", + "name_ar": "أخرى", + "code": "0", + "countryCode": "OT", + "pattern": "", + "maxLength": 20 + }, + ]; // }); // List countryList =[]; diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index ffa18025..0d3a8d52 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -63,7 +63,8 @@ class _ConfirmLogin extends State { bool authenticated = false; final authService = AuthProvider(); PharmacyModuleViewModel pharmacyModuleViewModel = locator(); - late int mobileNumber; + int? mobileNumber; + String? mobileNumberOthers; String errorMsg = ''; SelectDeviceIMEIRES? user; bool isLoading = false; @@ -426,6 +427,17 @@ class _ConfirmLogin extends State { request.dob = ""; request.healthId = ""; request.isHijri = 0; + + zipCode =='0' ? await this.authService.sendActivationCodeOthers(request).then((result) { + GifLoaderDialogUtils.hideDialog(context); + if (result != null && result['isSMSSent'] == true) { + this.startSMSService(type); + } + }).catchError((r) { + GifLoaderDialogUtils.hideDialog(context); + AppToast.showErrorToast(message: r.toString()); + }) + : await this.authService.sendActivationCode(request).then((result) { GifLoaderDialogUtils.hideDialog(context); if (result != null && result['isSMSSent'] == true) { @@ -445,7 +457,7 @@ class _ConfirmLogin extends State { new SMSOTP( context, type, - this.mobileNumber, + zipCode =='0'? this.mobileNumberOthers : this.mobileNumber, (value) { this.checkActivationCode(value: value); }, @@ -532,7 +544,9 @@ class _ConfirmLogin extends State { this.registerd_data = await CheckPatientAuthenticationReq.fromJson(await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); } - this.mobileNumber = this.registerd_data != null ? this.registerd_data.patientMobileNumber : int.parse(this.user!.mobile!); + this.mobileNumberOthers = this.registerd_data != null ? this.registerd_data.patientMobileNumberOthers : this.user!.mobile; + this.mobileNumber = this.registerd_data != null ? this.registerd_data.patientMobileNumber : int.parse(this.user!.mobile!); + this.zipCode = this.registerd_data != null ? this.registerd_data.zipCode : this.user!.outSA == true @@ -563,6 +577,10 @@ class _ConfirmLogin extends State { ? user!.logInType : null; + if(this.user !=null && this.user!.isOther!){ + this.zipCode ='0'; + } + showLoader(false); //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); } @@ -570,13 +588,22 @@ class _ConfirmLogin extends State { getCommonRequest({type}) { var request = SendActivationRequest(); request.patientMobileNumber = this.mobileNumber; - request.mobileNo = '0' + this.mobileNumber.toString(); + + if(this.zipCode=='0'){ + request.patientMobileNumberOthers = this.mobileNumberOthers; + request.mobileNo = this.mobileNumberOthers; + }else { + request.mobileNo = '0' + this.mobileNumber.toString(); + } request.deviceToken = this.deviceToken; request.projectOutSA = this.patientOutSA == true ? true : false; - request.loginType = this.selectedOption; + request.loginType = type ?? this.selectedOption; request.oTPSendType = type == 1 ? type : 2; //this.selectedOption == 1 ? 1 : 2; request.zipCode = this.zipCode; + //added new parameter for other country + + request.logInTokenID = this.loginTokenID ?? ""; if (this.registerd_data != null) { @@ -644,8 +671,12 @@ class _ConfirmLogin extends State { }); }); } else { - authService - .checkActivationCode(request, value) + // Check if Others country (zipCode == "0") and call appropriate API + final activationCodeCall = (this.zipCode == "0") + ? authService.checkActivationCodeOthers(request, value) + : authService.checkActivationCode(request, value); + + activationCodeCall .then((result) async => { res = result, if (result is Map) @@ -783,7 +814,7 @@ class _ConfirmLogin extends State { } insertIMEI() { - authService.insertDeviceImei(selectedOption).then((value) => {}).catchError((err) { + authService.insertDeviceImei(selectedOption, isForOthers: this.zipCode == "0").then((value) => {}).catchError((err) { print(err); }); } @@ -846,8 +877,9 @@ class _ConfirmLogin extends State { }); } - Widget _loginOptionButton(String _title, String _icon, int _flag, int? _loginIndex) { - bool isDisable = (_flag == 3 && !checkIfBiometricAvailable(BiometricType.face) || + Widget _loginOptionButton(String _title, String _icon, int _flag, int? _loginIndex, {bool isDisabledForOthers = false}) { + bool isDisable = isDisabledForOthers || + (_flag == 3 && !checkIfBiometricAvailable(BiometricType.face) || _flag == 2 && !checkIfBiometricAvailable(BiometricType.fingerprint) && _flag == 2 && !checkIfBiometricAvailable(BiometricType.strong)); return InkWell( onTap: isDisable @@ -894,18 +926,21 @@ class _ConfirmLogin extends State { // todo 'sikander' optimize this after knowing usage Widget getButton(int flag) { + // Disable SMS for Others country (zipCode == "0") + bool isDisabledForOthers = (flag == 1 && this.zipCode == "0"); + switch (flag) { case 4: - return _loginOptionButton(TranslationBase.of(context).verifyWhatsApp, 'assets/images/new/verify_whatsapp.svg', flag, null); + return _loginOptionButton(TranslationBase.of(context).verifyWhatsApp, 'assets/images/new/verify_whatsapp.svg', flag, null, isDisabledForOthers: false); break; case 1: - return _loginOptionButton(TranslationBase.of(context).verifySMS, 'assets/images/new/verify_sms.svg', flag, null); + return _loginOptionButton(TranslationBase.of(context).verifySMS, 'assets/images/new/verify_sms.svg', flag, null, isDisabledForOthers: isDisabledForOthers); break; case 2: - return _loginOptionButton(TranslationBase.of(context).verifyFingerprint, 'assets/images/new/verify_thumb.svg', flag, BiometricType.fingerprint.index); + return _loginOptionButton(TranslationBase.of(context).verifyFingerprint, 'assets/images/new/verify_thumb.svg', flag, BiometricType.fingerprint.index, isDisabledForOthers: false); break; case 3: - return _loginOptionButton(TranslationBase.of(context).verifyFaceID, 'assets/images/new/verify_face.svg', flag, BiometricType.face.index); + return _loginOptionButton(TranslationBase.of(context).verifyFaceID, 'assets/images/new/verify_face.svg', flag, BiometricType.face.index, isDisabledForOthers: false); break; default: diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index df111ba1..074e9a85 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -198,7 +198,7 @@ class _Login extends State { TextField( enabled: isEnable, scrollPadding: EdgeInsets.zero, - keyboardType: TextInputType.number, + keyboardType: countryCode =='0'? TextInputType.text: TextInputType.number, controller: _controller, onChanged: (value) => {validateForm()}, style: TextStyle( @@ -254,8 +254,13 @@ class _Login extends State { } void validateForm() { - if (util.validateIDBox(nationalIDorFile.text, loginType) == true && - (countryCode == "971" ? true : util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true)) { + // For "Others" country, skip Saudi ID validation + bool idValidation = util.validateIDBox(nationalIDorFile.text, loginType) == true || countryCode == "0"; + bool countrySpecificValidation = (countryCode == "971" || countryCode == "0") + ? true + : util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true; + + if (idValidation && countrySpecificValidation && mobileNo != null && mobileNo!.isNotEmpty) { setState(() { isButtonDisabled = false; }); @@ -270,7 +275,18 @@ class _Login extends State { // showLoader(true); var request = CheckPatientAuthenticationReq(); request.isRegister = false; - request.patientMobileNumber = int.parse(mobileNo!); + + // For Others country (countryCode == "0"), pass mobile number as STRING + // For KSA/UAE, pass mobile number as INT + if (countryCode == "0") { + // Mobile number as string for international format (e.g., "+1234567890") + request.patientMobileNumberOthers = mobileNo; // String + + } else { + // Mobile number as integer for KSA/UAE (e.g., 501234567) + request.patientMobileNumber = int.parse(mobileNo!); // Int + } + request.zipCode = countryCode; request.searchType = this.loginType; request.deviceTypeID = this.loginType; @@ -283,7 +299,14 @@ class _Login extends State { } sharedPref.setObject(REGISTER_DATA_FOR_REGISTER, request); GifLoaderDialogUtils.showMyDialog(context); - authService.checkPatientAuthentication(request).then((value) { + + // Use checkPatientAuthenticationOthers for Others country (countryCode == "0") + // Use checkPatientAuthentication for KSA/UAE (countryCode == "966" or "971") + final authCall = (countryCode == "0") + ? authService.checkPatientAuthenticationOthers(request) + : authService.checkPatientAuthentication(request); + + authCall.then((value) { // if (value['UserAccountIsActivated']) { if (value['isSMSSent']) { sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 6c03f9e9..1db329b2 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -34,13 +34,17 @@ AppSharedPreferences sharedPref = AppSharedPreferences(); AppGlobal appGlobal = AppGlobal(); const String INSERT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI'; +const INSERT_DEVICE_IMEI_OTHERS ='Services/Patients.svc/REST/Patient_INSERTDeviceIMEI_Others'; const String SELECT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI'; const String CHECK_PATIENT_AUTH = 'Services/Authentication.svc/REST/CheckPatientAuthentication'; +const String CHECK_PATIENT_AUTH_OTHERS = 'Services/Authentication.svc/REST/CheckPatientAuthentication_Others'; const GET_MOBILE_INFO = 'Services/Authentication.svc/REST/GetMobileLoginInfo'; const SEND_ACTIVATION_CODE = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType'; +const SEND_ACTIVATION_CODE_OTHERS = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType_Others'; const SEND_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration'; const CHECK_ACTIVATION_CODE = 'Services/Authentication.svc/REST/CheckActivationCode'; +const CHECK_ACTIVATION_CODE_OTHERS = 'Services/Authentication.svc/REST/CheckActivationCode_Others'; const CHECK_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/CheckActivationCodeForRegistration'; const FORGOT_PASSWORD = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo'; @@ -111,7 +115,7 @@ class AuthProvider with ChangeNotifier { // } // } - Future insertDeviceImei(lstLogin) async { + Future insertDeviceImei(lstLogin,{ bool isForOthers = false}) async { try { dynamic localRes; var lastLogin = lstLogin; //await sharedPref.getInt( @@ -137,9 +141,8 @@ class AuthProvider with ChangeNotifier { newRequest.patientType = request.patientType; newRequest.setupID = request.setupID; newRequest.tokenID = await sharedPref.getString(TOKEN); - // } - await new BaseAppClient().post(INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { + await new BaseAppClient().post(isForOthers ? INSERT_DEVICE_IMEI_OTHERS : INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { throw error; @@ -196,7 +199,7 @@ class AuthProvider with ChangeNotifier { request.patientOutSA = (request.zipCode == '966' || request.zipCode == '+966') ? 0 : 1; try { dynamic localRes; - await new BaseAppClient().post(CHECK_PATIENT_AUTH, onSuccess: (dynamic response, int statusCode) { + await new BaseAppClient().post( request.zipCode =='0' ? CHECK_PATIENT_AUTH_OTHERS : CHECK_PATIENT_AUTH, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { throw error; @@ -208,6 +211,27 @@ class AuthProvider with ChangeNotifier { } } + // New function for Others country authentication + Future checkPatientAuthenticationOthers(CheckPatientAuthenticationReq request) async { + request.versionID = VERSION_ID; + request.channel = CHANNEL; + request.iPAdress = IP_ADDRESS; + request.generalid = GENERAL_ID; + request.languageID = (languageID == 'ar' ? 1 : 2); + request.patientOutSA = 1; // Always set to 1 for Others (outside KSA/UAE) + try { + dynamic localRes; + await new BaseAppClient().post(CHECK_PATIENT_AUTH_OTHERS, onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request.toJson()); + return Future.value(localRes); + } catch (error) { + throw error; + } + } + Future getLoginInfo(request) async { request.versionID = VERSION_ID; request.channel = CHANNEL; @@ -249,6 +273,28 @@ class AuthProvider with ChangeNotifier { return Future.value(localRes); } + // New method for Others country activation code + Future sendActivationCodeOthers(request) async { + request.versionID = VERSION_ID; + request.channel = CHANNEL; + request.iPAdress = IP_ADDRESS; + request.generalid = GENERAL_ID; + // request.languageID = (languageID == 'ar' ? 1 : 2); + request.languageID = 2; + request.deviceTypeID = Platform.isIOS ? 1 : 2; + request.patientOutSA = 1; // Always 1 for Others (outside KSA/UAE) + request.isDentalAllowedBackend = false; + + dynamic localRes; + await new BaseAppClient().post(SEND_ACTIVATION_CODE_OTHERS, onSuccess: (dynamic response, int statusCode) { + localRes = response; + authenticatedUser = CheckActivationCode.fromJson(localRes); + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request.toJson()); + return Future.value(localRes); + } + Future sendActivationCodeRegister(request) async { request.versionID = VERSION_ID; request.channel = CHANNEL; @@ -282,6 +328,8 @@ class AuthProvider with ChangeNotifier { neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1; neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true; neRequest.isDentalAllowedBackend = false; + // neRequest.zipCode ='966'; //hardcoded for testing + // request.languageID = (languageID == 'ar' ? 1 : 2) // neRequest.deviceToken = null; neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false; neRequest.isRegister = false; @@ -300,6 +348,35 @@ class AuthProvider with ChangeNotifier { } } + Future checkActivationCodeOthers(request, [value]) async { + var neRequest = CheckActivationCodeReq.fromJson(request); + + neRequest.activationCode = value ?? "0000"; + neRequest.isSilentLogin = value != null ? false : true; + neRequest.versionID = VERSION_ID; + neRequest.channel = CHANNEL; + neRequest.iPAdress = IP_ADDRESS; + neRequest.generalid = GENERAL_ID; + neRequest.deviceTypeID = Platform.isIOS ? 1 : 2; + neRequest.patientOutSA = 1; // Always 1 for Others (outside KSA/UAE) + neRequest.projectOutSA = true; // Always true for Others + neRequest.isDentalAllowedBackend = false; + neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false; + neRequest.isRegister = false; + dynamic localRes; + try { + await new BaseAppClient().post(CHECK_ACTIVATION_CODE_OTHERS, onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + localRes = error; + return Future.value(error); + }, body: neRequest.toJson()); + return Future.value(localRes); + } catch (error) { + throw localRes; + } + } + Future checkActivationCodeRegister(request, [value]) async { var neRequest = CheckActivationCodeRegisterReq.fromJson(request); @@ -574,8 +651,7 @@ class AuthProvider with ChangeNotifier { // { // "ID": 12, // "ServiceName": "Precriptions", - // "Previlege": true, - // "Region": null + // "Previlege": true,// "Region": null // }, // { // "ID": 13, diff --git a/lib/widgets/mobile-no/mobile_no.dart b/lib/widgets/mobile-no/mobile_no.dart index b248c4d1..f25ba11c 100644 --- a/lib/widgets/mobile-no/mobile_no.dart +++ b/lib/widgets/mobile-no/mobile_no.dart @@ -30,6 +30,11 @@ class _PhoneNumberSelectorWidgetState extends State { List counties = []; ProjectViewModel? projectProvider; TextEditingController textController = new TextEditingController(); + String? validationError; + + // Regular expression to detect KSA (+966) or UAE (+971) phone numbers + // Matches: +966, 966, 00966, +971, 971, 00971 at the start + final RegExp ksaUaePattern = RegExp(r'^(\+|00)?(966|971)'); @override void initState() { @@ -38,6 +43,19 @@ class _PhoneNumberSelectorWidgetState extends State { super.initState(); } + // Validate phone number when "Others" is selected + String? validatePhoneNumber(String value) { + if (countryCode == "0" && value.isNotEmpty) { + // Check if the number starts with KSA or UAE country code + if (ksaUaePattern.hasMatch(value)) { + return projectProvider?.isArabic == true + ? "يرجى عدم إدخال أرقام السعودية أو الإمارات. استخدم الخيار المناسب من القائمة" + : "Please do not enter KSA or UAE numbers. Use the appropriate option from the list"; + } + } + return null; + } + @override void dispose() { super.dispose(); @@ -56,16 +74,43 @@ class _PhoneNumberSelectorWidgetState extends State { } } + // Check if "Others" is selected (code == "0") + bool isOthersSelected = countryCode == "0"; + return Column( children: [ inputWidget(TranslationBase.of(context).country, countryName!, isEnable: true, hasSelection: true), SizedBox(height: 12), - Directionality(textDirection: TextDirection.ltr, child: inputWidget(TranslationBase.of(context).phoneNumber, isEnable: widget.isEnable, widget.mobileNo ?? "5xxxxxxxx", prefix: countryCode)), + Directionality( + textDirection: TextDirection.ltr, + child: inputWidget( + TranslationBase.of(context).phoneNumber, + isEnable: widget.isEnable, + widget.mobileNo ?? (isOthersSelected ? "" : "5xxxxxxxx"), + prefix: isOthersSelected ? null : countryCode + ) + ), + if (validationError != null) + Container( + width: double.infinity, + margin: EdgeInsets.only(top: 8), + child: Text( + validationError!, + style: TextStyle( + color: Colors.red, + fontSize: 12, + fontWeight: FontWeight.w500, + ), + ), + ), ], ); } Widget inputWidget(String _labelText, String _hintText, {String? prefix, bool isEnable = true, bool hasSelection = false}) { + // Check if "Others" is selected + bool isOthersSelected = countryCode == "0"; + return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), alignment: Alignment.center, @@ -73,8 +118,8 @@ class _PhoneNumberSelectorWidgetState extends State { borderRadius: BorderRadius.circular(15), color: Colors.white, border: Border.all( - color: Color(0xffefefef), - width: 1, + color: validationError != null ? Colors.red : Color(0xffefefef), + width: validationError != null ? 1.5 : 1, ), ), child: PopupMenuButton( @@ -99,8 +144,20 @@ class _PhoneNumberSelectorWidgetState extends State { controller: hasSelection ? null : textController, enabled: isEnable, scrollPadding: EdgeInsets.zero, - keyboardType: TextInputType.number, - onChanged: (value) => widget.onNumberChange!(value), + keyboardType: isOthersSelected ? TextInputType.phone : TextInputType.number, + onChanged: (value) { + // Validate the phone number + setState(() { + validationError = validatePhoneNumber(value); + }); + // Only call the callback if validation passes + if (validationError == null) { + widget.onNumberChange!(value); + } else { + // Call with empty value to invalidate the form + widget.onNumberChange!(""); + } + }, style: TextStyle( fontSize: 14, height: 21 / 14, @@ -135,6 +192,8 @@ class _PhoneNumberSelectorWidgetState extends State { border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, + errorBorder: InputBorder.none, + focusedErrorBorder: InputBorder.none, ), ), ], @@ -151,6 +210,11 @@ class _PhoneNumberSelectorWidgetState extends State { setState(() { this.countryCode = countryCode; _selectedType = countryCode; + // Clear the text field and validation error when switching to/from "Others" + if (countryCode == "0" || this.countryCode == "0") { + textController.clear(); + validationError = null; + } }); widget.onCountryChange!(countryCode); }, diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index ebb78a77..6c742943 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -265,15 +265,26 @@ class SMSOTP { startTimer(setState) { this.remainingTime--; - setState(() { - displayTime = this.getSecondsAsDigitalClock(this.remainingTime); - }); + // Check if the widget is still mounted before calling setState + try { + setState(() { + displayTime = this.getSecondsAsDigitalClock(this.remainingTime); + }); + } catch (e) { + // Widget is no longer mounted, stop the timer + return; + } timer = Future.delayed(Duration(seconds: 1), () { if (this.remainingTime > 0) { startTimer(setState); } else { - Navigator.pop(context); + // Check if context is still valid before trying to pop + try { + Navigator.pop(context); + } catch (e) { + // Context is no longer valid, ignore + } } }); }