diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 4c44d80..7ebeb78 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -101,6 +101,10 @@ class ApiConsts { static String paymentWebViewUrl = "https://ms.hmg.com/pay/PaymentHome"; static String payForOrderDetailGet = "${baseUrlServices}api/Payment/PayFortOrderDetail_Get"; + //Duplicate Services + static String getMatchedServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchServicesMapping_Get"; + static String duplicateItems = "${baseUrlServices}api/ServiceProviders/ServiceItemCopy_Create"; + static List closingUrls = ["PayFortResponse"]; } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index f9b9f66..b72d532 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -5,21 +5,21 @@ import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/enums.dart'; extension EmailValidator on String { - Widget toText({Color? color, - bool isBold = false, - double? fontSize, - bool isUnderLine = false, - bool isItalic = false, - TextDecoration? textDecoration, - double letterSpacing = -0.4, - TextAlign? textAlign, - double? height, - int? maxLines}) => + Widget toText( + {Color? color, + bool isBold = false, + double? fontSize, + bool isUnderLine = false, + bool isItalic = false, + TextDecoration? textDecoration, + double letterSpacing = -0.4, + TextAlign? textAlign, + double? height, + int? maxLines}) => AutoSizeText( this, textAlign: textAlign, maxLines: maxLines, - style: TextStyle( fontStyle: isItalic ? FontStyle.italic : null, height: height, @@ -180,6 +180,46 @@ extension AdPostEnum on int { } } +extension BranchsEnum on int { + BranchStatusEnum toBranchStatusEnum() { + if (this == 1) { + return BranchStatusEnum.pending; + } else if (this == 2) { + return BranchStatusEnum.review; + } else if (this == 3) { + return BranchStatusEnum.approvedOrActive; + } else if (this == 4) { + return BranchStatusEnum.rejected; + } else if (this == 5) { + return BranchStatusEnum.blocked; + } else if (this == 6) { + return BranchStatusEnum.deactivated; + } else { + return BranchStatusEnum.pending; + } + } +} + +extension ServiceEnum on int { + ServiceStatusEnum toServiceStatusEnum() { + if (this == 1) { + return ServiceStatusEnum.pending; + } else if (this == 2) { + return ServiceStatusEnum.review; + } else if (this == 3) { + return ServiceStatusEnum.approvedOrActive; + } else if (this == 4) { + return ServiceStatusEnum.rejected; + } else if (this == 5) { + return ServiceStatusEnum.blocked; + } else if (this == 6) { + return ServiceStatusEnum.deactivated; + } else { + return ServiceStatusEnum.pending; + } + } +} + extension DateTimeConversions on DateTime { String getTimeAgo({bool numericDates = true}) { final date2 = DateTime.now(); diff --git a/lib/models/model/provider_model.dart b/lib/models/model/provider_model.dart new file mode 100644 index 0000000..97ce37e --- /dev/null +++ b/lib/models/model/provider_model.dart @@ -0,0 +1,91 @@ +// To parse this JSON data, do +// +// final branch2 = branch2FromJson(jsonString); + +import 'dart:convert'; + +import 'package:mc_common_app/models/profile/categroy.dart'; +import 'package:mc_common_app/models/services/branch_model.dart'; + +ProviderModel branch2FromJson(String str) => ProviderModel.fromJson(json.decode(str)); + +String branch2ToJson(ProviderModel data) => json.encode(data.toJson()); + +class ProviderModel { + ProviderModel({ + this.messageStatus, + this.totalItemsCount, + this.data, + this.message, + }); + + final int? messageStatus; + final int? totalItemsCount; + final ProviderModelData? data; + final String? message; + + factory ProviderModel.fromJson(Map json) => + ProviderModel( + messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], + totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"], + data: json["data"] == null ? null : ProviderModelData.fromJson(json["data"]), + message: json["message"] == null ? null : json["message"], + ); + + Map toJson() => + { + "messageStatus": messageStatus == null ? null : messageStatus, + "totalItemsCount": totalItemsCount == null ? null : totalItemsCount, + "data": data == null ? null : data!.toJson(), + "message": message == null ? null : message, + }; +} + +class ProviderModelData { + ProviderModelData({ + this.id, + this.companyName, + this.countryName, + this.companyDescription, + this.allDocStatus, + this.isValidSubscription, + this.userId, + this.serviceProviderBranch, + this.countryID, + }); + + final int? id; + final String? companyName; + final String? countryName; + int? countryID; + final String? companyDescription; + final int? allDocStatus; + final bool? isValidSubscription; + final String? userId; + final List? serviceProviderBranch; + + factory ProviderModelData.fromJson(Map json) => + ProviderModelData( + id: json["id"] == null ? null : json["id"], + companyName: json["companyName"] == null ? null : json["companyName"], + countryName: json["countryName"] == null ? null : json["countryName"], + countryID: json["countryID"] == null ? null : json["countryID"], + companyDescription: json["companyDescription"] == null ? null : json["companyDescription"], + allDocStatus: json["allDocStatus"] == null ? null : json["allDocStatus"], + isValidSubscription: json["isValidSubscription"] == null ? null : json["isValidSubscription"], + userId: json["userID"] == null ? null : json["userID"], + serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List.from(json["serviceProviderBranch"].map((x) => BranchModel.fromJson(x))), + ); + + Map toJson() => + { + "id": id == null ? null : id, + "companyName": companyName == null ? null : companyName, + "companyDescription": companyDescription == null ? null : companyDescription, + "allDocStatus": allDocStatus == null ? null : allDocStatus, + "isValidSubscription": isValidSubscription == null ? null : isValidSubscription, + "userID": userId == null ? null : userId, + "serviceProviderBranch": serviceProviderBranch == null ? null : List.from(serviceProviderBranch!.map((x) => x.toJson())), + }; +} + diff --git a/lib/models/provider_branches_models/branch_detail_model.dart b/lib/models/provider_branches_models/branch_detail_model.dart index 1c08508..dfc56ca 100644 --- a/lib/models/provider_branches_models/branch_detail_model.dart +++ b/lib/models/provider_branches_models/branch_detail_model.dart @@ -1,7 +1,9 @@ -import 'package:mc_common_app/models/provider_branches_models/profile/categroy.dart'; -import 'package:mc_common_app/models/services/branch_service_model.dart'; +import 'package:mc_common_app/extensions/string_extensions.dart'; +import 'package:mc_common_app/models/profile/categroy.dart'; +import 'package:mc_common_app/models/services/service_model.dart'; +import 'package:mc_common_app/utils/enums.dart'; -class BranchDetailModel { +class BranchModel { final int? id; final int? serviceProviderId; final String? serviceProviderName; @@ -14,13 +16,16 @@ class BranchDetailModel { final double? distanceKm; final String? openTime; final String? closeTime; - final int? status; + final BranchStatusEnum? branchStatus; + final int? statusId; final dynamic statusText; - final List? branchServices; + final List? branchServices; List? categories; + int? countryID; + String? countryName; bool isExpanded; - BranchDetailModel({ + BranchModel({ this.id, this.serviceProviderId, this.serviceProviderName, @@ -33,14 +38,17 @@ class BranchDetailModel { this.distanceKm, this.openTime, this.closeTime, - this.status, + this.branchStatus, + this.statusId, this.statusText, this.branchServices, this.categories, + this.countryID, + this.countryName, required this.isExpanded, }); - factory BranchDetailModel.fromJson(Map json) => BranchDetailModel( + factory BranchModel.fromJson(Map json) => BranchModel( id: json["id"], serviceProviderId: json["serviceProviderID"], serviceProviderName: json["serviceProviderName"], @@ -53,9 +61,10 @@ class BranchDetailModel { distanceKm: json["distanceKM"]?.toDouble(), openTime: json["openTime"], closeTime: json["closeTime"], - status: json["status"], + branchStatus: (json['branchStatus'] as int).toBranchStatusEnum(), + statusId: json["branchStatus"], statusText: json["statusText"], - branchServices: json["serviceProviderServices"] == null ? [] : List.from(json["serviceProviderServices"]!.map((x) => BranchServiceModel.fromJson(x))), + branchServices: json["serviceProviderServices"] == null ? [] : List.from(json["serviceProviderServices"]!.map((x) => ServiceModel.fromJson(x))), categories: [], isExpanded: false, ); @@ -73,7 +82,7 @@ class BranchDetailModel { "distanceKM": distanceKm, "openTime": openTime, "closeTime": closeTime, - "status": status, + "status": statusId, "statusText": statusText, "serviceProviderServices": branchServices == null ? [] : List.from(branchServices!.map((x) => x.toJson())), }; diff --git a/lib/models/services/branch_service_model.dart b/lib/models/services/branch_service_model.dart index 44cf8d4..3d04657 100644 --- a/lib/models/services/branch_service_model.dart +++ b/lib/models/services/branch_service_model.dart @@ -1,4 +1,6 @@ -class BranchServiceModel { +import 'package:mc_common_app/models/services/item_model.dart'; + +class ServiceModel { final int? serviceProviderServiceId; final dynamic providerServiceDescription; final int? categoryId; @@ -13,9 +15,10 @@ class BranchServiceModel { final int? customerLocationRange; final String? rangePricePerKm; final int? itemsCount; - bool isExpanded; + List? serviceItems; + bool isExpandedOrSelected; - BranchServiceModel({ + ServiceModel({ this.serviceProviderServiceId, this.providerServiceDescription, this.categoryId, @@ -30,17 +33,19 @@ class BranchServiceModel { this.customerLocationRange, this.rangePricePerKm, this.itemsCount, - required this.isExpanded, + this.serviceItems, + required this.isExpandedOrSelected, }); - factory BranchServiceModel.fromJson(Map json) => BranchServiceModel( + factory ServiceModel.fromJson(Map json) => + ServiceModel( serviceProviderServiceId: json["serviceProviderServiceID"], providerServiceDescription: json["providerServiceDescription"], categoryId: json["categoryID"], categoryName: json["categoryName"], serviceId: json["serviceID"], serviceDescription: json["serviceDescription"] ?? json["serviceName"], - serviceDescriptionN: json["serviceDescriptionN"]?? json["serviceNameN"], + serviceDescriptionN: json["serviceDescriptionN"] ?? json["serviceNameN"], serviceStatus: json["serviceStatus"], statusText: json["statusText"], isAllowAppointment: json["isAllowAppointment"], @@ -48,10 +53,12 @@ class BranchServiceModel { customerLocationRange: json["customerLocationRange"], rangePricePerKm: json["rangePricePerKm"].toString(), itemsCount: json["itemsCount"], - isExpanded: false, + serviceItems: json["branchServiceItems"] == null ? [] : List.from(json["branchServiceItems"]!.map((x) => ItemData.fromJson(x))), + isExpandedOrSelected: false, ); - Map toJson() => { + Map toJson() => + { "serviceProviderServiceID": serviceProviderServiceId, "providerServiceDescription": providerServiceDescription, "categoryID": categoryId, @@ -66,5 +73,6 @@ class BranchServiceModel { "customerLocationRange": customerLocationRange, "rangePricePerKm": rangePricePerKm, "itemsCount": itemsCount, + "branchServiceItems": serviceItems == null ? [] : List.from(serviceItems!.map((x) => x.toJson())), }; } diff --git a/lib/models/services/item_model.dart b/lib/models/services/item_model.dart index 8d37bbe..4cd35cf 100644 --- a/lib/models/services/item_model.dart +++ b/lib/models/services/item_model.dart @@ -13,7 +13,7 @@ class ServiceItemModel { final bool? isAllowAppointment; final bool? isAppointmentCompanyLoc; final bool? isAppointmentCustomerLoc; - bool? isUpdate; + bool? isUpdateOrSelected; ServiceItemModel({ this.id, @@ -28,7 +28,7 @@ class ServiceItemModel { this.isAllowAppointment, this.isAppointmentCompanyLoc, this.isAppointmentCustomerLoc, - this.isUpdate, + this.isUpdateOrSelected, }); factory ServiceItemModel.fromJson(Map json) => ServiceItemModel( @@ -44,7 +44,7 @@ class ServiceItemModel { isAllowAppointment: json["isAllowAppointment"], isAppointmentCompanyLoc: json["isAppointmentCompanyLoc"], isAppointmentCustomerLoc: json["isAppointmentCustomerLoc"], - isUpdate: false, + isUpdateOrSelected: false, ); Map toJson() => { diff --git a/lib/utils/enums.dart b/lib/utils/enums.dart index c795bef..dc9e841 100644 --- a/lib/utils/enums.dart +++ b/lib/utils/enums.dart @@ -67,7 +67,7 @@ enum LoginType { enum AppType { provider, customer } -enum ServiceStatus { +enum ServiceStatusEnum { pending, //1 review, //2 approvedOrActive, //3 @@ -75,3 +75,20 @@ enum ServiceStatus { blocked, //5 deactivated, //6 } + +enum DocumentStatusEnum { + needUpload, // 0 + pending, // 1 + review, // 2 + approvedOrActive, // 3 + rejected // 4 +} + +enum BranchStatusEnum { + pending, // 1 + review, // 2 + approvedOrActive, // 3 + rejected, // 4 + blocked, // 5 + deactivated // 6 +} diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 54e0a3e..b7dbc27 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -214,6 +214,7 @@ class Utils { } } + static statusContainerChip({required String text, EdgeInsetsGeometry padding = const EdgeInsets.symmetric(vertical: 3, horizontal: 6), Color chipColor = MyColors.greenColor}) { return Container( decoration: BoxDecoration( diff --git a/lib/widgets/dropdown/dropdown_text.dart b/lib/widgets/dropdown/dropdown_text.dart index bcf476d..079ee26 100644 --- a/lib/widgets/dropdown/dropdown_text.dart +++ b/lib/widgets/dropdown/dropdown_text.dart @@ -1,29 +1,32 @@ - import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/theme/colors.dart'; +import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; class DropDownText extends StatelessWidget { String title; - DropDownText(this.title); + DropDownText(this.title, {super.key}); @override Widget build(BuildContext context) { return Row( crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - title.toText(color: accentColor, fontSize: 16, letterSpacing: -0.64,), - 16.height, - SvgPicture.asset( - "assets/ic_arrow_down.svg", - width: 10, - height: 10, + title.toText( + fontSize: 16, + letterSpacing: -0.64, ), + const Icon(Icons.keyboard_arrow_down_outlined), ], + ).toContainer( + isEnabledBorder: true, + borderRadius: 0, + borderColor: MyColors.primaryColor, + borderWidget: 2, ); } } diff --git a/lib/widgets/tab/menu_tabs.dart b/lib/widgets/tab/menu_tabs.dart index 2a38bef..88e12d1 100644 --- a/lib/widgets/tab/menu_tabs.dart +++ b/lib/widgets/tab/menu_tabs.dart @@ -9,7 +9,6 @@ class MenuTabs extends StatefulWidget { Function(DropValue value) onSelect; Color? selectedColor; - MenuTabs(this.selectedIndex, this.dropList, {required this.onSelect, this.selectedColor}); @override