@ -108,6 +108,7 @@ class AuthenticationViewModel extends ChangeNotifier {
Future < void > clearDefaultInputValues ( ) async {
nationalIdController . clear ( ) ;
phoneNumberController . clear ( ) ;
emailController . clear ( ) ;
dobController . clear ( ) ;
maritalStatus = null ;
genderType = null ;
@ -324,7 +325,8 @@ class AuthenticationViewModel extends ChangeNotifier {
) ;
}
Future < void > sendActivationCode ( { required OTPTypeEnum otpTypeEnum , required String nationalIdOrFileNumber , required String phoneNumber , required bool isForRegister , dynamic payload } ) async {
Future < void > sendActivationCode (
{ required OTPTypeEnum otpTypeEnum , required String nationalIdOrFileNumber , required String phoneNumber , required bool isForRegister , dynamic payload , bool isComingFromResendOTP = false } ) async {
var request = RequestUtils . getCommonRequestSendActivationCode (
otpTypeEnum: otpTypeEnum ,
mobileNumber: phoneNumber ,
@ -364,7 +366,7 @@ class AuthenticationViewModel extends ChangeNotifier {
} else {
if ( apiResponse . data ! = null & & apiResponse . data [ ' isSMSSent ' ] = = true ) {
LoaderBottomSheet . hideLoader ( ) ;
navigateToOTPScreen ( otpTypeEnum: otpTypeEnum , phoneNumber: phoneNumber ) ;
if ( ! isComingFromResendOTP ) navigateToOTPScreen ( otpTypeEnum: otpTypeEnum , phoneNumber: phoneNumber , isComingFromRegister: checkIsUserComingForRegister ( request: payload ) , payload: payload ) ;
} else {
/ / TODO: Handle isSMSSent false
/ / navigateToOTPScreen ( otpTypeEnum: otpTypeEnum , phoneNumber: phoneNumber ) ;
@ -386,8 +388,9 @@ class AuthenticationViewModel extends ChangeNotifier {
required String ? activationCode ,
required OTPTypeEnum otpTypeEnum ,
required Function ( String ? message ) onWrongActivationCode ,
Function ( ) ? onResendActivation ,
} ) async {
bool isForRegister = ( _appState . getUserRegistrationPayload . healthId ! = null | | _appState . getUserRegistrationPayload . patientOutSa = = true ) ;
bool isForRegister = ( _appState . getUserRegistrationPayload . healthId ! = null | | _appState . getUserRegistrationPayload . patientOutSa = = true | | _appState . getUserRegistrationPayload . patientOutSa = = 1 ) ;
final request = RequestUtils . getCommonRequestWelcome (
phoneNumber: phoneNumberController . text ,
@ -553,20 +556,27 @@ class AuthenticationViewModel extends ChangeNotifier {
_navigationService . pushAndReplace ( AppRoutes . landingScreen ) ;
}
Future < void > navigateToOTPScreen ( { required OTPTypeEnum otpTypeEnum , required String phoneNumber }) async {
Future < void > navigateToOTPScreen ( { required OTPTypeEnum otpTypeEnum , required String phoneNumber , required bool isComingFromRegister , dynamic payload }) async {
_navigationService . pushToOtpScreen (
phoneNumber: phoneNumber ,
checkActivationCode: ( int activationCode ) async {
await checkActivationCode (
activationCode: activationCode . toString ( ) ,
activationCode: activationCode . toString ( ) ,
otpTypeEnum: otpTypeEnum ,
onWrongActivationCode: ( String ? value ) {
onWrongActivationCode ( message: value ) ;
} ,
) ;
} ,
onResendOTPPressed: ( String phoneNumber ) async {
await sendActivationCode (
otpTypeEnum: otpTypeEnum ,
onWrongActivationCode: ( String ? value ) {
onWrongActivationCode ( message: value ) ;
} ) ;
/ / Navigator . of ( context ) . push ( MaterialPageRoute ( builder: ( BuildContext context ) = > RegisterNewStep2 ( null , { " nationalID " : " 12345678654321 " } ) ) ) ;
phoneNumber: phoneNumberController . text ,
nationalIdOrFileNumber: nationalIdController . text ,
isForRegister: isComingFromRegister ,
isComingFromResendOTP: true ,
payload: payload ) ;
} ,
onResendOTPPressed: ( String phoneNumber ) { } ,
) ;
}
@ -649,19 +659,18 @@ class AuthenticationViewModel extends ChangeNotifier {
}
Future < void > onRegistrationComplete ( ) async {
LoaderBottomSheet . showLoader ( ) ;
var request = RequestUtils . getUserSignupCompletionRequest ( fullName: nameController . text , emailAddress: emailController . text , gender: genderType , maritalStatus: maritalStatus ) ;
/ /
print ( " ============= Final Payload =============== " ) ;
print ( request ) ;
print ( " =================== ==================== " ) ;
final resultEither = await _authenticationRepo . registerUser ( registrationPayloadDataModelRequest: request ) ;
resultEither . fold ( ( failure ) async = > await _errorHandlerService . handleError ( failure: failure ) , ( apiResponse ) async {
if ( apiResponse . data is String ) {
/ / TODO: This Section Need to Be Testing .
_dialogService . showExceptionBottomSheet ( message: apiResponse . data , onOkPressed: ( ) { } , onCancelPressed: ( ) { } ) ;
/ / TODO: Here We Need to Show a Dialog Of Something in the case of Fail With OK and Cancel and the Display Variable WIll be result .
} else {
print ( apiResponse . data as Map < String , dynamic > ) ;
if ( apiResponse . data [ " MessageStatus " ] = = 1 ) {
LoaderBottomSheet . hideLoader ( ) ;
/ / TODO: Here We Need to Show a Dialog Of Something in the case of Success .
await clearDefaultInputValues ( ) ; / / This will Clear All Default Values Of User .
_navigationService . pushAndReplace ( AppRoutes . loginScreen ) ;
@ -722,8 +731,6 @@ class AuthenticationViewModel extends ChangeNotifier {
} else {
isOutSideSa = false ;
}
print ( isOutSideSa ) ;
return isOutSideSa ;
}