mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
fix changes
This commit is contained in:
@ -34,6 +34,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
final TextEditingController forgetPasswordController = TextEditingController();
|
||||
final TextEditingController forgetOtp = TextEditingController();
|
||||
final forgetFormKey = GlobalKey<FormState>();
|
||||
final forgetEmailKey = GlobalKey<FormState>();
|
||||
final forgetRegionKey = GlobalKey<FormState>();
|
||||
late bool checkValidate = false;
|
||||
|
||||
Timer? _timer;
|
||||
@ -93,34 +95,36 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
|
||||
Future<void> changePassword(ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||
try {
|
||||
emit(LoadingForgetState());
|
||||
var response = await AuthenticationAPI.verifyOtp(
|
||||
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||
if (response == true) {
|
||||
await AuthenticationAPI.forgetPassword(
|
||||
password: forgetPasswordController.text, email: forgetEmailController.text);
|
||||
_timer?.cancel();
|
||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||
emit(SuccessForgetState());
|
||||
emit(LoadingForgetState());
|
||||
try {
|
||||
var response = await AuthenticationAPI.verifyOtp(
|
||||
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||
if (response == true) {
|
||||
await AuthenticationAPI.forgetPassword(
|
||||
password: forgetPasswordController.text,
|
||||
email: forgetEmailController.text);
|
||||
_timer?.cancel();
|
||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||
emit(SuccessForgetState());
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
if (errorMessage == 'this email is not registered') {
|
||||
validate = 'Invalid Credentials!';
|
||||
emit(AuthInitialState());
|
||||
} else if (errorMessage == "You entered wrong otp") {
|
||||
forgetValidate = 'Wrong one time password.';
|
||||
emit(AuthInitialState());
|
||||
} else if (errorMessage == "OTP expired") {
|
||||
forgetValidate = 'One time password has been expired.';
|
||||
emit(AuthInitialState());
|
||||
} else {
|
||||
validate = '';
|
||||
emit(AuthInitialState());
|
||||
}
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
if (errorMessage == 'this email is not registered') {
|
||||
validate = 'Invalid Credentials!';
|
||||
emit(AuthInitialState());
|
||||
} else if (errorMessage == "You entered wrong otp") {
|
||||
forgetValidate = 'Wrong one time password.';
|
||||
emit(AuthInitialState());
|
||||
} else if (errorMessage == "OTP expired") {
|
||||
forgetValidate = 'One time password has been expired.';
|
||||
emit(AuthInitialState());
|
||||
} else {
|
||||
validate = '';
|
||||
emit(AuthInitialState());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String? validateCode(String? value) {
|
||||
@ -231,9 +235,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
return 'Email is required';
|
||||
} else if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) {
|
||||
return 'Enter a valid email address';
|
||||
} else if (regionUuid == '') {
|
||||
return 'Please select your region';
|
||||
}
|
||||
// else if (regionUuid == '') {
|
||||
// return 'Please select your region';
|
||||
// }
|
||||
validate = '';
|
||||
return null;
|
||||
}
|
||||
@ -371,6 +376,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
try {
|
||||
emit(AuthLoading());
|
||||
regionUuid = event.val;
|
||||
add(CheckEnableEvent());
|
||||
emit(AuthInitialState());
|
||||
} catch (e) {
|
||||
emit(FailureForgetState(error: e.toString()));
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@ class HourPickerDialog extends StatefulWidget {
|
||||
|
||||
class _HourPickerDialogState extends State<HourPickerDialog> {
|
||||
late int _selectedHour;
|
||||
bool _isPm = false;
|
||||
bool _isPm = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -18,7 +18,7 @@ class _HourPickerDialogState extends State<HourPickerDialog> {
|
||||
_selectedHour = widget.initialTime.hour > 12
|
||||
? widget.initialTime.hour - 12
|
||||
: widget.initialTime.hour;
|
||||
_isPm = widget.initialTime.period == DayPeriod.pm;
|
||||
_isPm = widget.initialTime.period == DayPeriod.am;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -69,7 +69,7 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
||||
deviceId: device.uuid!,
|
||||
description: 'Child Lock',
|
||||
icon:
|
||||
state.status.childLock ? Assets.unlock : Assets.childLock,
|
||||
state.status.childLock ? Assets.childLock:Assets.unlock ,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
Reference in New Issue
Block a user