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