Provider Dealer User #4

Merged
mirzashafique merged 2 commits from mirza_development into master 2 years ago

@ -17,6 +17,7 @@ class AppState {
bool? get getIsLogged => isLogged; bool? get getIsLogged => isLogged;
AppType currentAppType = AppType.provider; AppType currentAppType = AppType.provider;
UserType userType = UserType.customer;
void setAppType(AppType appType) { void setAppType(AppType appType) {
currentAppType = appType; currentAppType = appType;

@ -108,6 +108,16 @@ class ApiConsts {
static String getMatchedServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchServicesMapping_Get"; static String getMatchedServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchServicesMapping_Get";
static String duplicateItems = "${baseUrlServices}api/ServiceProviders/ServiceItemCopy_Create"; static String duplicateItems = "${baseUrlServices}api/ServiceProviders/ServiceItemCopy_Create";
//Branch Users
static String getAllProviderDealers = "${baseUrlServices}api/ServiceProviders/DealershipUserBranchWise_Get";
// /api/ServiceProviders/BranchUser_Get
//DealershipUserBranchWise_Get
static String getBranchUser = "${baseUrlServices}api/ServiceProviders/BranchUser_Get";
static String assignDealerToBranch = "${baseUrlServices}api/ServiceProviders/BranchUser_Create";
static String removeDealerFromBranch = "${baseUrlServices}api/ServiceProviders/BranchUser_Update";
static List<String> closingUrls = ["PayFortResponse"]; static List<String> closingUrls = ["PayFortResponse"];
} }

@ -19,7 +19,7 @@ class PostParamsModel {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = Map<String, dynamic>();
data['VersionID'] = this.versionID; data['VersionID'] = this.versionID;
data['Channel'] = this.channel; data['Channel'] = this.channel;
data['LanguageID'] = this.languageID; data['LanguageID'] = this.languageID;

@ -0,0 +1,48 @@
class BranchUser {
int id;
String? userId;
int? serviceProviderId;
int? dealershipUserID;
String firstName;
String lastName;
String mobileNo;
String email;
bool isBranchUser;
BranchUser({
required this.id,
required this.userId,
required this.serviceProviderId,
required this.dealershipUserID,
required this.firstName,
required this.lastName,
required this.mobileNo,
required this.email,
required this.isBranchUser,
});
factory BranchUser.fromJson(Map<String, dynamic> json) =>
BranchUser(
id: json["id"],
userId: json.containsKey("userID") ? json["userID"] : null,
serviceProviderId: json.containsKey("serviceProviderID") ? json["serviceProviderID"] : null,
dealershipUserID: json.containsKey("dealershipUserID") ? json["dealershipUserID"] : null,
firstName: json["firstName"],
lastName: json["lastName"],
mobileNo: json["mobileNo"],
email: json["email"],
isBranchUser: json.containsKey("isBranchUser") ? json["isBranchUser"] : false,
);
Map<String, dynamic> toJson() =>
{
"id": id,
"userID": userId,
"serviceProviderID": serviceProviderId,
"firstName": firstName,
"lastName": lastName,
"mobileNo": mobileNo,
"email": email,
"isBranchUser": isBranchUser,
};
}

@ -22,18 +22,18 @@ class RegisterUserRespModel {
final String? message; final String? message;
factory RegisterUserRespModel.fromJson(Map<String, dynamic> json) => RegisterUserRespModel( factory RegisterUserRespModel.fromJson(Map<String, dynamic> json) => RegisterUserRespModel(
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
totalItemsCount: json["totalItemsCount"], totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? null : Data.fromJson(json["data"]), data: json["data"] == null ? null : Data.fromJson(json["data"]),
message: json["message"] == null ? null : json["message"], message: json["message"] == null ? null : json["message"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"messageStatus": messageStatus == null ? null : messageStatus, "messageStatus": messageStatus == null ? null : messageStatus,
"totalItemsCount": totalItemsCount, "totalItemsCount": totalItemsCount,
"data": data == null ? null : data!.toJson(), "data": data == null ? null : data!.toJson(),
"message": message == null ? null : message, "message": message == null ? null : message,
}; };
} }
class Data { class Data {
@ -58,6 +58,7 @@ class Data {
this.providerId, this.providerId,
this.customerId, this.customerId,
this.dealershipId, this.dealershipId,
required this.isNeedToPassToken,
}); });
final int? id; final int? id;
@ -67,7 +68,7 @@ class Data {
final String? mobileNo; final String? mobileNo;
final String? email; final String? email;
final dynamic? userImageUrl; final dynamic? userImageUrl;
final int? roleId; int? roleId;
final dynamic? roleName; final dynamic? roleName;
final bool? isEmailVerified; final bool? isEmailVerified;
final List<dynamic>? serviceProviderBranch; final List<dynamic>? serviceProviderBranch;
@ -80,50 +81,52 @@ class Data {
final dynamic? providerId; final dynamic? providerId;
final dynamic? customerId; final dynamic? customerId;
final dynamic? dealershipId; final dynamic? dealershipId;
bool isNeedToPassToken;
factory Data.fromJson(Map<String, dynamic> json) => Data( factory Data.fromJson(Map<String, dynamic> json) => Data(
id: json["id"] == null ? null : json["id"], id: json["id"] == null ? null : json["id"],
userId: json["userID"] == null ? null : json["userID"], userId: json["userID"] == null ? null : json["userID"],
firstName: json["firstName"], firstName: json["firstName"],
lastName: json["lastName"], lastName: json["lastName"],
mobileNo: json["mobileNo"] == null ? null : json["mobileNo"], mobileNo: json["mobileNo"] == null ? null : json["mobileNo"],
email: json["email"] == null ? null : json["email"], email: json["email"] == null ? null : json["email"],
userImageUrl: json["userImageUrl"], userImageUrl: json["userImageUrl"],
roleId: json["roleID"] == null ? null : json["roleID"], roleId: json["roleID"] == null ? null : json["roleID"],
roleName: json["roleName"], roleName: json["roleName"],
isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"], isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"],
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)), serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)),
isVerified: json["isVerified"] == null ? null : json["isVerified"], isVerified: json["isVerified"] == null ? null : json["isVerified"],
userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)), userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)),
isCustomer: json["isCustomer"] == null ? null : json["isCustomer"], isCustomer: json["isCustomer"] == null ? null : json["isCustomer"],
isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"], isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"],
isProviderIndividual: json["isProviderIndividual"] == null ? null : json["isProviderIndividual"], isProviderIndividual: json["isProviderIndividual"] == null ? null : json["isProviderIndividual"],
isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"], isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"],
providerId: json["providerID"], providerId: json["providerID"],
customerId: json["customerID"], customerId: json["customerID"],
dealershipId: json["dealershipID"], dealershipId: json["dealershipID"],
); isNeedToPassToken: false,
);
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id == null ? null : id, "id": id == null ? null : id,
"userID": userId == null ? null : userId, "userID": userId == null ? null : userId,
"firstName": firstName, "firstName": firstName,
"lastName": lastName, "lastName": lastName,
"mobileNo": mobileNo == null ? null : mobileNo, "mobileNo": mobileNo == null ? null : mobileNo,
"email": email == null ? null : email, "email": email == null ? null : email,
"userImageUrl": userImageUrl, "userImageUrl": userImageUrl,
"roleID": roleId == null ? null : roleId, "roleID": roleId == null ? null : roleId,
"roleName": roleName, "roleName": roleName,
"isEmailVerified": isEmailVerified == null ? null : isEmailVerified, "isEmailVerified": isEmailVerified == null ? null : isEmailVerified,
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)), "serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)),
"isVerified": isVerified == null ? null : isVerified, "isVerified": isVerified == null ? null : isVerified,
"userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)), "userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)),
"isCustomer": isCustomer == null ? null : isCustomer, "isCustomer": isCustomer == null ? null : isCustomer,
"isProviderDealership": isProviderDealership == null ? null : isProviderDealership, "isProviderDealership": isProviderDealership == null ? null : isProviderDealership,
"isProviderIndividual": isProviderIndividual == null ? null : isProviderIndividual, "isProviderIndividual": isProviderIndividual == null ? null : isProviderIndividual,
"isDealershipUser": isDealershipUser == null ? null : isDealershipUser, "isDealershipUser": isDealershipUser == null ? null : isDealershipUser,
"providerID": providerId, "providerID": providerId,
"customerID": customerId, "customerID": customerId,
"dealershipID": dealershipId, "dealershipID": dealershipId,
}; };
} }

