fix issues

fatima
Fatimah Alshammari 4 years ago
parent 184ac7859d
commit 4e9eccb3cd

@ -41,7 +41,11 @@ class UserApiClent {
} }
Future<RegisterUser> basicComplete(String userId, String firstName, String lastName, String email, String password) async { Future<RegisterUser> basicComplete(String userId, String firstName, String lastName, String email, String password) async {
var postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password}; var postParams;
if(email.isEmpty)
{ postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password};
}else{ postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password};
}
return await ApiClient().postJsonForObject((json) => RegisterUser.fromJson(json), ApiConsts.BasicComplete, postParams); return await ApiClient().postJsonForObject((json) => RegisterUser.fromJson(json), ApiConsts.BasicComplete, postParams);
} }
@ -159,13 +163,13 @@ class UserApiClent {
return await ApiClient().postJsonForObject((json) => VerifyEmail.fromJson(json), ApiConsts.EmailVerify, postParams, token: t); return await ApiClient().postJsonForObject((json) => VerifyEmail.fromJson(json), ApiConsts.EmailVerify, postParams, token: t);
} }
Future<VerifyEmailOTP> EmailVerifyOTPVerify(String userToken, String userOTP) async { Future<MResponse> EmailVerifyOTPVerify(String userToken, String userOTP) async {
var postParams = var postParams =
{"userToken": userToken, {"userToken": userToken,
"userOTP": userOTP}; "userOTP": userOTP};
String t = AppState().getUser.data!.accessToken ?? ""; String t = AppState().getUser.data!.accessToken ?? "";
return await ApiClient().postJsonForObject((json) => VerifyEmailOTP.fromJson(json), ApiConsts.EmailVerifyOTPVerify, postParams, token: t); return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.EmailVerifyOTPVerify, postParams, token: t);
} }

@ -51,7 +51,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
12.height, 12.height,
TxtField( TxtField(
hint: "First Name", hint: "First Name *",
value: firstName, value: firstName,
onChanged: (v) { onChanged: (v) {
firstName = v; firstName = v;
@ -59,7 +59,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
), ),
12.height, 12.height,
TxtField( TxtField(
hint: "Surname", hint: "Surname *",
value: lastName, value: lastName,
onChanged: (v) { onChanged: (v) {
lastName = v; lastName = v;
@ -75,7 +75,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
), ),
12.height, 12.height,
TxtField( TxtField(
hint: "Create Password", hint: "Create Password *",
isPasswordEnabled: true, isPasswordEnabled: true,
maxLines: 1, maxLines: 1,
value: password, value: password,
@ -85,7 +85,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
), ),
12.height, 12.height,
TxtField( TxtField(
hint: "Confirm Password", hint: "Confirm Password *",
isPasswordEnabled: true, isPasswordEnabled: true,
maxLines: 1, maxLines: 1,
value: confirmPassword, value: confirmPassword,

@ -3,9 +3,11 @@ import 'dart:convert';
import 'package:car_customer_app/api/shared_prefrence.dart'; import 'package:car_customer_app/api/shared_prefrence.dart';
import 'package:car_customer_app/api/user_api_client.dart'; import 'package:car_customer_app/api/user_api_client.dart';
import 'package:car_customer_app/classes/app_state.dart';
import 'package:car_customer_app/classes/utils.dart'; import 'package:car_customer_app/classes/utils.dart';
import 'package:car_customer_app/config/routes.dart'; import 'package:car_customer_app/config/routes.dart';
import 'package:car_customer_app/extensions/string_extensions.dart'; import 'package:car_customer_app/extensions/string_extensions.dart';
import 'package:car_customer_app/models/user/change_password.dart';
import 'package:car_customer_app/models/user/email_verify.dart'; import 'package:car_customer_app/models/user/email_verify.dart';
import 'package:car_customer_app/models/user/email_verify_otp.dart'; import 'package:car_customer_app/models/user/email_verify_otp.dart';
import 'package:car_customer_app/utils/navigator.dart'; import 'package:car_customer_app/utils/navigator.dart';
@ -27,7 +29,7 @@ class EditAccountPage extends StatefulWidget {
class _EditAccountPageState extends State<EditAccountPage> { class _EditAccountPageState extends State<EditAccountPage> {
String userID = ""; String userID = "";
String email = ''; String email = '';
bool isVerified = false; //bool isVerified = true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -72,8 +74,11 @@ class _EditAccountPageState extends State<EditAccountPage> {
Icon(Icons.email, color: Colors.blue,), Icon(Icons.email, color: Colors.blue,),
"Change Email".toText12(), "Change Email".toText12(),
InkWell( InkWell(
child: "Verify".toText12(), child:((AppState().getUser.data!.userInfo!.isEmailVerified??false)?"Verified" :"Verify").toText12(),
onTap:() { onTap:
(AppState().getUser.data!.userInfo!.isEmailVerified??false) ?
null
:(){
verifyEmail(context); verifyEmail(context);
}, },
), ),
@ -89,21 +94,6 @@ class _EditAccountPageState extends State<EditAccountPage> {
) )
], ],
) )
// ListTile(
// leading: Icon(Icons.phone_android_sharp, color: Colors.blue,),
// title: "Change Mobile".toText12(),
// onTap: () {
// navigateWithName(context, AppRoutes.changeMobilePage);
// },
// ),
// ListTile(
// leading: Icon(Icons.email_outlined, color: Colors.blue,),
// title: "Change Email".toText12(),
// onTap: () {
// navigateWithName(context, AppRoutes.changeEmailPage);
// },
// ),
], ],
), ),
), ),
@ -120,22 +110,18 @@ class _EditAccountPageState extends State<EditAccountPage> {
onClick: (String code) async { onClick: (String code) async {
pop(context); pop(context);
Utils.showLoading(context); Utils.showLoading(context);
VerifyEmailOTP otpCompare = await UserApiClent().EmailVerifyOTPVerify(otpRequest.data!.userToken ?? "", code); MResponse otpCompare = await UserApiClent().EmailVerifyOTPVerify(otpRequest.data!.userToken ?? "", code);
Utils.hideLoading(context); Utils.hideLoading(context);
if (otpCompare.success == true) { if (otpCompare.messageStatus == 1) {
showMDialog( AppState().getUser.data!.userInfo!.isEmailVerified=true;
context, setState(() {
child: MessageDialog(
title: "Email Verified", });
onClick: () { Utils.showToast("Email is verified successfully");
// !isVerified; pop(context);
pop(context);
// Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.dashboard, (Route<dynamic> route) => false);
},
),
);
} else { } else {
Utils.showToast(otpCompare.errors ?? ""); Utils.showToast(otpCompare.message ?? "");
} }
}, },
)); ));

@ -104,7 +104,7 @@ class _LoginWithPasswordState extends State<LoginWithPassword> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
"Forget Password".toText12(color: Colors.blue).onPress(() { "Forget Password ?".toText12(color: Colors.blue).onPress(() {
navigateWithName(context, AppRoutes.forgetPassword); navigateWithName(context, AppRoutes.forgetPassword);
}), }),
], ],

Loading…
Cancel
Save