pull/28/head
haroon amjad 2 months ago
parent 3a649bca35
commit d87562caf5

@ -65,7 +65,7 @@ class RequestUtils {
required String? deviceToken, required String? deviceToken,
required bool patientOutSA, required bool patientOutSA,
required String? loginTokenID, required String? loginTokenID,
required RegistrationDataModelPayload registeredData, RegistrationDataModelPayload? registeredData,
int? patientId, int? patientId,
required String nationIdText, required String nationIdText,
required String countryCode, required String countryCode,

@ -82,7 +82,7 @@ class AuthenticationViewModel extends ChangeNotifier {
String errorMsg = ''; String errorMsg = '';
final FocusNode myFocusNode = FocusNode(); final FocusNode myFocusNode = FocusNode();
var healthId; var healthId;
int getDeviceLastLogin =1; int getDeviceLastLogin = 1;
Future<void> onLoginPressed() async { Future<void> onLoginPressed() async {
try { try {
@ -297,12 +297,11 @@ class AuthenticationViewModel extends ChangeNotifier {
} else if (apiResponse.messageStatus == 1) { } else if (apiResponse.messageStatus == 1) {
if (apiResponse.data['isSMSSent']) { if (apiResponse.data['isSMSSent']) {
_appState.setAppAuthToken = apiResponse.data['LogInTokenID']; _appState.setAppAuthToken = apiResponse.data['LogInTokenID'];
await sendActivationCode( await sendActivationCode(
otpTypeEnum: otpTypeEnum, otpTypeEnum: otpTypeEnum,
phoneNumber: phoneNumberController.text, phoneNumber: phoneNumberController.text,
nationalIdOrFileNumber: nationalIdController.text, nationalIdOrFileNumber: nationalIdController.text,
); );
} else { } else {
if (apiResponse.data['IsAuthenticated']) { if (apiResponse.data['IsAuthenticated']) {
await checkActivationCode( await checkActivationCode(
@ -310,7 +309,6 @@ class AuthenticationViewModel extends ChangeNotifier {
onWrongActivationCode: (String? message) {}, onWrongActivationCode: (String? message) {},
activationCode: null, //todo silent login case halded on the repo itself.. activationCode: null, //todo silent login case halded on the repo itself..
); );
} }
} }
} }
@ -325,10 +323,13 @@ class AuthenticationViewModel extends ChangeNotifier {
selectedLoginType: otpTypeEnum.toInt(), selectedLoginType: otpTypeEnum.toInt(),
zipCode: selectedCountrySignup.countryCode, zipCode: selectedCountrySignup.countryCode,
nationalId: int.parse(nationalIdOrFileNumber), nationalId: int.parse(nationalIdOrFileNumber),
isFileNo: isPatientHasFile(request: payload), // isFileNo: isPatientHasFile(request: payload),
isFileNo: false,
patientId: 0, patientId: 0,
isForRegister: checkIsUserComingForRegister(request: payload), isForRegister: false,
patientOutSA: isPatientOutsideSA(request: payload), // isForRegister: checkIsUserComingForRegister(request: payload),
patientOutSA: selectedCountrySignup.countryCode == CountryEnum.saudiArabia ? false : true,
// patientOutSA: isPatientOutsideSA(request: payload),
payload: payload); payload: payload);
// TODO: GET APP SMS SIGNATURE HERE // TODO: GET APP SMS SIGNATURE HERE
@ -373,19 +374,25 @@ class AuthenticationViewModel extends ChangeNotifier {
required OTPTypeEnum otpTypeEnum, required OTPTypeEnum otpTypeEnum,
required Function(String? message) onWrongActivationCode, required Function(String? message) onWrongActivationCode,
}) async { }) async {
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
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
? _appState.getUserRegistrationPayload.projectOutSa == 1
? true
: false
: _appState.getSelectDeviceByImeiRespModelElement!.outSa!,
loginTokenID: _appState.appAuthToken, loginTokenID: _appState.appAuthToken,
registeredData: _appState.getUserRegistrationPayload, registeredData: isForRegister ? _appState.getUserRegistrationPayload : null,
nationIdText: nationalIdController.text, nationIdText: nationalIdController.text,
countryCode: selectedCountrySignup.countryCode, countryCode: selectedCountrySignup.countryCode,
loginType: loginTypeEnum.toInt) loginType: loginTypeEnum.toInt)
.toJson(); .toJson();
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
if (isForRegister) { if (isForRegister) {
if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob; if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob;
request['HealthId'] = _appState.getUserRegistrationPayload.healthId; request['HealthId'] = _appState.getUserRegistrationPayload.healthId;

Loading…
Cancel
Save