@ -4,6 +4,9 @@
import 'dart:convert'; import 'dart:convert';
import '../../classes/app_state.dart';
import '../../utils/enums.dart';
User userFromJson(String str) => User.fromJson(json.decode(str)); User userFromJson(String str) => User.fromJson(json.decode(str));
String userToJson(User data) => json.encode(data.toJson()); String userToJson(User data) => json.encode(data.toJson());
@ -22,18 +25,18 @@ class User {
String? message; String? message;
factory User.fromJson(Map<String, dynamic> json) => User( factory User.fromJson(Map<String, dynamic> json) => User(
totalItemsCount: json["totalItemsCount"], totalItemsCount: json["totalItemsCount"],
data: json["data"] == null ? null : UserData.fromJson(json["data"]), data: json["data"] == null ? null : UserData.fromJson(json["data"]),
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], messageStatus: json["messageStatus"],
message: json["message"] == null ? null : json["message"], message: json["message"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"totalItemsCount": totalItemsCount, "totalItemsCount": totalItemsCount,
"data": data == null ? null : data!.toJson(), "data": data == null ? null : data!.toJson(),
"messageStatus": messageStatus == null ? null : messageStatus, "messageStatus": messageStatus,
"message": message == null ? null : message, "message": message,
}; };
} }
class UserData { class UserData {
@ -50,18 +53,18 @@ class UserData {
UserInfo? userInfo; UserInfo? userInfo;
factory UserData.fromJson(Map<String, dynamic> json) => UserData( factory UserData.fromJson(Map<String, dynamic> json) => UserData(
accessToken: json["accessToken"] == null ? null : json["accessToken"], accessToken: json["accessToken"],
refreshToken: json["refreshToken"] == null ? null : json["refreshToken"], refreshToken: json["refreshToken"],
expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]), expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]),
userInfo: json["userInfo"] == null ? null : UserInfo.fromJson(json["userInfo"]), userInfo: json["userInfo"] == null ? null : UserInfo.fromJson(json["userInfo"]),
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"accessToken": accessToken == null ? null : accessToken, "accessToken": accessToken,
"refreshToken": refreshToken == null ? null : refreshToken, "refreshToken": refreshToken,
"expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(), "expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(),
"userInfo": userInfo == null ? null : userInfo!.toJson(), "userInfo": userInfo == null ? null : userInfo!.toJson(),
}; };
} }
class UserInfo { class UserInfo {
@ -107,47 +110,76 @@ class UserInfo {
int? customerId; int? customerId;
dynamic dealershipId; dynamic dealershipId;
factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo( UserInfo.fromJson(Map<String, dynamic> json) {
id: json["id"] == null ? null : json["id"], if (json["roleID"] == 5) {
userId: json["userID"] == null ? null : json["userID"], AppState().userType = UserType.providerDealer;
firstName: json["firstName"] == null ? null : json["firstName"], } else if (json["roleID"] == 6) {
lastName: json["lastName"] == null ? null : json["lastName"], AppState().userType = UserType.providerIndividual;
mobileNo: json["mobileNo"] == null ? null : json["mobileNo"], } else {
email: json["email"] == null ? null : json["email"], AppState().userType = UserType.customer;
userImageUrl: json["userImageUrl"], }
roleId: json["roleID"] == null ? null : json["roleID"], id = json["id"];
roleName: json["roleName"] == null ? null : json["roleName"], userId = json["userID"];
isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"], firstName = json["firstName"];
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)), lastName = json["lastName"];
isVerified: json["isVerified"] == null ? null : json["isVerified"], mobileNo = json["mobileNo"];
userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)), email = json["email"];
isCustomer: json["isCustomer"] == null ? null : json["isCustomer"], userImageUrl = json["userImageUrl"];
isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"], roleId = json["roleID"];
isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"], roleName = json["roleName"];
providerId: json["providerID"], isEmailVerified = json["isEmailVerified"];
customerId: json["customerID"] == null ? null : json["customerID"], serviceProviderBranch = json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x));
dealershipId: json["dealershipID"], isVerified = json["isVerified"];
); userRoles = json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x));
isCustomer = json["isCustomer"];
isProviderDealership = json["isProviderDealership"];
isDealershipUser = json["isDealershipUser"];
providerId = json["providerID"];
customerId = json["customerID"];
dealershipId = json["dealershipID"];
}
// factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
// id: json["id"],
// userId: json["userID"],
// firstName: json["firstName"],
// lastName: json["lastName"],
// mobileNo: json["mobileNo"],
// email: json["email"],
// userImageUrl: json["userImageUrl"],
// roleId: json["roleID"],
// roleName: json["roleName"],
// isEmailVerified: json["isEmailVerified"],
// serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)),
// isVerified: json["isVerified"],
// userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)),
// isCustomer: json["isCustomer"],
// isProviderDealership: json["isProviderDealership"],
// isDealershipUser: json["isDealershipUser"],
// providerId: json["providerID"],
// customerId: json["customerID"],
// dealershipId: json["dealershipID"],
// );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"id": id == null ? null : id, "id": id,
"userID": userId == null ? null : userId, "userID": userId,
"firstName": firstName == null ? null : firstName, "firstName": firstName,
"lastName": lastName == null ? null : lastName, "lastName": lastName,
"mobileNo": mobileNo == null ? null : mobileNo, "mobileNo": mobileNo,
"email": email == null ? null : email, "email": email,
"userImageUrl": userImageUrl, "userImageUrl": userImageUrl,
"roleID": roleId == null ? null : roleId, "roleID": roleId,
"roleName": roleName == null ? null : roleName, "roleName": roleName,
"isEmailVerified": isEmailVerified == null ? null : isEmailVerified, "isEmailVerified": isEmailVerified,
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)), "serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)),
"isVerified": isVerified == null ? null : isVerified, "isVerified": isVerified,
"userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)), "userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)),
"isCustomer": isCustomer == null ? null : isCustomer, "isCustomer": isCustomer,
"isProviderDealership": isProviderDealership == null ? null : isProviderDealership, "isProviderDealership": isProviderDealership,
"isDealershipUser": isDealershipUser == null ? null : isDealershipUser, "isDealershipUser": isDealershipUser,
"providerID": providerId, "providerID": providerId,
"customerID": customerId == null ? null : customerId, "customerID": customerId,
"dealershipID": dealershipId, "dealershipID": dealershipId,
}; };
} }

