@ -59,7 +59,8 @@ class AuthenticationViewModel extends ChangeNotifier {
required NavigationService navigationService ,
required NavigationService navigationService ,
required CacheService cacheService ,
required CacheService cacheService ,
required LocalAuthService localAuthService ,
required LocalAuthService localAuthService ,
} ) : _navigationService = navigationService ,
} )
: _navigationService = navigationService ,
_dialogService = dialogService ,
_dialogService = dialogService ,
_errorHandlerService = errorHandlerService ,
_errorHandlerService = errorHandlerService ,
_appState = appState ,
_appState = appState ,
@ -204,13 +205,13 @@ class AuthenticationViewModel extends ChangeNotifier {
final result = await _authenticationRepo . selectDeviceByImei ( firebaseToken: firebaseToken ) ;
final result = await _authenticationRepo . selectDeviceByImei ( firebaseToken: firebaseToken ) ;
result . fold (
result . fold (
( failure ) async {
( failure ) async {
/ / LoadingUtils . hideFullScreenLoader ( ) ;
/ / LoadingUtils . hideFullScreenLoader ( ) ;
/ / await _errorHandlerService . handleError ( failure: failure ) ;
/ / await _errorHandlerService . handleError ( failure: failure ) ;
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
_navigationService . pushPage ( page: LoginScreen ( ) ) ;
_navigationService . pushPage ( page: LoginScreen ( ) ) ;
} ,
} ,
( apiResponse ) {
( apiResponse ) {
/ / LoadingUtils . hideFullScreenLoader ( ) ;
/ / LoadingUtils . hideFullScreenLoader ( ) ;
log ( " apiResponse: ${ apiResponse . data . toString ( ) } " ) ;
log ( " apiResponse: ${ apiResponse . data . toString ( ) } " ) ;
log ( " messageStatus: ${ apiResponse . messageStatus . toString ( ) } " ) ;
log ( " messageStatus: ${ apiResponse . messageStatus . toString ( ) } " ) ;
@ -300,7 +301,8 @@ class AuthenticationViewModel extends ChangeNotifier {
final result = await _authenticationRepo . checkPatientAuthentication ( checkPatientAuthenticationReq: checkPatientAuthenticationReq ) ;
final result = await _authenticationRepo . checkPatientAuthentication ( checkPatientAuthenticationReq: checkPatientAuthenticationReq ) ;
result . fold (
result . fold (
( failure ) async = > await _errorHandlerService . handleError (
( failure ) async = >
await _errorHandlerService . handleError (
failure: failure ,
failure: failure ,
onUnHandledFailure: ( failure ) async {
onUnHandledFailure: ( failure ) async {
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
@ -314,7 +316,7 @@ class AuthenticationViewModel extends ChangeNotifier {
_navigationService . pop ( ) ;
_navigationService . pop ( ) ;
} ) ;
} ) ;
} ) ,
} ) ,
( apiResponse ) async {
( apiResponse ) async {
if ( apiResponse . messageStatus = = 2 ) {
if ( apiResponse . messageStatus = = 2 ) {
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
await _dialogService . showErrorBottomSheet ( message: apiResponse . errorMessage ? ? " ErrorEmpty " , onOkPressed: ( ) { } ) ;
await _dialogService . showErrorBottomSheet ( message: apiResponse . errorMessage ? ? " ErrorEmpty " , onOkPressed: ( ) { } ) ;
@ -357,8 +359,8 @@ class AuthenticationViewModel extends ChangeNotifier {
patientOutSA: isForRegister
patientOutSA: isForRegister
? isPatientOutsideSA ( request: payload )
? isPatientOutsideSA ( request: payload )
: selectedCountrySignup . countryCode = = CountryEnum . saudiArabia
: selectedCountrySignup . countryCode = = CountryEnum . saudiArabia
? false
? false
: true ,
: true ,
payload: payload ,
payload: payload ,
) ;
) ;
@ -372,8 +374,8 @@ class AuthenticationViewModel extends ChangeNotifier {
final resultEither = await _authenticationRepo . sendActivationCodeRepo ( sendActivationCodeReq: request , isRegister: checkIsUserComingForRegister ( request: payload ) , languageID: ' er ' ) ;
final resultEither = await _authenticationRepo . sendActivationCodeRepo ( sendActivationCodeReq: request , isRegister: checkIsUserComingForRegister ( request: payload ) , languageID: ' er ' ) ;
resultEither . fold (
resultEither . fold (
( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) ,
( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) ,
( apiResponse ) async {
( apiResponse ) async {
if ( apiResponse . messageStatus = = 2 ) {
if ( apiResponse . messageStatus = = 2 ) {
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
await _dialogService . showCommonBottomSheetWithoutH (
await _dialogService . showCommonBottomSheetWithoutH (
@ -407,27 +409,27 @@ class AuthenticationViewModel extends ChangeNotifier {
bool isForRegister = ( _appState . getUserRegistrationPayload . healthId ! = null | | _appState . getUserRegistrationPayload . patientOutSa = = true | | _appState . getUserRegistrationPayload . patientOutSa = = 1 ) ;
bool isForRegister = ( _appState . getUserRegistrationPayload . healthId ! = null | | _appState . getUserRegistrationPayload . patientOutSa = = true | | _appState . getUserRegistrationPayload . patientOutSa = = 1 ) ;
final request = RequestUtils . getCommonRequestWelcome (
final request = RequestUtils . getCommonRequestWelcome (
phoneNumber: phoneNumberController . text ,
phoneNumber: phoneNumberController . text ,
otpTypeEnum: otpTypeEnum ,
otpTypeEnum: otpTypeEnum ,
deviceToken: _appState . deviceToken ,
deviceToken: _appState . deviceToken ,
/ / patientOutSA: _appState . getUserRegistrationPayload . projectOutSa = = 1 ? true : false ,
/ / patientOutSA: _appState . getUserRegistrationPayload . projectOutSa = = 1 ? true : false ,
patientOutSA: isForRegister
patientOutSA: isForRegister
? _appState . getUserRegistrationPayload . projectOutSa = = true
? _appState . getUserRegistrationPayload . projectOutSa = = true
? true
? true
: false
: false
: _appState . getSelectDeviceByImeiRespModelElement ! = null
: _appState . getSelectDeviceByImeiRespModelElement ! = null
? _appState . getSelectDeviceByImeiRespModelElement ! . outSa !
? _appState . getSelectDeviceByImeiRespModelElement ! . outSa !
: selectedCountrySignup = = CountryEnum . saudiArabia
: selectedCountrySignup = = CountryEnum . saudiArabia
? false
? false
: true ,
: true ,
loginTokenID: _appState . appAuthToken ,
loginTokenID: _appState . appAuthToken ,
registeredData: isForRegister ? _appState . getUserRegistrationPayload : null ,
registeredData: isForRegister ? _appState . getUserRegistrationPayload : null ,
nationIdText: nationalIdController . text ,
nationIdText: nationalIdController . text ,
countryCode: _appState . getSelectDeviceByImeiRespModelElement ! = null & & _appState . getSelectDeviceByImeiRespModelElement ! . outSa = = true
countryCode: _appState . getSelectDeviceByImeiRespModelElement ! = null & & _appState . getSelectDeviceByImeiRespModelElement ! . outSa = = true
? CountryEnum . unitedArabEmirates . countryCode
? CountryEnum . unitedArabEmirates . countryCode
: selectedCountrySignup . countryCode ,
: selectedCountrySignup . countryCode ,
/ / TODO: Error Here IN Zip Code .
/ / TODO: Error Here IN Zip Code .
loginType: loginTypeEnum . toInt )
loginType: loginTypeEnum . toInt )
. toJson ( ) ;
. toJson ( ) ;
LoaderBottomSheet . showLoader ( ) ;
LoaderBottomSheet . showLoader ( ) ;
if ( isForRegister ) {
if ( isForRegister ) {
@ -443,7 +445,8 @@ class AuthenticationViewModel extends ChangeNotifier {
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
resultEither . fold (
resultEither . fold (
( failure ) async = > await _errorHandlerService . handleError (
( failure ) async = >
await _errorHandlerService . handleError (
failure: failure ,
failure: failure ,
onUnHandledFailure: ( failure ) async {
onUnHandledFailure: ( failure ) async {
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
@ -470,7 +473,8 @@ class AuthenticationViewModel extends ChangeNotifier {
final resultEither = await _authenticationRepo . checkActivationCodeRepo ( newRequest: CheckActivationCodeRegisterReq . fromJson ( request ) , activationCode: activationCode , isRegister: false ) ;
final resultEither = await _authenticationRepo . checkActivationCodeRepo ( newRequest: CheckActivationCodeRegisterReq . fromJson ( request ) , activationCode: activationCode , isRegister: false ) ;
resultEither . fold (
resultEither . fold (
( failure ) async = > await _errorHandlerService . handleError (
( failure ) async = >
await _errorHandlerService . handleError (
failure: failure ,
failure: failure ,
onUnHandledFailure: ( failure ) async {
onUnHandledFailure: ( failure ) async {
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
@ -654,15 +658,15 @@ class AuthenticationViewModel extends ChangeNotifier {
bool isOutSidePatient = selectedCountrySignup . countryCode = = CountryEnum . unitedArabEmirates . countryCode ? true : false ;
bool isOutSidePatient = selectedCountrySignup . countryCode = = CountryEnum . unitedArabEmirates . countryCode ? true : false ;
LoaderBottomSheet . showLoader ( ) ;
LoaderBottomSheet . showLoader ( ) ;
final request = await RequestUtils . getPatientAuthenticationRequest (
final request = await RequestUtils . getPatientAuthenticationRequest (
phoneNumber: phoneNumberController . text ,
phoneNumber: phoneNumberController . text ,
nationId: nationalIdController . text ,
nationId: nationalIdController . text ,
patientOutSA: isOutSidePatient ,
patientOutSA: isOutSidePatient ,
otpTypeEnum: otpTypeEnum ,
otpTypeEnum: otpTypeEnum ,
isForRegister: true ,
isForRegister: true ,
patientId: 0 ,
patientId: 0 ,
zipCode: selectedCountrySignup . countryCode ,
zipCode: selectedCountrySignup . countryCode ,
calenderType: calenderType ,
calenderType: calenderType ,
dob: dob )
dob: dob )
. toJson ( ) ;
. toJson ( ) ;
var nRequest = Map < String , dynamic > . from ( request ) ;
var nRequest = Map < String , dynamic > . from ( request ) ;
@ -798,22 +802,22 @@ class AuthenticationViewModel extends ChangeNotifier {
Future < void > insertPatientIMEIData ( int loginType ) async {
Future < void > insertPatientIMEIData ( int loginType ) async {
final resultEither = await _authenticationRepo . insertPatientIMEIData (
final resultEither = await _authenticationRepo . insertPatientIMEIData (
patientIMEIDataRequest: PatientInsertDeviceImei (
patientIMEIDataRequest: PatientInsertDeviceImei (
imei: _appState . deviceToken ,
imei: _appState . deviceToken ,
deviceTypeId: _appState . getDeviceTypeID ( ) ,
deviceTypeId: _appState . getDeviceTypeID ( ) ,
patientId: _appState . getAuthenticatedUser ( ) ! . patientId ! ,
patientId: _appState . getAuthenticatedUser ( ) ! . patientId ! ,
patientIdentificationNo: _appState . getAuthenticatedUser ( ) ! . patientIdentificationNo ! ,
patientIdentificationNo: _appState . getAuthenticatedUser ( ) ! . patientIdentificationNo ! ,
identificationNo: _appState . getAuthenticatedUser ( ) ! . patientIdentificationNo ! ,
identificationNo: _appState . getAuthenticatedUser ( ) ! . patientIdentificationNo ! ,
firstName: _appState . getAuthenticatedUser ( ) ! . firstName ! ,
firstName: _appState . getAuthenticatedUser ( ) ! . firstName ! ,
lastName: _appState . getAuthenticatedUser ( ) ! . lastName ! ,
lastName: _appState . getAuthenticatedUser ( ) ! . lastName ! ,
patientTypeId: _appState . getAuthenticatedUser ( ) ! . patientType ,
patientTypeId: _appState . getAuthenticatedUser ( ) ! . patientType ,
mobileNo: _appState . getAuthenticatedUser ( ) ! . mobileNumber ! ,
mobileNo: _appState . getAuthenticatedUser ( ) ! . mobileNumber ! ,
logInTypeId: loginType ,
logInTypeId: loginType ,
patientOutSa: _appState . getAuthenticatedUser ( ) ! . outSa ! ,
patientOutSa: _appState . getAuthenticatedUser ( ) ! . outSa ! ,
outSa: _appState . getAuthenticatedUser ( ) ! . outSa = = 1 ? true : false ,
outSa: _appState . getAuthenticatedUser ( ) ! . outSa = = 1 ? true : false ,
biometricEnabled: loginType = = 1 | | loginType = = 2 ? false : true ,
biometricEnabled: loginType = = 1 | | loginType = = 2 ? false : true ,
firstNameN: _appState . getAuthenticatedUser ( ) ! . firstNameN ,
firstNameN: _appState . getAuthenticatedUser ( ) ! . firstNameN ,
lastNameN: _appState . getAuthenticatedUser ( ) ! . lastNameN ,
lastNameN: _appState . getAuthenticatedUser ( ) ! . lastNameN ,
) . toJson ( ) ) ;
) . toJson ( ) ) ;
resultEither . fold ( ( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) , ( apiResponse ) async {
resultEither . fold ( ( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) , ( apiResponse ) async {
if ( apiResponse . messageStatus = = 1 ) {
if ( apiResponse . messageStatus = = 1 ) {
log ( " Insert IMEI Success " ) ;
log ( " Insert IMEI Success " ) ;
@ -827,20 +831,20 @@ class AuthenticationViewModel extends ChangeNotifier {
Future < void > insertPatientDeviceData ( int loginType ) async {
Future < void > insertPatientDeviceData ( int loginType ) async {
final resultEither = await _authenticationRepo . insertPatientDeviceData (
final resultEither = await _authenticationRepo . insertPatientDeviceData (
patientDeviceDataRequest: InsertPatientMobileDeviceInfo (
patientDeviceDataRequest: InsertPatientMobileDeviceInfo (
deviceToken: _appState . deviceToken ,
deviceToken: _appState . deviceToken ,
deviceTypeId: _appState . getDeviceTypeID ( ) ,
deviceTypeId: _appState . getDeviceTypeID ( ) ,
patientId: _appState . getAuthenticatedUser ( ) ! . patientId ! ,
patientId: _appState . getAuthenticatedUser ( ) ! . patientId ! ,
patientTypeId: _appState . getAuthenticatedUser ( ) ! . patientType ,
patientTypeId: _appState . getAuthenticatedUser ( ) ! . patientType ,
patientOutSa: _appState . getAuthenticatedUser ( ) ! . outSa ! ,
patientOutSa: _appState . getAuthenticatedUser ( ) ! . outSa ! ,
loginType: loginType ,
loginType: loginType ,
languageId: _appState . getLanguageID ( ) ,
languageId: _appState . getLanguageID ( ) ,
latitude: _appState . userLat ,
latitude: _appState . userLat ,
longitude: _appState . userLong ,
longitude: _appState . userLong ,
voipToken: " " ,
voipToken: " " ,
deviceType: _appState . deviceTypeID ,
deviceType: _appState . deviceTypeID ,
patientMobileNumber: _appState . getAuthenticatedUser ( ) ! . mobileNumber ,
patientMobileNumber: _appState . getAuthenticatedUser ( ) ! . mobileNumber ,
nationalId: _appState . getAuthenticatedUser ( ) ! . patientIdentificationNo ,
nationalId: _appState . getAuthenticatedUser ( ) ! . patientIdentificationNo ,
gender: _appState . getAuthenticatedUser ( ) ! . gender )
gender: _appState . getAuthenticatedUser ( ) ! . gender )
. toJson ( ) ) ;
. toJson ( ) ) ;
resultEither . fold ( ( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) , ( apiResponse ) async {
resultEither . fold ( ( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) , ( apiResponse ) async {
if ( apiResponse . messageStatus = = 1 ) {
if ( apiResponse . messageStatus = = 1 ) {
@ -854,18 +858,18 @@ class AuthenticationViewModel extends ChangeNotifier {
Future < void > getPatientDeviceData ( int loginType ) async {
Future < void > getPatientDeviceData ( int loginType ) async {
final resultEither = await _authenticationRepo . getPatientDeviceData (
final resultEither = await _authenticationRepo . getPatientDeviceData (
patientDeviceDataRequest: GetUserMobileDeviceData (
patientDeviceDataRequest: GetUserMobileDeviceData (
deviceToken: _appState . deviceToken ,
deviceToken: _appState . deviceToken ,
deviceTypeId: _appState . getDeviceTypeID ( ) ,
deviceTypeId: _appState . getDeviceTypeID ( ) ,
patientId: _appState . getSelectDeviceByImeiRespModelElement ! . patientId ! ,
patientId: _appState . getSelectDeviceByImeiRespModelElement ! . patientId ! ,
patientType: _appState . getSelectDeviceByImeiRespModelElement ! . patientType ,
patientType: _appState . getSelectDeviceByImeiRespModelElement ! . patientType ,
patientOutSa: _appState . getSelectDeviceByImeiRespModelElement ! . outSa = = true ? 1 : 0 ,
patientOutSa: _appState . getSelectDeviceByImeiRespModelElement ! . outSa = = true ? 1 : 0 ,
loginType: loginType ,
loginType: loginType ,
languageId: _appState . getLanguageID ( ) ,
languageId: _appState . getLanguageID ( ) ,
latitude: _appState . userLat ,
latitude: _appState . userLat ,
longitude: _appState . userLong ,
longitude: _appState . userLong ,
mobileNo: _appState . getSelectDeviceByImeiRespModelElement ! . mobile ! ,
mobileNo: _appState . getSelectDeviceByImeiRespModelElement ! . mobile ! ,
patientMobileNumber: int . parse ( _appState . getSelectDeviceByImeiRespModelElement ! . mobile ! ) ,
patientMobileNumber: int . parse ( _appState . getSelectDeviceByImeiRespModelElement ! . mobile ! ) ,
nationalId: _appState . getSelectDeviceByImeiRespModelElement ! . identificationNo )
nationalId: _appState . getSelectDeviceByImeiRespModelElement ! . identificationNo )
. toJson ( ) ) ;
. toJson ( ) ) ;
resultEither . fold ( ( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) , ( apiResponse ) async {
resultEither . fold ( ( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) , ( apiResponse ) async {
if ( apiResponse . messageStatus = = 1 ) {
if ( apiResponse . messageStatus = = 1 ) {
@ -881,7 +885,7 @@ class AuthenticationViewModel extends ChangeNotifier {
message: apiResponse . errorMessage ? ? " " ,
message: apiResponse . errorMessage ? ? " " ,
label: LocaleKeys . notice . tr ( ) ,
label: LocaleKeys . notice . tr ( ) ,
onOkPressed: ( ) {
onOkPressed: ( ) {
_dialogService . showPhoneNumberPickerSheet ( onSMSPress: ( ) {
_dialogService . showPhoneNumberPickerSheet ( label:" Where would you like to receive OTP? " , message: " Please select from the below options to receive OTP. " , onSMSPress: ( ) {
checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . sms ) ;
checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . sms ) ;
} , onWhatsappPress: ( ) {
} , onWhatsappPress: ( ) {
checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
checkUserAuthentication ( otpTypeEnum: OTPTypeEnum . whatsapp ) ;
@ -910,8 +914,8 @@ class AuthenticationViewModel extends ChangeNotifier {
List < ProjectDetailListModel > projectDetailListModel = [ ] ;
List < ProjectDetailListModel > projectDetailListModel = [ ] ;
resultEither . fold (
resultEither . fold (
( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) ,
( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) ,
( apiResponse ) async {
( apiResponse ) async {
if ( apiResponse . messageStatus = = 2 ) {
if ( apiResponse . messageStatus = = 2 ) {
await _dialogService . showErrorBottomSheet ( message: apiResponse . errorMessage ? ? " ErrorEmpty " ) ;
await _dialogService . showErrorBottomSheet ( message: apiResponse . errorMessage ? ? " ErrorEmpty " ) ;
} else {
} else {