Schedules in Appointments (In Progress)
parent
026090b962
commit
fb9db7fb0b
@ -0,0 +1,180 @@
|
||||
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/widgets_models.dart';
|
||||
|
||||
class ServiceAppointmentScheduleModel {
|
||||
List<ServiceSlotList>? serviceSlotList;
|
||||
List<ItemData>? serviceItemList;
|
||||
String? selectedDate;
|
||||
String? selectedTimeSlot;
|
||||
List<TimeSlotModel>? availableDates;
|
||||
List<TimeSlotModel>? availableTimeSlots;
|
||||
double? amountToPay;
|
||||
double? amountTotal;
|
||||
double? amountRem;
|
||||
|
||||
ServiceAppointmentScheduleModel({
|
||||
this.serviceSlotList,
|
||||
this.serviceItemList,
|
||||
this.selectedDate,
|
||||
this.selectedTimeSlot,
|
||||
this.availableDates,
|
||||
this.availableTimeSlots,
|
||||
this.amountToPay,
|
||||
this.amountTotal,
|
||||
this.amountRem,
|
||||
});
|
||||
|
||||
List<TimeSlotModel> getFormattedSlotTimes() {
|
||||
var seenSlots = <TimeSlotModel>{};
|
||||
|
||||
var slotTimeData = serviceSlotList!
|
||||
.where((slot) => seenSlots.add(TimeSlotModel(
|
||||
slot: slot.startTime!,
|
||||
slotId: slot.id!,
|
||||
isSelected: false,
|
||||
)))
|
||||
.toList();
|
||||
List<TimeSlotModel> slotTime = [];
|
||||
for (var element in slotTimeData) {
|
||||
slotTime.add(TimeSlotModel(isSelected: false, slotId: element.id!, slot: element.slotDate ?? ""));
|
||||
}
|
||||
|
||||
return slotTime;
|
||||
}
|
||||
|
||||
List<TimeSlotModel> getFormattedSlotDates() {
|
||||
var seenDates = <TimeSlotModel>{};
|
||||
|
||||
var slotDatesData = serviceSlotList!
|
||||
.where((slot) => seenDates.add(TimeSlotModel(
|
||||
slot: slot.slotDate!,
|
||||
slotId: slot.id!,
|
||||
isSelected: false,
|
||||
)))
|
||||
.toList();
|
||||
List<TimeSlotModel> slotDates = [];
|
||||
for (var element in slotDatesData) {
|
||||
slotDates.add(TimeSlotModel(isSelected: false, slotId: element.id!, slot: element.slotDate!.toFormattedDateWithoutTime() ?? ""));
|
||||
}
|
||||
|
||||
return slotDates;
|
||||
}
|
||||
|
||||
//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
|
||||
|
||||
ServiceAppointmentScheduleModel.fromJson(Map<String, dynamic> json) {
|
||||
if (json['serviceSlotList'] != null) {
|
||||
serviceSlotList = <ServiceSlotList>[];
|
||||
json['serviceSlotList'].forEach((v) {
|
||||
serviceSlotList!.add(ServiceSlotList.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['serviceItemList'] != null) {
|
||||
serviceItemList = <ItemData>[];
|
||||
json['serviceItemList'].forEach((v) {
|
||||
serviceItemList!.add(ItemData.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
amountToPay = json['amountToPay'];
|
||||
selectedDate = '';
|
||||
selectedTimeSlot = '';
|
||||
availableDates = getFormattedSlotDates();
|
||||
availableTimeSlots = getFormattedSlotTimes();
|
||||
amountTotal = json['amountTotal'];
|
||||
amountRem = json['amountRem'];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
class ServiceSlotList {
|
||||
int? id;
|
||||
int? branchAppointmentScheduleID;
|
||||
String? branchAppointmentSchedule;
|
||||
int? serviceProviderID;
|
||||
String? slotDate;
|
||||
String? startTime;
|
||||
String? endTime;
|
||||
int? bookAppointment;
|
||||
int? allowAppointment;
|
||||
int? slotDurationMinute;
|
||||
int? appointmentType;
|
||||
bool? isActive;
|
||||
int? createdBy;
|
||||
String? createdOn;
|
||||
int? modifiedBy;
|
||||
String? modifiedOn;
|
||||
|
||||
ServiceSlotList(
|
||||
{this.id,
|
||||
this.branchAppointmentScheduleID,
|
||||
this.branchAppointmentSchedule,
|
||||
this.serviceProviderID,
|
||||
this.slotDate,
|
||||
this.startTime,
|
||||
this.endTime,
|
||||
this.bookAppointment,
|
||||
this.allowAppointment,
|
||||
this.slotDurationMinute,
|
||||
this.appointmentType,
|
||||
this.isActive,
|
||||
this.createdBy,
|
||||
this.createdOn,
|
||||
this.modifiedBy,
|
||||
this.modifiedOn});
|
||||
|
||||
ServiceSlotList.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
branchAppointmentScheduleID = json['branchAppointmentScheduleID'];
|
||||
branchAppointmentSchedule = json['branchAppointmentSchedule'];
|
||||
serviceProviderID = json['serviceProviderID'];
|
||||
slotDate = json['slotDate'];
|
||||
startTime = json['startTime'];
|
||||
endTime = json['endTime'];
|
||||
bookAppointment = json['bookAppointment'];
|
||||
allowAppointment = json['allowAppointment'];
|
||||
slotDurationMinute = json['slotDurationMinute'];
|
||||
appointmentType = json['appointmentType'];
|
||||
isActive = json['isActive'];
|
||||
createdBy = json['createdBy'];
|
||||
createdOn = json['createdOn'];
|
||||
modifiedBy = json['modifiedBy'];
|
||||
modifiedOn = json['modifiedOn'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['branchAppointmentScheduleID'] = branchAppointmentScheduleID;
|
||||
data['branchAppointmentSchedule'] = branchAppointmentSchedule;
|
||||
data['serviceProviderID'] = serviceProviderID;
|
||||
data['slotDate'] = slotDate;
|
||||
data['startTime'] = startTime;
|
||||
data['endTime'] = endTime;
|
||||
data['bookAppointment'] = bookAppointment;
|
||||
data['allowAppointment'] = allowAppointment;
|
||||
data['slotDurationMinute'] = slotDurationMinute;
|
||||
data['appointmentType'] = appointmentType;
|
||||
data['isActive'] = isActive;
|
||||
data['createdBy'] = createdBy;
|
||||
data['createdOn'] = createdOn;
|
||||
data['modifiedBy'] = modifiedBy;
|
||||
data['modifiedOn'] = modifiedOn;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue