mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Removed prints and warnings
This commit is contained in:
@ -31,8 +31,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
|
||||
////////////////////////////// forget password //////////////////////////////////
|
||||
final TextEditingController forgetEmailController = TextEditingController();
|
||||
final TextEditingController forgetPasswordController =
|
||||
TextEditingController();
|
||||
final TextEditingController forgetPasswordController = TextEditingController();
|
||||
final TextEditingController forgetOtp = TextEditingController();
|
||||
final forgetFormKey = GlobalKey<FormState>();
|
||||
late bool checkValidate = false;
|
||||
@ -41,16 +40,13 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
int _remainingTime = 0;
|
||||
List<RegionModel>? regionList = [RegionModel(name: 'name', id: 'id')];
|
||||
|
||||
|
||||
Future _onStartTimer(
|
||||
StartTimerEvent event, Emitter<AuthState> emit) async {
|
||||
Future _onStartTimer(StartTimerEvent event, Emitter<AuthState> emit) async {
|
||||
if (_validateInputs(emit)) return;
|
||||
if (_timer != null && _timer!.isActive) {
|
||||
return;
|
||||
}
|
||||
_remainingTime = 1;
|
||||
add(UpdateTimerEvent(
|
||||
remainingTime: _remainingTime, isButtonEnabled: false));
|
||||
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
|
||||
try {
|
||||
forgetEmailValidate = '';
|
||||
_remainingTime = (await AuthenticationAPI.sendOtp(
|
||||
@ -59,13 +55,12 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
if (e.response!.statusCode == 400) {
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
print('sendOtp=$errorMessage');
|
||||
if (errorMessage == 'User not found') {
|
||||
validate='Invalid Credential';
|
||||
validate = 'Invalid Credential';
|
||||
emit(AuthInitialState());
|
||||
return 1;
|
||||
} else {
|
||||
validate='';
|
||||
validate = '';
|
||||
_remainingTime = errorData['data']['cooldown'] ?? 1;
|
||||
emit(AuthInitialState());
|
||||
}
|
||||
@ -75,7 +70,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
return 1;
|
||||
}
|
||||
emit(AuthInitialState());
|
||||
|
||||
} catch (e) {
|
||||
emit(AuthInitialState());
|
||||
|
||||
@ -88,8 +82,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
_timer?.cancel();
|
||||
add(const UpdateTimerEvent(remainingTime: 0, isButtonEnabled: true));
|
||||
} else {
|
||||
add(UpdateTimerEvent(
|
||||
remainingTime: _remainingTime, isButtonEnabled: false));
|
||||
add(UpdateTimerEvent(remainingTime: _remainingTime, isButtonEnabled: false));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -99,16 +92,14 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||
}
|
||||
|
||||
Future<void> changePassword(
|
||||
ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||
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);
|
||||
password: forgetPasswordController.text, email: forgetEmailController.text);
|
||||
_timer?.cancel();
|
||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||
emit(SuccessForgetState());
|
||||
@ -125,12 +116,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
} else if (errorMessage == "OTP expired") {
|
||||
forgetValidate = 'One time password has been expired.';
|
||||
emit(AuthInitialState());
|
||||
}else{
|
||||
validate='';
|
||||
} else {
|
||||
validate = '';
|
||||
emit(AuthInitialState());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,9 +131,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
|
||||
void _onUpdateTimer(UpdateTimerEvent event, Emitter<AuthState> emit) {
|
||||
emit(TimerState(
|
||||
isButtonEnabled: event.isButtonEnabled,
|
||||
remainingTime: event.remainingTime));
|
||||
emit(TimerState(isButtonEnabled: event.isButtonEnabled, remainingTime: event.remainingTime));
|
||||
}
|
||||
|
||||
///////////////////////////////////// login /////////////////////////////////////
|
||||
@ -176,9 +163,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
|
||||
token = await AuthenticationAPI.loginWithEmail(
|
||||
model: LoginWithEmailModel(
|
||||
email: event.username,
|
||||
password: event.password,
|
||||
regionUuid: event.regionUuid),
|
||||
email: event.username, password: event.password, regionUuid: event.regionUuid),
|
||||
);
|
||||
} catch (failure) {
|
||||
validate = 'Invalid Credentials!';
|
||||
@ -188,8 +173,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
|
||||
if (token.accessTokenIsNotEmpty) {
|
||||
FlutterSecureStorage storage = const FlutterSecureStorage();
|
||||
await storage.write(
|
||||
key: Token.loginAccessTokenKey, value: token.accessToken);
|
||||
await storage.write(key: Token.loginAccessTokenKey, value: token.accessToken);
|
||||
const FlutterSecureStorage().write(
|
||||
key: UserModel.userUuidKey,
|
||||
value: Token.decodeToken(token.accessToken)['uuid'].toString());
|
||||
@ -207,9 +191,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
|
||||
checkBoxToggle(
|
||||
CheckBoxEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
CheckBoxEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
emit(AuthLoading());
|
||||
isChecked = event.newValue!;
|
||||
add(CheckEnableEvent());
|
||||
@ -346,14 +330,12 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
static Future<String> getTokenAndValidate() async {
|
||||
try {
|
||||
const storage = FlutterSecureStorage();
|
||||
final firstLaunch = await SharedPreferencesHelper.readBoolFromSP(
|
||||
StringsManager.firstLaunch) ??
|
||||
true;
|
||||
final firstLaunch =
|
||||
await SharedPreferencesHelper.readBoolFromSP(StringsManager.firstLaunch) ?? true;
|
||||
if (firstLaunch) {
|
||||
storage.deleteAll();
|
||||
}
|
||||
await SharedPreferencesHelper.saveBoolToSP(
|
||||
StringsManager.firstLaunch, false);
|
||||
await SharedPreferencesHelper.saveBoolToSP(StringsManager.firstLaunch, false);
|
||||
final value = await storage.read(key: Token.loginAccessTokenKey) ?? '';
|
||||
if (value.isEmpty) {
|
||||
return 'Token not found';
|
||||
@ -405,9 +387,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
final String formattedTime = [
|
||||
if (days > 0) '${days}d', // Append 'd' for days
|
||||
if (days > 0 || hours > 0)
|
||||
hours
|
||||
.toString()
|
||||
.padLeft(2, '0'), // Show hours if there are days or hours
|
||||
hours.toString().padLeft(2, '0'), // Show hours if there are days or hours
|
||||
minutes.toString().padLeft(2, '0'),
|
||||
seconds.toString().padLeft(2, '0'),
|
||||
].join(':');
|
||||
@ -416,9 +396,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
|
||||
bool checkEnable(
|
||||
CheckEnableEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
CheckEnableEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
emit(AuthLoading());
|
||||
checkValidate = isChecked == true &&
|
||||
loginPasswordController.text.isNotEmpty &&
|
||||
@ -429,18 +409,18 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
|
||||
changeValidate(
|
||||
ChangeValidateEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
ChangeValidateEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
emit(AuthLoading());
|
||||
validate = '';
|
||||
emit(LoginInitial());
|
||||
}
|
||||
|
||||
changeForgetValidate(
|
||||
ChangeValidateEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
ChangeValidateEvent event,
|
||||
Emitter<AuthState> emit,
|
||||
) {
|
||||
emit(AuthLoading());
|
||||
forgetValidate = '';
|
||||
emit(LoginInitial());
|
||||
|
@ -33,7 +33,6 @@ class DevicesManagementApi {
|
||||
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
print('getDeviceStatus$json');
|
||||
return DeviceStatus.fromJson(json);
|
||||
},
|
||||
);
|
||||
@ -66,8 +65,7 @@ class DevicesManagementApi {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||
String gatewayId) async {
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||
showServerMessage: false,
|
||||
@ -98,9 +96,7 @@ class DevicesManagementApi {
|
||||
|
||||
static Future<DeviceReport> getDeviceReports(String uuid, String code) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.getDeviceLogs
|
||||
.replaceAll('{uuid}', uuid)
|
||||
.replaceAll('{code}', code),
|
||||
path: ApiEndpoints.getDeviceLogs.replaceAll('{uuid}', uuid).replaceAll('{code}', code),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
|
Reference in New Issue
Block a user