@ -27,11 +27,11 @@ import 'package:mc_common_app/models/user/verify_email.dart';
import 'package:mc_common_app/utils/shared_prefrence.dart'; import 'package:mc_common_app/utils/shared_prefrence.dart';
abstract class UserRepo { abstract class UserRepo {
Future<BasicOtpRespModel> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1}); Future<BasicOtpRespModel> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1, bool isNeedToPassToken = false});
Future<RegisterUserRespModel> basicVerify(String phoneNo, String otp, String userToken); Future<RegisterUserRespModel> basicVerify(String phoneNo, String otp, String userToken, {bool isNeedToPassToken = false});
Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password); Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password, {bool isNeedToPassToken = false});
Future<Response> loginV1(String phoneNo, String password); Future<Response> loginV1(String phoneNo, String password);
@ -76,31 +76,45 @@ abstract class UserRepo {
class UserRepoImp implements UserRepo { class UserRepoImp implements UserRepo {
@override @override
Future<BasicOtpRespModel> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1}) async { Future<BasicOtpRespModel> basicOtp(String phoneNo, {int otpType = 1, int roleId = 4, int countryId = 1, bool isNeedToPassToken = false}) async {
var postParams = {"countryID": countryId, "userMobileNo": phoneNo, "otpType": otpType, "userRole": roleId}; var postParams = {"countryID": countryId, "userMobileNo": phoneNo, "otpType": otpType, "userRole": roleId};
return await injector.get<ApiClient>().postJsonForObject((json) => BasicOtpRespModel.fromJson(json), ApiConsts.BasicOTP, postParams); String? t;
if (isNeedToPassToken) {
t = AppState().getUser.data!.accessToken ?? "";
debugPrint("token " + t);
}
return await injector.get<ApiClient>().postJsonForObject((json) => BasicOtpRespModel.fromJson(json), ApiConsts.BasicOTP, postParams, token: t);
} }
@override @override
Future<RegisterUserRespModel> basicVerify(String phoneNo, String otp, String userToken) async { Future<RegisterUserRespModel> basicVerify(String phoneNo, String otp, String userToken, {bool isNeedToPassToken = false}) async {
var postParams = { var postParams = {
"userMobileNo": phoneNo, "userMobileNo": phoneNo,
"userOTP": otp, "userOTP": otp,
"userToken": userToken, "userToken": userToken,
}; };
return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicVerify, postParams); String? t;
if (isNeedToPassToken) {
t = AppState().getUser.data!.accessToken ?? "";
debugPrint("token " + t);
}
return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicVerify, postParams, token: t);
} }
@override @override
Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password) async { Future<RegisterUserRespModel> basicComplete(String userId, String firstName, String lastName, String email, String password, {bool isNeedToPassToken = false}) async {
Map<String, Object> postParams; Map<String, Object> postParams;
if (email.isEmpty) { if (email.isEmpty) {
postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password}; postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "companyName": "string", "isEmailVerified": true, "password": password};
} else { } else {
postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password}; postParams = {"userID": userId, "firstName": firstName, "lastName": lastName, "email": email, "companyName": "string", "isEmailVerified": true, "password": password};
} }
String? t;
return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicComplete, postParams); if (isNeedToPassToken) {
t = AppState().getUser.data!.accessToken ?? "";
debugPrint("token " + t);
}
return await injector.get<ApiClient>().postJsonForObject((json) => RegisterUserRespModel.fromJson(json), ApiConsts.BasicComplete, postParams, token: t);
} }
@override @override
@ -285,6 +299,7 @@ class UserRepoImp implements UserRepo {
UserInfo info = UserInfo.fromJson(jsonDecode(mdata)); UserInfo info = UserInfo.fromJson(jsonDecode(mdata));
User user = User(); User user = User();
user.data = UserData(accessToken: refresh.data!.accessToken ?? "", refreshToken: refresh.data!.refreshToken ?? "", userInfo: info); user.data = UserData(accessToken: refresh.data!.accessToken ?? "", refreshToken: refresh.data!.refreshToken ?? "", userInfo: info);
AppState().setUser = user; AppState().setUser = user;
return refresh.data!.accessToken ?? ""; return refresh.data!.accessToken ?? "";
} }

