otp screen & register Uae & resend Activation Code.

pull/45/head
aamir-csol 1 month ago
parent 28a95959e0
commit 3b1b51ef6f

@ -57,7 +57,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,
@ -202,13 +203,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()}");
@ -298,7 +299,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();
@ -312,7 +314,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: () {});
@ -355,8 +357,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,
); );
@ -370,8 +372,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(
@ -405,27 +407,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) {
@ -441,7 +443,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();
@ -468,7 +471,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();
@ -652,15 +656,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);
@ -796,22 +800,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");
@ -825,20 +829,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) {
@ -852,18 +856,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) {
@ -878,7 +882,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);
@ -907,8 +911,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 {

@ -109,11 +109,11 @@ void showCommonBottomSheetWithoutHeight(
required Widget child, required Widget child,
required VoidCallback callBackFunc, required VoidCallback callBackFunc,
String title = "", String title = "",
bool isCloseButtonVisible = true,
bool isCloseButtonVisible = true, bool isFullScreen = true,
bool isFullScreen = true, bool isDismissible = true,
bool isDismissible = true, Widget? titleWidget,
Widget? titleWidget,}) { }) {
showModalBottomSheet<String>( showModalBottomSheet<String>(
sheetAnimationStyle: AnimationStyle( sheetAnimationStyle: AnimationStyle(
duration: Duration(milliseconds: 500), // Custom animation duration duration: Duration(milliseconds: 500), // Custom animation duration
@ -141,7 +141,7 @@ void showCommonBottomSheetWithoutHeight(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
titleWidget ?? title.toText20(weight: FontWeight.w600), titleWidget ?? Expanded(child: title.toText20(weight: FontWeight.w600)),
Utils.buildSvgWithAssets(icon: AppAssets.close_bottom_sheet_icon, iconColor: Color(0xff2B353E)).onPress(() { Utils.buildSvgWithAssets(icon: AppAssets.close_bottom_sheet_icon, iconColor: Color(0xff2B353E)).onPress(() {
Navigator.of(context).pop(); Navigator.of(context).pop();
}), }),

Loading…
Cancel
Save