Schedules in Appointments (In Progress)

pull/3/head
FaizHashmiCS22 3 years ago
parent 026090b962
commit fb9db7fb0b

@ -50,6 +50,7 @@ class ApiConsts {
static String ServiceProviderService_Get = "${baseUrlServices}api/ServiceProviders/ServiceProviderService_Get";
static String BranchesAndServices = "${baseUrlServices}api/ServiceProviders/ServiceProviderDetail_Get";
static String GetAllNearBranches = "${baseUrlServices}api/ServiceProviders/ServiceProviderBranchDetail_Get";
static String GetServiceItemAppointmentScheduleSlots = "${baseUrlServices}api/ServiceProviders/ServiceItemAppointmentScheduleSlots_Get";
//Appointment APIs
static String serviceProvidersAppointmentGet = "${baseUrlServices}api/ServiceProviders/ServiceProvidersAppointment_Get";

@ -4,6 +4,8 @@
import 'dart:convert';
import 'package:mc_common_app/models/services/service_model.dart';
Schedule scheduleFromJson(String str) => Schedule.fromJson(json.decode(str));
String scheduleToJson(Schedule data) => json.encode(data.toJson());
@ -53,7 +55,8 @@ class ScheduleData {
final String? latitude;
final String? longitude;
final List<WeeklyOffDay>? weeklyOffDays;
final List<ScheduleService>? scheduleServices;
final List<ServiceModel>? scheduleServices;
final List<ServiceModel>? selectedServices;
String branchId;
ScheduleData({
@ -72,6 +75,7 @@ class ScheduleData {
this.longitude,
this.weeklyOffDays,
this.scheduleServices,
this.selectedServices,
this.branchId = "",
});
@ -91,7 +95,8 @@ class ScheduleData {
latitude: json["latitude"],
longitude: json["longitude"],
weeklyOffDays: json["weeklyOffDays"] == null ? [] : List<WeeklyOffDay>.from(json["weeklyOffDays"]!.map((x) => WeeklyOffDay.fromJson(x))),
scheduleServices: json["scheduleServices"] == null ? [] : List<ScheduleService>.from(json["scheduleServices"]!.map((x) => ScheduleService.fromJson(x))),
scheduleServices: json["scheduleServices"] == null ? [] : List<ServiceModel>.from(json["scheduleServices"]!.map((x) => ServiceModel.fromJson(x))),
selectedServices: [],
);
Map<String, dynamic> toJson() =>
@ -111,33 +116,14 @@ class ScheduleData {
"longitude": longitude,
"scheduleServices": scheduleServices == null ? [] : List<dynamic>.from(scheduleServices!.map((x) => x.toJson())),
};
}
class ScheduleService {
final int? providerServiceId;
// final int? branchScheduleGroupServiceID;
final String? providerServiceName;
ScheduleService({
this.providerServiceId,
// this.branchScheduleGroupServiceID,
this.providerServiceName,
});
factory ScheduleService.fromJson(Map<String, dynamic> json) =>
ScheduleService(
providerServiceId: json["providerServiceID"],
// branchScheduleGroupServiceID: json["branchScheduleGroupServiceID"],
providerServiceName: json["providerServiceName"],
);
Map<String, dynamic> toJson() =>
{
"providerServiceID": providerServiceId,
"providerServiceName": providerServiceName,
};
@override
String toString() {
return 'ScheduleData{id: $id, scheduleName: $scheduleName, serviceProviderBranchId: $serviceProviderBranchId, fromDate: $fromDate, toDate: $toDate, startTime: $startTime, endTime: $endTime, slotDurationMinute: $slotDurationMinute, perSlotAppointment: $perSlotAppointment, branchName: $branchName, address: $address, latitude: $latitude, longitude: $longitude, weeklyOffDays: $weeklyOffDays, scheduleServices: $scheduleServices, branchId: $branchId}';
}
}
class WeeklyOffDay {
final int? id;
final int? dayNumber;

@ -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;
}
}

@ -49,6 +49,7 @@ class ItemData {
final bool? isAllowAppointment;
final bool? isAppointmentCompanyLoc;
final bool? isAppointmentCustomerLoc;
final double? appointmentPricePercentage;
bool? isUpdateOrSelected;
ItemData({
@ -64,6 +65,7 @@ class ItemData {
this.isAllowAppointment,
this.isAppointmentCompanyLoc,
this.isAppointmentCustomerLoc,
this.appointmentPricePercentage,
this.isUpdateOrSelected,
});

@ -66,7 +66,7 @@ class ProviderDetailsCard extends StatelessWidget {
title.toText(fontSize: 16, isBold: true),
Row(
children: [
(LocaleKeys.location.tr() + ":").toText(color: MyColors.lightTextColor, fontSize: 12),
("${LocaleKeys.location.tr()}:").toText(color: MyColors.lightTextColor, fontSize: 12),
4.width,
providerLocation.toText(fontSize: 12, isBold: true),
],
@ -74,7 +74,7 @@ class ProviderDetailsCard extends StatelessWidget {
if (providerName != null)
Row(
children: [
(LocaleKeys.providers.tr() + ":").toText(color: MyColors.lightTextColor, fontSize: 12),
("${LocaleKeys.providers.tr()}:").toText(color: MyColors.lightTextColor, fontSize: 12),
4.width,
providerName!.toText(fontSize: 12, isBold: true),
],

Loading…
Cancel
Save