Merge branch 'fatima' into mirza_dev

# Conflicts:
#	lib/api/client/user_api_client.dart
#	lib/pages/user/complete_profile_page.dart
mirza_dev
devmirza121 4 years ago
commit 66438f3d48

@ -23,6 +23,8 @@ import '../../classes/app_state.dart';
import '../../models/m_response.dart';
import '../api_client.dart';
class UserApiClent {
static final UserApiClent _instance = UserApiClent._internal();
@ -45,7 +47,13 @@ class UserApiClent {
}
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);
}
@ -99,7 +107,7 @@ class UserApiClent {
Future<Response> ForgetPasswordOTPCompare(String userToken, String userOTP) async {
var postParams = {"userToken": userToken, "userOTP": userOTP};
return await ApiClient().postJsonForResponse(ApiConsts.ForgetPasswordOTPCompare, postParams);
// return await ApiClient().postJsonForObject((json) => PasswordOTPCompare.fromJson(json), ApiConsts.ForgetPasswordOTPCompare, postParams);
// return await ApiClient().postJsonForObject((json) => PasswordOTPCompare.fromJson(json), ApiConsts.ForgetPasswordOTPCompare, postParams);
}
Future<Response> ForgetPassword(String userToken, String newPassword) async {
@ -121,6 +129,7 @@ class UserApiClent {
String t = AppState().getUser.data!.accessToken ?? "";
print("tokeen " + t);
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
}
Future<ChangeMobile> ChangeMobileNoOTPRequest(
@ -166,11 +175,13 @@ class UserApiClent {
return await ApiClient().postJsonForObject((json) => VerifyEmail.fromJson(json), ApiConsts.EmailVerify, postParams, token: t);
}
Future<VerifyEmailOTP> EmailVerifyOTPVerify(String userToken, String userOTP) async {
var postParams = {"userToken": userToken, "userOTP": userOTP};
Future<MResponse> EmailVerifyOTPVerify(String userToken, String userOTP) async {
var postParams =
{"userToken": userToken,
"userOTP": userOTP};
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);
}
Future<Response> UpdateUserImage(String image) async {

@ -52,7 +52,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
12.height,
TxtField(
hint: "First Name*",
hint: "First Name *",
value: firstName,
onChanged: (v) {
firstName = v;
@ -60,7 +60,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
),
12.height,
TxtField(
hint: "Surname*",
hint: "Surname *",
value: lastName,
onChanged: (v) {
lastName = v;
@ -70,13 +70,15 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
TxtField(
hint: "Email",
value: email,
isButtonEnable: email!.length > 0 ? true : false,
buttonTitle: "Verify",
onChanged: (v) {
email = v;
},
),
12.height,
TxtField(
hint: "Create Password*",
hint: "Create Password *",
isPasswordEnabled: true,
maxLines: 1,
value: password,
@ -86,7 +88,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
),
12.height,
TxtField(
hint: "Confirm Password*",
hint: "Confirm Password *",
isPasswordEnabled: true,
maxLines: 1,
value: confirmPassword,

@ -3,10 +3,12 @@
import 'dart:convert';
import 'package:car_provider_app/api/client/user_api_client.dart';
import 'package:car_provider_app/classes/app_state.dart';
import 'package:car_provider_app/classes/utils.dart';
import 'package:car_provider_app/config/routes.dart';
import 'package:car_provider_app/extensions/int_extensions.dart';
import 'package:car_provider_app/extensions/string_extensions.dart';
import 'package:car_provider_app/models/m_response.dart';
import 'package:car_provider_app/models/user/verify_email.dart';
import 'package:car_provider_app/models/user/verify_email_otp.dart';
import 'package:car_provider_app/utils/navigator.dart';
@ -52,7 +54,7 @@ class _EditAccountPageState extends State<EditAccountPage> {
children: [
SvgPicture.asset("assets/images/ic_mobile.svg"),
"Change Mobile".toText12(),
"Verified".toText12(),
"Verify".toText12(),
RaisedButton(
onPressed: (){
navigateWithName(context, AppRoutes.changeMobilePage);
@ -71,11 +73,14 @@ class _EditAccountPageState extends State<EditAccountPage> {
children: [
Icon(Icons.email, color: Colors.blue,),
"Change Email".toText12(),
InkWell(
child: "Verify".toText12(),
onTap:() {
verifyEmail(context);
},
InkWell(
child:((AppState().getUser.data!.userInfo!.isEmailVerified??false)?"Verified" :"Verify").toText12(),
onTap:
(AppState().getUser.data!.userInfo!.isEmailVerified??false) ?
null
:(){
verifyEmail(context);
},
),
RaisedButton(
onPressed: (){
@ -120,20 +125,22 @@ class _EditAccountPageState extends State<EditAccountPage> {
onClick: (String code) async {
pop(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);
if (otpCompare.success == true) {
showMDialog(
context,
child: MessageDialog(
title: "Email is Verified",
onClick: () {
Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.dashboard, (Route<dynamic> route) => false);
},
),
);
if (otpCompare.messageStatus == 1) {
Utils.showToast("Email is verified successfully");
// Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.dashboard, (Route<dynamic> route) => false);
// showMDialog(
// context,
// child: MessageDialog(
// title: "Email is Verified",
// onClick: () {
// Navigator.of(context).pushNamedAndRemoveUntil(AppRoutes.dashboard, (Route<dynamic> route) => false);
// },
// ),
// );
} else {
Utils.showToast(otpCompare.errors ?? "");
Utils.showToast(otpCompare.message ?? "");
}
},
));

Loading…
Cancel
Save