mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Hide region field
This commit is contained in:
@ -52,7 +52,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
try {
|
try {
|
||||||
forgetEmailValidate = '';
|
forgetEmailValidate = '';
|
||||||
_remainingTime = (await AuthenticationAPI.sendOtp(
|
_remainingTime = (await AuthenticationAPI.sendOtp(
|
||||||
email: forgetEmailController.text, regionUuid: regionUuid))!;
|
email: forgetEmailController.text,
|
||||||
|
))!;
|
||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
if (e.response!.statusCode == 400) {
|
if (e.response!.statusCode == 400) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
@ -139,7 +140,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
String validate = '';
|
String validate = '';
|
||||||
String forgetValidate = '';
|
String forgetValidate = '';
|
||||||
String forgetEmailValidate = '';
|
String forgetEmailValidate = '';
|
||||||
String regionUuid = '';
|
// String regionUuid = '';
|
||||||
static Token token = Token.emptyConstructor();
|
static Token token = Token.emptyConstructor();
|
||||||
static UserModel? user;
|
static UserModel? user;
|
||||||
bool showValidationMessage = false;
|
bool showValidationMessage = false;
|
||||||
@ -156,7 +157,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
|
|
||||||
token = await AuthenticationAPI.loginWithEmail(
|
token = await AuthenticationAPI.loginWithEmail(
|
||||||
model: LoginWithEmailModel(
|
model: LoginWithEmailModel(
|
||||||
email: event.username, password: event.password, regionUuid: event.regionUuid),
|
email: event.username,
|
||||||
|
password: event.password,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
validate = 'Invalid Credentials!';
|
validate = 'Invalid Credentials!';
|
||||||
@ -364,7 +367,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
Future selectRegion(SelectRegionEvent event, Emitter<AuthState> emit) async {
|
Future selectRegion(SelectRegionEvent event, Emitter<AuthState> emit) async {
|
||||||
try {
|
try {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
regionUuid = event.val;
|
// regionUuid = event.val;
|
||||||
add(CheckEnableEvent());
|
add(CheckEnableEvent());
|
||||||
emit(AuthInitialState());
|
emit(AuthInitialState());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -397,8 +400,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
checkValidate = isChecked == true &&
|
checkValidate = isChecked == true &&
|
||||||
loginPasswordController.text.isNotEmpty &&
|
loginPasswordController.text.isNotEmpty &&
|
||||||
loginEmailController.text.isNotEmpty &&
|
loginEmailController.text.isNotEmpty;
|
||||||
regionUuid != '';
|
|
||||||
emit(LoginInitial());
|
emit(LoginInitial());
|
||||||
return checkValidate;
|
return checkValidate;
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,16 @@ abstract class AuthEvent extends Equatable {
|
|||||||
class LoginButtonPressed extends AuthEvent {
|
class LoginButtonPressed extends AuthEvent {
|
||||||
final String username;
|
final String username;
|
||||||
final String password;
|
final String password;
|
||||||
final String regionUuid;
|
// final String regionUuid;
|
||||||
|
|
||||||
const LoginButtonPressed({
|
const LoginButtonPressed({
|
||||||
required this.username,
|
required this.username,
|
||||||
required this.password,
|
required this.password,
|
||||||
required this.regionUuid,
|
// required this.regionUuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [username, password, regionUuid];
|
List<Object> get props => [username, password];
|
||||||
}
|
}
|
||||||
|
|
||||||
class CheckBoxEvent extends AuthEvent {
|
class CheckBoxEvent extends AuthEvent {
|
||||||
@ -49,13 +49,9 @@ class UpdateTimerEvent extends AuthEvent {
|
|||||||
const UpdateTimerEvent({required this.remainingTime, required this.isButtonEnabled});
|
const UpdateTimerEvent({required this.remainingTime, required this.isButtonEnabled});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChangePasswordEvent extends AuthEvent {
|
class ChangePasswordEvent extends AuthEvent {}
|
||||||
|
|
||||||
}
|
class SendOtpEvent extends AuthEvent {}
|
||||||
|
|
||||||
class SendOtpEvent extends AuthEvent {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class PasswordVisibleEvent extends AuthEvent {
|
class PasswordVisibleEvent extends AuthEvent {
|
||||||
final bool? newValue;
|
final bool? newValue;
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
class LoginWithEmailModel {
|
class LoginWithEmailModel {
|
||||||
final String email;
|
final String email;
|
||||||
final String password;
|
final String password;
|
||||||
final String regionUuid;
|
// final String regionUuid;
|
||||||
|
|
||||||
LoginWithEmailModel({
|
LoginWithEmailModel({
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.password,
|
required this.password,
|
||||||
required this.regionUuid,
|
// required this.regionUuid,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory LoginWithEmailModel.fromJson(Map<String, dynamic> json) {
|
factory LoginWithEmailModel.fromJson(Map<String, dynamic> json) {
|
||||||
return LoginWithEmailModel(
|
return LoginWithEmailModel(
|
||||||
email: json['email'],
|
email: json['email'],
|
||||||
password: json['password'],
|
password: json['password'],
|
||||||
regionUuid: json['regionUuid'],
|
// regionUuid: json['regionUuid'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ class LoginWithEmailModel {
|
|||||||
return {
|
return {
|
||||||
'email': email,
|
'email': email,
|
||||||
'password': password,
|
'password': password,
|
||||||
'regionUuid': regionUuid,
|
// 'regionUuid': regionUuid,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,18 +124,18 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
|
.copyWith(fontSize: 14, fontWeight: FontWeight.w400),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Column(
|
// Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
// children: [
|
||||||
const SizedBox(height: 10),
|
// const SizedBox(height: 10),
|
||||||
Form(
|
// Form(
|
||||||
key: forgetBloc.forgetRegionKey,
|
// key: forgetBloc.forgetRegionKey,
|
||||||
child: SizedBox(
|
// child: SizedBox(
|
||||||
child:
|
// child:
|
||||||
_buildDropdownField(context, forgetBloc, size)))
|
// _buildDropdownField(context, forgetBloc, size)))
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Form(
|
Form(
|
||||||
key: forgetBloc.forgetEmailKey,
|
key: forgetBloc.forgetEmailKey,
|
||||||
@ -459,9 +459,9 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
value: loginBloc.regionList!.any((region) => region.id == loginBloc.regionUuid)
|
// value: loginBloc.regionList!.any((region) => region.id == loginBloc.regionUuid)
|
||||||
? loginBloc.regionUuid
|
// ? loginBloc.regionUuid
|
||||||
: null,
|
// : null,
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
loginBloc.add(SelectRegionEvent(val: value));
|
loginBloc.add(SelectRegionEvent(val: value));
|
||||||
|
@ -6,7 +6,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_event.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_event.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_state.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_state.dart';
|
||||||
import 'package:syncrow_web/pages/auth/model/region_model.dart';
|
// import 'package:syncrow_web/pages/auth/model/region_model.dart';
|
||||||
import 'package:syncrow_web/pages/auth/view/forget_password_page.dart';
|
import 'package:syncrow_web/pages/auth/view/forget_password_page.dart';
|
||||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
@ -112,44 +112,44 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
|
color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Column(
|
// Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
// children: [
|
||||||
Text(
|
// Text(
|
||||||
"Country/Region",
|
// "Country/Region",
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
// style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
// ),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
child: DropdownButtonFormField<String>(
|
// child: DropdownButtonFormField<String>(
|
||||||
validator: loginBloc.validateRegion,
|
// validator: loginBloc.validateRegion,
|
||||||
icon: const Icon(
|
// icon: const Icon(
|
||||||
Icons.keyboard_arrow_down_outlined,
|
// Icons.keyboard_arrow_down_outlined,
|
||||||
),
|
// ),
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
// decoration: textBoxDecoration()!.copyWith(
|
||||||
hintText: null,
|
// hintText: null,
|
||||||
),
|
// ),
|
||||||
hint: const Align(
|
// hint: const Align(
|
||||||
alignment: Alignment.centerLeft,
|
// alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
// child: Text(
|
||||||
'Select your region/country',
|
// 'Select your region/country',
|
||||||
textAlign: TextAlign.center,
|
// textAlign: TextAlign.center,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
isDense: true,
|
// isDense: true,
|
||||||
style: const TextStyle(color: Colors.black),
|
// style: const TextStyle(color: Colors.black),
|
||||||
items: loginBloc.regionList!.map((RegionModel region) {
|
// items: loginBloc.regionList!.map((RegionModel region) {
|
||||||
return DropdownMenuItem<String>(
|
// return DropdownMenuItem<String>(
|
||||||
value: region.name,
|
// value: region.name,
|
||||||
child: Text(region.name),
|
// child: Text(region.name),
|
||||||
);
|
// );
|
||||||
}).toList(),
|
// }).toList(),
|
||||||
onChanged: (String? value) {},
|
// onChanged: (String? value) {},
|
||||||
),
|
// ),
|
||||||
)
|
// )
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
const SizedBox(height: 20.0),
|
// const SizedBox(height: 20.0),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@ -207,7 +207,10 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Forgot Password?",
|
"Forgot Password?",
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall!
|
||||||
|
.copyWith(color: ColorsManager.blackColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -276,7 +279,6 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
if (loginBloc.loginFormKey.currentState!.validate()) {
|
if (loginBloc.loginFormKey.currentState!.validate()) {
|
||||||
loginBloc.add(
|
loginBloc.add(
|
||||||
LoginButtonPressed(
|
LoginButtonPressed(
|
||||||
regionUuid: '',
|
|
||||||
username: loginBloc.loginEmailController.text,
|
username: loginBloc.loginEmailController.text,
|
||||||
password: loginBloc.loginPasswordController.text,
|
password: loginBloc.loginPasswordController.text,
|
||||||
),
|
),
|
||||||
|
@ -155,8 +155,8 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
Text('Login', style: Theme.of(context).textTheme.headlineLarge),
|
Text('Login', style: Theme.of(context).textTheme.headlineLarge),
|
||||||
SizedBox(height: size.height * 0.03),
|
// SizedBox(height: size.height * 0.03),
|
||||||
_buildDropdownField(context, loginBloc, size),
|
// _buildDropdownField(context, loginBloc, size),
|
||||||
const SizedBox(height: 20.0),
|
const SizedBox(height: 20.0),
|
||||||
_buildEmailField(context, loginBloc),
|
_buildEmailField(context, loginBloc),
|
||||||
const SizedBox(height: 20.0),
|
const SizedBox(height: 20.0),
|
||||||
@ -219,11 +219,11 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
value: loginBloc.regionList!.any(
|
// value: loginBloc.regionList!.any(
|
||||||
(region) => region.id == loginBloc.regionUuid,
|
// (region) => region.id == loginBloc.regionUuid,
|
||||||
)
|
// )
|
||||||
? loginBloc.regionUuid
|
// ? loginBloc.regionUuid
|
||||||
: null,
|
// : null,
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
loginBloc.add(CheckEnableEvent());
|
loginBloc.add(CheckEnableEvent());
|
||||||
@ -462,7 +462,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (loginBloc.loginFormKey.currentState!.validate()) {
|
if (loginBloc.loginFormKey.currentState!.validate()) {
|
||||||
loginBloc.add(LoginButtonPressed(
|
loginBloc.add(LoginButtonPressed(
|
||||||
regionUuid: loginBloc.regionUuid,
|
// regionUuid: loginBloc.regionUuid,
|
||||||
username: loginBloc.loginEmailController.text,
|
username: loginBloc.loginEmailController.text,
|
||||||
password: loginBloc.loginPasswordController.text,
|
password: loginBloc.loginPasswordController.text,
|
||||||
));
|
));
|
||||||
|
@ -22,16 +22,16 @@ class AuthenticationAPI {
|
|||||||
}) async {
|
}) async {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.forgetPassword,
|
path: ApiEndpoints.forgetPassword,
|
||||||
body: {"email": email, "password": password,"otpCode": otpCode},
|
body: {"email": email, "password": password, "otpCode": otpCode},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {});
|
expectedResponseModel: (json) {});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<int?> sendOtp({required String email, required String regionUuid}) async {
|
static Future<int?> sendOtp({required String email}) async {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.sendOtp,
|
path: ApiEndpoints.sendOtp,
|
||||||
body: {"email": email, "type": "PASSWORD", "regionUuid": regionUuid},
|
body: {"email": email, "type": "PASSWORD"},
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json['data']['cooldown'];
|
return json['data']['cooldown'];
|
||||||
|
Reference in New Issue
Block a user