|
|
|
@ -1,5 +1,6 @@
|
|
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
|
|
import 'package:mc_common_app/models/services/item_model.dart';
|
|
|
|
import 'package:mc_common_app/models/services/item_model.dart';
|
|
|
|
|
|
|
|
import 'package:mc_common_app/models/services/service_model.dart';
|
|
|
|
import 'package:mc_common_app/models/widgets_models.dart';
|
|
|
|
import 'package:mc_common_app/models/widgets_models.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class CustomTimeDateSlotModel {
|
|
|
|
class CustomTimeDateSlotModel {
|
|
|
|
@ -11,30 +12,25 @@ class CustomTimeDateSlotModel {
|
|
|
|
|
|
|
|
|
|
|
|
class ServiceAppointmentScheduleModel {
|
|
|
|
class ServiceAppointmentScheduleModel {
|
|
|
|
List<ServiceSlotList>? serviceSlotList;
|
|
|
|
List<ServiceSlotList>? serviceSlotList;
|
|
|
|
List<ItemData>? serviceItemList;
|
|
|
|
List<ServiceModel>? servicesListInAppointment;
|
|
|
|
int? selectedDateIndex;
|
|
|
|
int? selectedDateIndex;
|
|
|
|
|
|
|
|
|
|
|
|
// String? selectedTimeSlot;
|
|
|
|
|
|
|
|
// List<TimeSlotModel>? availableDates;
|
|
|
|
|
|
|
|
// List<TimeSlotModel>? availableTimeSlots;
|
|
|
|
|
|
|
|
List<CustomTimeDateSlotModel>? customTimeDateSlotList;
|
|
|
|
List<CustomTimeDateSlotModel>? customTimeDateSlotList;
|
|
|
|
CustomTimeDateSlotModel? selectedCustomTimeDateSlotModel;
|
|
|
|
CustomTimeDateSlotModel? selectedCustomTimeDateSlotModel;
|
|
|
|
double? amountToPay;
|
|
|
|
double? amountToPay;
|
|
|
|
double? amountTotal;
|
|
|
|
double? amountTotal;
|
|
|
|
double? amountRem;
|
|
|
|
double? amountRem;
|
|
|
|
|
|
|
|
int? appointmentType;
|
|
|
|
|
|
|
|
|
|
|
|
ServiceAppointmentScheduleModel({
|
|
|
|
ServiceAppointmentScheduleModel({
|
|
|
|
this.serviceSlotList,
|
|
|
|
this.serviceSlotList,
|
|
|
|
this.serviceItemList,
|
|
|
|
this.servicesListInAppointment,
|
|
|
|
this.selectedDateIndex,
|
|
|
|
this.selectedDateIndex,
|
|
|
|
// this.selectedTimeSlot,
|
|
|
|
|
|
|
|
// this.availableDates,
|
|
|
|
|
|
|
|
// this.availableTimeSlots,
|
|
|
|
|
|
|
|
this.customTimeDateSlotList,
|
|
|
|
this.customTimeDateSlotList,
|
|
|
|
this.selectedCustomTimeDateSlotModel,
|
|
|
|
this.selectedCustomTimeDateSlotModel,
|
|
|
|
this.amountToPay,
|
|
|
|
this.amountToPay,
|
|
|
|
this.amountTotal,
|
|
|
|
this.amountTotal,
|
|
|
|
this.amountRem,
|
|
|
|
this.amountRem,
|
|
|
|
|
|
|
|
this.appointmentType,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
List<CustomTimeDateSlotModel> getFormattedDateTimeSlotPackage() {
|
|
|
|
List<CustomTimeDateSlotModel> getFormattedDateTimeSlotPackage() {
|
|
|
|
@ -55,7 +51,11 @@ class ServiceAppointmentScheduleModel {
|
|
|
|
List<TimeSlotModel> timeslots = [];
|
|
|
|
List<TimeSlotModel> timeslots = [];
|
|
|
|
for (var element in serviceSlotList!) {
|
|
|
|
for (var element in serviceSlotList!) {
|
|
|
|
if (element.slotDate == date) {
|
|
|
|
if (element.slotDate == date) {
|
|
|
|
timeslots.add(TimeSlotModel(slotId: element.id!, slot: element.startTime!, date: element.slotDate!, isSelected: false, allowAppointment: element.bookAppointment! < element.allowAppointment!));
|
|
|
|
timeslots.add(TimeSlotModel(slotId: element.id!,
|
|
|
|
|
|
|
|
slot: element.startTime!,
|
|
|
|
|
|
|
|
date: element.slotDate!,
|
|
|
|
|
|
|
|
isSelected: false,
|
|
|
|
|
|
|
|
allowAppointment: element.bookAppointment! < element.allowAppointment!));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return timeslots;
|
|
|
|
return timeslots;
|
|
|
|
@ -65,12 +65,13 @@ class ServiceAppointmentScheduleModel {
|
|
|
|
var seenSlots = <TimeSlotModel>{};
|
|
|
|
var seenSlots = <TimeSlotModel>{};
|
|
|
|
|
|
|
|
|
|
|
|
var slotTimeData = serviceSlotList!
|
|
|
|
var slotTimeData = serviceSlotList!
|
|
|
|
.where((slot) => seenSlots.add(TimeSlotModel(
|
|
|
|
.where((slot) =>
|
|
|
|
slot: slot.startTime!,
|
|
|
|
seenSlots.add(TimeSlotModel(
|
|
|
|
slotId: slot.id!,
|
|
|
|
slot: slot.startTime!,
|
|
|
|
isSelected: false,
|
|
|
|
slotId: slot.id!,
|
|
|
|
date: slot.slotDate!.toFormattedDateWithoutTime(),
|
|
|
|
isSelected: false,
|
|
|
|
)))
|
|
|
|
date: slot.slotDate!.toFormattedDateWithoutTime(),
|
|
|
|
|
|
|
|
)))
|
|
|
|
.toList();
|
|
|
|
.toList();
|
|
|
|
List<TimeSlotModel> slotTime = [];
|
|
|
|
List<TimeSlotModel> slotTime = [];
|
|
|
|
for (var element in slotTimeData) {
|
|
|
|
for (var element in slotTimeData) {
|
|
|
|
@ -99,17 +100,19 @@ class ServiceAppointmentScheduleModel {
|
|
|
|
//TODO: I WILL START FROM HERE; I NEED TO ONLY PICK THE DISTINCT DATES FROM THE RESPONSE AND THEN BASED ON THE DATE SELECTION I WILL PICK THEIR SLOTS.
|
|
|
|
//TODO: I WILL START FROM HERE; I NEED TO ONLY PICK THE DISTINCT DATES FROM THE RESPONSE AND THEN BASED ON THE DATE SELECTION I WILL PICK THEIR SLOTS.
|
|
|
|
//TODO: AFTER THAT, I WILL
|
|
|
|
//TODO: AFTER THAT, I WILL
|
|
|
|
|
|
|
|
|
|
|
|
ServiceAppointmentScheduleModel.fromJson(Map<String, dynamic> json) {
|
|
|
|
ServiceAppointmentScheduleModel.fromJson
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(Map<String, dynamic> json, {bool isForAppointment = false}) {
|
|
|
|
if (json['serviceSlotList'] != null) {
|
|
|
|
if (json['serviceSlotList'] != null) {
|
|
|
|
serviceSlotList = <ServiceSlotList>[];
|
|
|
|
serviceSlotList = <ServiceSlotList>[];
|
|
|
|
json['serviceSlotList'].forEach((v) {
|
|
|
|
json['serviceSlotList'].forEach((v) {
|
|
|
|
serviceSlotList!.add(ServiceSlotList.fromJson(v));
|
|
|
|
serviceSlotList!.add(ServiceSlotList.fromJson(v));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (json['serviceItemList'] != null) {
|
|
|
|
if (json['serviceList'] != null) {
|
|
|
|
serviceItemList = <ItemData>[];
|
|
|
|
servicesListInAppointment = <ServiceModel>[];
|
|
|
|
json['serviceItemList'].forEach((v) {
|
|
|
|
json['serviceList'].forEach((v) {
|
|
|
|
serviceItemList!.add(ItemData.fromJson(v));
|
|
|
|
servicesListInAppointment!.add(ServiceModel.fromJson(v, isForAppointment: isForAppointment));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
customTimeDateSlotList = getFormattedDateTimeSlotPackage();
|
|
|
|
customTimeDateSlotList = getFormattedDateTimeSlotPackage();
|
|
|
|
@ -117,20 +120,7 @@ class ServiceAppointmentScheduleModel {
|
|
|
|
selectedDateIndex = null;
|
|
|
|
selectedDateIndex = null;
|
|
|
|
amountTotal = json['amountTotal'];
|
|
|
|
amountTotal = json['amountTotal'];
|
|
|
|
amountRem = json['amountRem'];
|
|
|
|
amountRem = json['amountRem'];
|
|
|
|
}
|
|
|
|
appointmentType = json['appointmentType'];
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
|
|
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
|
|
|
|
|
|
if (serviceSlotList != null) {
|
|
|
|
|
|
|
|
data['serviceSlotList'] = serviceSlotList!.map((v) => v.toJson()).toList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (serviceItemList != null) {
|
|
|
|
|
|
|
|
data['serviceItemList'] = serviceItemList!.map((v) => v.toJson()).toList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data['amountToPay'] = amountToPay;
|
|
|
|
|
|
|
|
data['amountTotal'] = amountTotal;
|
|
|
|
|
|
|
|
data['amountRem'] = amountRem;
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -152,23 +142,22 @@ class ServiceSlotList {
|
|
|
|
int? modifiedBy;
|
|
|
|
int? modifiedBy;
|
|
|
|
String? modifiedOn;
|
|
|
|
String? modifiedOn;
|
|
|
|
|
|
|
|
|
|
|
|
ServiceSlotList(
|
|
|
|
ServiceSlotList({this.id,
|
|
|
|
{this.id,
|
|
|
|
this.branchAppointmentScheduleID,
|
|
|
|
this.branchAppointmentScheduleID,
|
|
|
|
this.branchAppointmentSchedule,
|
|
|
|
this.branchAppointmentSchedule,
|
|
|
|
this.serviceProviderID,
|
|
|
|
this.serviceProviderID,
|
|
|
|
this.slotDate,
|
|
|
|
this.slotDate,
|
|
|
|
this.startTime,
|
|
|
|
this.startTime,
|
|
|
|
this.endTime,
|
|
|
|
this.endTime,
|
|
|
|
this.bookAppointment,
|
|
|
|
this.bookAppointment,
|
|
|
|
this.allowAppointment,
|
|
|
|
this.allowAppointment,
|
|
|
|
this.slotDurationMinute,
|
|
|
|
this.slotDurationMinute,
|
|
|
|
this.appointmentType,
|
|
|
|
this.appointmentType,
|
|
|
|
this.isActive,
|
|
|
|
this.isActive,
|
|
|
|
this.createdBy,
|
|
|
|
this.createdBy,
|
|
|
|
this.createdOn,
|
|
|
|
this.createdOn,
|
|
|
|
this.modifiedBy,
|
|
|
|
this.modifiedBy,
|
|
|
|
this.modifiedOn});
|
|
|
|
this.modifiedOn});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ServiceSlotList.fromJson(Map<String, dynamic> json) {
|
|
|
|
ServiceSlotList.fromJson(Map<String, dynamic> json) {
|
|
|
|
id = json['id'];
|
|
|
|
id = json['id'];
|
|
|
|
|