@ -21,6 +21,12 @@ enum AdReserveStatus {
enum CreatedByRoleEnum { customer, provider, admin, allAds } enum CreatedByRoleEnum { customer, provider, admin, allAds }
enum UserType {
providerDealer,
providerIndividual,
customer,
}
enum AdPostStatus { enum AdPostStatus {
pendingForReview, pendingForReview,
pendingForPayment, pendingForPayment,

@ -4,8 +4,8 @@ navigateWithName(BuildContext context, String routeName, {Object? arguments}) {
Navigator.pushNamed(context, routeName, arguments: arguments); Navigator.pushNamed(context, routeName, arguments: arguments);
} }
navigateReplaceWithName(BuildContext context, String routeName, {Object? arguments}) { Future<void> navigateReplaceWithName(BuildContext context, String routeName, {Object? arguments}) async {
Navigator.pushReplacementNamed(context, routeName, arguments: arguments); await Navigator.pushReplacementNamed(context, routeName, arguments: arguments);
} }
navigateReplaceWithNameUntilRoute(BuildContext context, String routeName, {Object? arguments}) { navigateReplaceWithNameUntilRoute(BuildContext context, String routeName, {Object? arguments}) {

@ -142,19 +142,26 @@ class UserVM extends BaseVM {
} }
} }
Future<void> performCompleteProfile( Future<void> performCompleteProfile(BuildContext context, {
BuildContext context, {
required String password, required String password,
required String confirmPassword, required String confirmPassword,
required String firstName, required String firstName,
required String lastName, required String lastName,
required String email, required String email,
required String? userId, required String? userId,
bool isNeedToPassToken = false,
}) async { }) async {
if (Utils.passwordValidateStructure(password)) { if (Utils.passwordValidateStructure(password)) {
if (password == confirmPassword) { if (password == confirmPassword) {
Utils.showLoading(context); Utils.showLoading(context);
RegisterUserRespModel user = await userRepo.basicComplete(userId ?? "", firstName, lastName, email, password); RegisterUserRespModel user = await userRepo.basicComplete(
userId ?? "",
firstName,
lastName,
email,
password,
isNeedToPassToken: isNeedToPassToken,
);
Utils.hideLoading(context); Utils.hideLoading(context);
if (user.messageStatus == 1) { if (user.messageStatus == 1) {
Utils.showToast(LocaleKeys.successfullyRegistered.tr()); Utils.showToast(LocaleKeys.successfullyRegistered.tr());
@ -334,7 +341,6 @@ class UserVM extends BaseVM {
RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body)); RegisterUserRespModel verifiedUser = RegisterUserRespModel.fromJson(jsonDecode(response2.body));
if (verifiedUser.messageStatus == 1) { if (verifiedUser.messageStatus == 1) {
User user = User.fromJson(jsonDecode(response2.body)); User user = User.fromJson(jsonDecode(response2.body));
if (appType == AppType.provider) { if (appType == AppType.provider) {
if (user.data!.userInfo!.roleId == 5 || user.data!.userInfo!.roleId == 6) { if (user.data!.userInfo!.roleId == 5 || user.data!.userInfo!.roleId == 6) {
AppState().setUser = user; AppState().setUser = user;
@ -466,20 +472,33 @@ class UserVM extends BaseVM {
return await userRepo.getAllCountries(); return await userRepo.getAllCountries();
} }
Future<void> performBasicOtpRegisterPage(BuildContext context, {required String countryCode, required String phoneNum, required int role}) async { Future<void> performBasicOtpRegisterPage(BuildContext context,
{required String countryCode, required String phoneNum, required int role, bool isNeedToPassToken = false, VoidCallback? reloadPage}) async {
Utils.showLoading(context); Utils.showLoading(context);
BasicOtpRespModel basicOtp = await userRepo.basicOtp(countryCode + phoneNum, roleId: role); BasicOtpRespModel basicOtp = await userRepo.basicOtp(countryCode + phoneNum, roleId: role, isNeedToPassToken: isNeedToPassToken);
Utils.hideLoading(context); Utils.hideLoading(context);
if (basicOtp.messageStatus == 1) { if (basicOtp.messageStatus == 1) {
showMDialog(context, child: OtpDialog( showMDialog(context, child: OtpDialog(
onClick: (String code) async { onClick: (String code) async {
pop(context); if (reloadPage == null)
pop(context);
Utils.showLoading(context); Utils.showLoading(context);
RegisterUserRespModel user = await userRepo.basicVerify(countryCode + phoneNum, code, basicOtp.data!.userToken ?? ""); RegisterUserRespModel user = await userRepo.basicVerify(
countryCode + phoneNum,
code,
basicOtp.data!.userToken ?? "",
isNeedToPassToken: isNeedToPassToken,
);
Utils.hideLoading(context); Utils.hideLoading(context);
if (user.messageStatus == 1) { if (user.messageStatus == 1) {
Utils.showToast(user.message ?? ""); Utils.showToast(user.message ?? "");
navigateReplaceWithName(context, AppRoutes.completeProfile, arguments: user); user.data!.roleId = role;
user.data!.isNeedToPassToken = isNeedToPassToken;
navigateReplaceWithName(context, AppRoutes.completeProfile, arguments: user).then((value) {
if (reloadPage != null) {
reloadPage();
}
});
} else { } else {
Utils.showToast(user.message ?? ""); Utils.showToast(user.message ?? "");
} }

@ -35,8 +35,9 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: CustomAppBar( isRemoveBackButton: true, appBar: CustomAppBar(
title: LocaleKeys.signUp.tr(), isRemoveBackButton: widget.user.data!.roleId == 7 ? false : true,
title: widget.user.data!.roleId == 7 ? "" : LocaleKeys.signUp.tr(),
), ),
body: SizedBox( body: SizedBox(
width: double.infinity, width: double.infinity,
@ -47,7 +48,11 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
child: Column( child: Column(
children: [ children: [
6.height, 6.height,
LocaleKeys.completeProfile.tr().toText(height: 23 / 24, fontSize: 24, letterSpacing: -1.44,), LocaleKeys.completeProfile.tr().toText(
height: 23 / 24,
fontSize: 24,
letterSpacing: -1.44,
),
12.height, 12.height,
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
@ -55,7 +60,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
color: MyColors.lightTextColor, color: MyColors.lightTextColor,
textAlign: TextAlign.center, textAlign: TextAlign.center,
fontSize: 14, fontSize: 14,
height: 23 / 24, height: 23 / 24,
letterSpacing: -0.48, letterSpacing: -0.48,
), ),
), ),
@ -139,7 +144,12 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
title: LocaleKeys.save.tr(), title: LocaleKeys.save.tr(),
maxWidth: double.infinity, maxWidth: double.infinity,
onPressed: () { onPressed: () {
bool validateStatus = userVM.dataValidation(password: password, firstName: firstName, lastName: lastName, email: email); bool validateStatus = userVM.dataValidation(
password: password,
firstName: firstName,
lastName: lastName,
email: email,
);
if (validateStatus) { if (validateStatus) {
userVM.performCompleteProfile( userVM.performCompleteProfile(
context, context,
@ -149,6 +159,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
lastName: lastName!, lastName: lastName!,
email: email!, email: email!,
userId: widget.user.data!.userId ?? "", userId: widget.user.data!.userId ?? "",
isNeedToPassToken: widget.user.data!.isNeedToPassToken,
); );
} }
}), }),

@ -1,10 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/int_extensions.dart';
void showMyBottomSheet(BuildContext context, {required Widget child, VoidCallback? callBackFunc}) { void showMyBottomSheet(BuildContext context, {bool isDismissible = true, required Widget child, VoidCallback? callBackFunc}) {
showModalBottomSheet<String>( showModalBottomSheet<String>(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
isDismissible: isDismissible,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (BuildContext context) { builder: (BuildContext context) {
return Container( return Container(
@ -40,9 +41,10 @@ void showMyBottomSheet(BuildContext context, {required Widget child, VoidCallbac
).then((value) { ).then((value) {
// print("BACK FROM DELEGATE!!!!"); // print("BACK FROM DELEGATE!!!!");
// print("value: $value"); // print("value: $value");
if (value == "delegate_reload") { // if (value == "delegate_reload") {
if (callBackFunc != null) callBackFunc(); // if (callBackFunc != null) callBackFunc();
} // }
if (callBackFunc != null) callBackFunc();
}); });
} }

@ -23,13 +23,14 @@ extension ExtendedText on Widget {
} }
extension ContainerExt on Widget { extension ContainerExt on Widget {
Widget toWhiteContainer({required double width, double? allPading, EdgeInsets? pading, EdgeInsets? margin, VoidCallback? onTap, Color? backgroundColor, bool isBorderRequired = false}) { Widget toWhiteContainer({required double width, double? allPading, EdgeInsets? pading, EdgeInsets? margin, VoidCallback? onTap, Color? backgroundColor, bool isBorderRequired = false, double borderRadius = 0}) {
return InkWell( return InkWell(
onTap: onTap, onTap: onTap,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: isBorderRequired ? Border.all(color: MyColors.darkPrimaryColor, width: 2) : null, border: isBorderRequired ? Border.all(color: MyColors.darkPrimaryColor, width: 2) : null,
color: backgroundColor ?? MyColors.white, color: backgroundColor ?? MyColors.white,
borderRadius: BorderRadius.circular(borderRadius),
boxShadow: const [ boxShadow: const [
BoxShadow( BoxShadow(
blurRadius: 8, blurRadius: 8,
@ -76,12 +77,12 @@ extension ContainerExt on Widget {
boxShadow: !isShadowEnabled boxShadow: !isShadowEnabled
? null ? null
: [ : [
BoxShadow( BoxShadow(
color: const Color(0xff000000).withOpacity(.05), color: const Color(0xff000000).withOpacity(.05),
blurRadius: 26, blurRadius: 26,
offset: const Offset(0, -3), offset: const Offset(0, -3),
), ),
], ],
), ),
padding: padding ?? EdgeInsets.all(paddingAll), padding: padding ?? EdgeInsets.all(paddingAll),
margin: margin ?? EdgeInsets.all(marginAll), margin: margin ?? EdgeInsets.all(marginAll),
@ -355,3 +356,5 @@ extension LocaleSetup on MultiProvider {
extension WidgetExtensions on Widget { extension WidgetExtensions on Widget {
Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this); Widget onPress(VoidCallback onTap) => InkWell(onTap: onTap, child: this);
} }

Loading…
Cancel
Save