|
|
|
@ -1,4 +1,5 @@
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'dart:developer';
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
|
|
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
|
|
import 'package:mc_common_app/utils/navigator.dart';
|
|
|
|
import 'package:mc_common_app/utils/navigator.dart';
|
|
|
|
@ -15,10 +16,15 @@ import 'package:mc_common_app/widgets/checkbox_with_title_desc.dart';
|
|
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
|
|
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
|
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
|
|
|
import 'package:mc_common_app/widgets/txt_field.dart';
|
|
|
|
import 'package:mc_common_app/widgets/txt_field.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// [log] 1035 -> branch ID
|
|
|
|
|
|
|
|
// [log] HMG Branch QA II -> branchName
|
|
|
|
|
|
|
|
// [log] 8 -> category ID
|
|
|
|
|
|
|
|
// [log] Sell Car -> categegory name
|
|
|
|
|
|
|
|
// [log] New Car -> service name
|
|
|
|
|
|
|
|
|
|
|
|
class CreateServicesPage3 extends StatefulWidget {
|
|
|
|
class CreateServicesPage3 extends StatefulWidget {
|
|
|
|
final CreateBranchModel? branchModel;
|
|
|
|
final CreateBranchModel? branchModel;
|
|
|
|
|
|
|
|
|
|
|
|
@ -41,19 +47,23 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
scheduleMicrotask(() {
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
ServiceVM serviceVM = context.read<ServiceVM>();
|
|
|
|
ServiceVM serviceVM = context.read<ServiceVM>();
|
|
|
|
if (widget.branchModel!.categoryId == null) {
|
|
|
|
if (widget.branchModel!.categoryId != null) {
|
|
|
|
serviceVM.fetchBranchCategory(EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA");
|
|
|
|
await serviceVM.fetchServicesByCategoryId(int.parse(widget.branchModel!.categoryId ?? "0"));
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
category = DropValue(int.parse(widget.branchModel!.categoryId ?? "0"), widget.branchModel!.categoryName ?? "", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
service = serviceVM.servicesDropList.firstWhere((element) => element.id == widget.branchModel!.serviceProviderService!.serviceId);
|
|
|
|
|
|
|
|
|
|
|
|
isAppointmentAvailable = widget.branchModel?.serviceProviderService?.isAllowAppointment ?? false;
|
|
|
|
isAppointmentAvailable = widget.branchModel?.serviceProviderService?.isAllowAppointment ?? false;
|
|
|
|
// isHomeAppointmentAvailable=branchModel.serviceProviderService.
|
|
|
|
|
|
|
|
serviceRage = widget.branchModel?.serviceProviderService?.customerLocationRange ?? 0;
|
|
|
|
serviceRage = widget.branchModel?.serviceProviderService?.customerLocationRange ?? 0;
|
|
|
|
if (serviceRage > 0) {
|
|
|
|
if (serviceRage > 0) {
|
|
|
|
isHomeAppointmentAvailable = true;
|
|
|
|
isHomeAppointmentAvailable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chargersPerKm = widget.branchModel?.serviceProviderService?.rangePricePerKm ?? "";
|
|
|
|
chargersPerKm = widget.branchModel?.serviceProviderService?.rangePricePerKm ?? "";
|
|
|
|
serviceId = widget.branchModel?.serviceProviderService?.serviceId ?? -1;
|
|
|
|
serviceId = widget.branchModel?.serviceProviderService?.serviceProviderServiceId ?? -1;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -61,7 +71,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
return Scaffold(
|
|
|
|
appBar: CustomAppBar(title: LocaleKeys.addServices.tr()),
|
|
|
|
appBar: CustomAppBar(title: LocaleKeys.editServices.tr()),
|
|
|
|
body: SizedBox(
|
|
|
|
body: SizedBox(
|
|
|
|
width: double.infinity,
|
|
|
|
width: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
height: double.infinity,
|
|
|
|
@ -75,87 +85,46 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
// Text(
|
|
|
|
|
|
|
|
// widget.branchModel!.branchName ?? "N/A",
|
|
|
|
|
|
|
|
// style: const TextStyle(
|
|
|
|
|
|
|
|
// fontSize: 12,
|
|
|
|
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// ).toContainer(
|
|
|
|
|
|
|
|
// padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12, top: 12),
|
|
|
|
|
|
|
|
// backgroundColor: MyColors.textFieldColor,
|
|
|
|
|
|
|
|
// borderRadius: 0,
|
|
|
|
|
|
|
|
// width: double.infinity,
|
|
|
|
|
|
|
|
// ),
|
|
|
|
|
|
|
|
// 12.height,
|
|
|
|
|
|
|
|
(widget.branchModel!.categoryId != null)
|
|
|
|
(widget.branchModel!.categoryId != null)
|
|
|
|
? Text(
|
|
|
|
? DropdownField(
|
|
|
|
widget.branchModel!.categoryName ?? "N/A",
|
|
|
|
isSelectAble: false,
|
|
|
|
style: const TextStyle(
|
|
|
|
(DropValue value) async {
|
|
|
|
fontSize: 12,
|
|
|
|
// categoryId = value.id;
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
// category = value;
|
|
|
|
),
|
|
|
|
// service = null;
|
|
|
|
).toContainer(
|
|
|
|
// serviceId = -1;
|
|
|
|
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12, top: 12),
|
|
|
|
// isAppointmentAvailable = false;
|
|
|
|
backgroundColor: MyColors.textFieldColor,
|
|
|
|
// isHomeAppointmentAvailable = false;
|
|
|
|
borderRadius: 0,
|
|
|
|
// model.fetchServicesByCategoryId(value.id);
|
|
|
|
width: double.infinity,
|
|
|
|
},
|
|
|
|
|
|
|
|
dropdownValue: category,
|
|
|
|
|
|
|
|
list: model.categoryDropList,
|
|
|
|
|
|
|
|
hint: category != null ? category!.value : LocaleKeys.selectServiceCategory.tr(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: (widget.branchModel!.categoryId == null && model.categoryDropList.isNotEmpty)
|
|
|
|
: const CircularProgressIndicator(),
|
|
|
|
? DropdownField(
|
|
|
|
|
|
|
|
(DropValue value) async {
|
|
|
|
|
|
|
|
categoryId = value.id;
|
|
|
|
|
|
|
|
category = value;
|
|
|
|
|
|
|
|
service = null;
|
|
|
|
|
|
|
|
serviceId = -1;
|
|
|
|
|
|
|
|
isAppointmentAvailable = false;
|
|
|
|
|
|
|
|
isHomeAppointmentAvailable = false;
|
|
|
|
|
|
|
|
model.fetchServicesByCategoryId(value.id);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
dropdownValue: category,
|
|
|
|
|
|
|
|
list: model.categoryDropList,
|
|
|
|
|
|
|
|
hint: LocaleKeys.selectServiceCategory.tr(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: const CircularProgressIndicator(),
|
|
|
|
|
|
|
|
12.height,
|
|
|
|
12.height,
|
|
|
|
widget.branchModel!.serviceProviderService != null
|
|
|
|
model.servicesDropList.isNotEmpty
|
|
|
|
? Text(
|
|
|
|
? DropdownField(
|
|
|
|
widget.branchModel!.serviceProviderService!.serviceDescription ?? "N/A",
|
|
|
|
(DropValue value) {
|
|
|
|
style: const TextStyle(
|
|
|
|
service = value;
|
|
|
|
fontSize: 12,
|
|
|
|
isAppointmentAvailable = false;
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
isHomeAppointmentAvailable = false;
|
|
|
|
),
|
|
|
|
model.setState(ViewState.idle);
|
|
|
|
).toContainer(
|
|
|
|
},
|
|
|
|
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12, top: 12),
|
|
|
|
dropdownValue: service,
|
|
|
|
backgroundColor: MyColors.textFieldColor,
|
|
|
|
list: model.servicesDropList,
|
|
|
|
borderRadius: 0,
|
|
|
|
hint: LocaleKeys.defineServices.tr(),
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: model.servicesDropList.isNotEmpty
|
|
|
|
: Container(),
|
|
|
|
? DropdownField(
|
|
|
|
|
|
|
|
(DropValue value) {
|
|
|
|
|
|
|
|
serviceId = value.id;
|
|
|
|
|
|
|
|
service = value;
|
|
|
|
|
|
|
|
isAppointmentAvailable = false;
|
|
|
|
|
|
|
|
isHomeAppointmentAvailable = false;
|
|
|
|
|
|
|
|
model.setState(ViewState.idle);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
dropdownValue: service,
|
|
|
|
|
|
|
|
list: model.servicesDropList,
|
|
|
|
|
|
|
|
hint: LocaleKeys.defineServices.tr(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: categoryId == null
|
|
|
|
|
|
|
|
? Container()
|
|
|
|
|
|
|
|
: const CircularProgressIndicator(),
|
|
|
|
|
|
|
|
12.height,
|
|
|
|
12.height,
|
|
|
|
if (serviceId != -1)
|
|
|
|
if (serviceId != -1) ...[
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
20.height,
|
|
|
|
20.height,
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
isSelected: isAppointmentAvailable,
|
|
|
|
isSelected: isAppointmentAvailable,
|
|
|
|
title: 'Available for appointment',
|
|
|
|
title: LocaleKeys.availableforAppointment.tr(),
|
|
|
|
description: 'This option will allow customer to book appointment for these services',
|
|
|
|
description: LocaleKeys.bookAppointmentForServices.tr(),
|
|
|
|
onSelection: (bool v) {
|
|
|
|
onSelection: (bool v) {
|
|
|
|
isAppointmentAvailable = v;
|
|
|
|
isAppointmentAvailable = v;
|
|
|
|
model.setState(ViewState.idle);
|
|
|
|
model.setState(ViewState.idle);
|
|
|
|
@ -164,8 +133,8 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
20.height,
|
|
|
|
20.height,
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
isSelected: isHomeAppointmentAvailable,
|
|
|
|
isSelected: isHomeAppointmentAvailable,
|
|
|
|
title: 'Allow home services',
|
|
|
|
title: LocaleKeys.allowingHomeService.tr(),
|
|
|
|
description: 'This option will allow customer to book appointment at their desired location',
|
|
|
|
description: LocaleKeys.bookAppointmentAtLocation.tr(),
|
|
|
|
onSelection: (bool v) {
|
|
|
|
onSelection: (bool v) {
|
|
|
|
isHomeAppointmentAvailable = v;
|
|
|
|
isHomeAppointmentAvailable = v;
|
|
|
|
model.setState(ViewState.idle);
|
|
|
|
model.setState(ViewState.idle);
|
|
|
|
@ -176,7 +145,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
Column(
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
TxtField(
|
|
|
|
TxtField(
|
|
|
|
hint: "Home Services Range",
|
|
|
|
hint: LocaleKeys.homeServiceRange.tr(),
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
value: serviceRage == 0 ? null : serviceRage.toString(),
|
|
|
|
value: serviceRage == 0 ? null : serviceRage.toString(),
|
|
|
|
postfixWidget: Row(
|
|
|
|
postfixWidget: Row(
|
|
|
|
@ -197,7 +166,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
12.height,
|
|
|
|
12.height,
|
|
|
|
TxtField(
|
|
|
|
TxtField(
|
|
|
|
hint: "Charges per Kilometer",
|
|
|
|
hint: LocaleKeys.chargesPerKM.tr(),
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
value: chargersPerKm == "" ? null : chargersPerKm,
|
|
|
|
value: chargersPerKm == "" ? null : chargersPerKm,
|
|
|
|
onChanged: (v) {
|
|
|
|
onChanged: (v) {
|
|
|
|
@ -220,6 +189,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
@ -229,7 +199,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
ShowFillButton(
|
|
|
|
ShowFillButton(
|
|
|
|
title: LocaleKeys.save.tr(),
|
|
|
|
title: LocaleKeys.save.tr(),
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
margin: const EdgeInsets.symmetric(horizontal: 20),
|
|
|
|
margin: const EdgeInsets.all(20),
|
|
|
|
onPressed: () {
|
|
|
|
onPressed: () {
|
|
|
|
if (widget.branchModel!.serviceProviderService != null) {
|
|
|
|
if (widget.branchModel!.serviceProviderService != null) {
|
|
|
|
updateService(context, model);
|
|
|
|
updateService(context, model);
|
|
|
|
@ -267,7 +237,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isActive": true,
|
|
|
|
"isActive": true,
|
|
|
|
"customerLocationRange": serviceRage,
|
|
|
|
"customerLocationRange": serviceRage,
|
|
|
|
"rangePricePerKm": chargersPerKm
|
|
|
|
"rangePricePerKm": chargersPerKm.isEmpty ? "0.0" : chargersPerKm,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
map.add(postParams);
|
|
|
|
map.add(postParams);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -278,13 +248,33 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
await model.getBranchAndServices();
|
|
|
|
await model.getBranchAndServices();
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.showToast(mResponse.message ?? "");
|
|
|
|
Utils.showToast(mResponse.message ?? "");
|
|
|
|
pop(context);
|
|
|
|
if (mResponse.messageStatus == 1) {
|
|
|
|
|
|
|
|
context.read<ServiceVM>().filterUserBranchCategories();
|
|
|
|
|
|
|
|
pop(context);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateService(BuildContext context, ServiceVM model) async {
|
|
|
|
updateService(BuildContext context, ServiceVM model) async {
|
|
|
|
List<Map<String, dynamic>> map = [
|
|
|
|
List<Map<String, dynamic>> map = [];
|
|
|
|
{"id": widget.branchModel!.serviceProviderService!.serviceId.toString(), "isAllowAppointment": isAppointmentAvailable, "isActive": true, "customerLocationRange": serviceRage, "rangePricePerKm": chargersPerKm}
|
|
|
|
if (isHomeAppointmentAvailable) {
|
|
|
|
];
|
|
|
|
map = [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"id": widget.branchModel!.serviceProviderService!.serviceProviderServiceId.toString(),
|
|
|
|
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
|
|
|
|
"isActive": true,
|
|
|
|
|
|
|
|
"customerLocationRange": serviceRage,
|
|
|
|
|
|
|
|
"rangePricePerKm": chargersPerKm.isEmpty ? "0.0" : chargersPerKm,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
map = [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"id": widget.branchModel!.serviceProviderService!.serviceProviderServiceId.toString(),
|
|
|
|
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
|
|
|
|
"isActive": true,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// print(map);
|
|
|
|
// print(map);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
@ -293,6 +283,9 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
model.filterUserBranchCategories();
|
|
|
|
model.filterUserBranchCategories();
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.showToast(mResponse.message ?? "");
|
|
|
|
Utils.showToast(mResponse.message ?? "");
|
|
|
|
pop(context);
|
|
|
|
if (mResponse.messageStatus == 1) {
|
|
|
|
|
|
|
|
context.read<ServiceVM>().filterUserBranchCategories();
|
|
|
|
|
|
|
|
pop(context);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|