horario pro
This commit is contained in:
@@ -53,13 +53,54 @@ class ProfessionalEntity extends Equatable {
|
||||
latitude: double.parse(doc['latitude'].toString()),
|
||||
longitude: double.parse(doc['longitude'].toString()),
|
||||
specializations: List<String>.from(doc['specializations']),
|
||||
specializationsPictures:
|
||||
List<String>.from(doc['specializations_pictures']),
|
||||
specializationsPictures: List<String>.from(doc['specializations_pictures']),
|
||||
schedules: Schedules.fromDocument(doc['schedules']),
|
||||
paymentMethods: PaymentMethodEntity.fromDocument(doc['payment_methods']),
|
||||
);
|
||||
}
|
||||
|
||||
// copy func
|
||||
|
||||
ProfessionalEntity copyWith({
|
||||
String? id,
|
||||
String? identification,
|
||||
String? address,
|
||||
String? aditionalAddress,
|
||||
String? profession,
|
||||
String? rate,
|
||||
LocationPreferences? locationPreferences,
|
||||
String? bannerPicture,
|
||||
String? identificationPicture,
|
||||
String? certificatePicture,
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
List<String>? specializations,
|
||||
List<String>? specializationsPictures,
|
||||
Schedules? schedules,
|
||||
PaymentMethodEntity? paymentMethods,
|
||||
}) {
|
||||
return ProfessionalEntity(
|
||||
id: id ?? this.id,
|
||||
identification: identification ?? this.identification,
|
||||
address: address ?? this.address,
|
||||
aditionalAddress: aditionalAddress ?? this.aditionalAddress,
|
||||
profession: profession ?? this.profession,
|
||||
rate: rate ?? this.rate,
|
||||
locationPreferences: locationPreferences ?? this.locationPreferences,
|
||||
bannerPicture: bannerPicture ?? this.bannerPicture,
|
||||
identificationPicture:
|
||||
identificationPicture ?? this.identificationPicture,
|
||||
certificatePicture: certificatePicture ?? this.certificatePicture,
|
||||
latitude: latitude ?? this.latitude,
|
||||
longitude: longitude ?? this.longitude,
|
||||
specializations: specializations ?? this.specializations,
|
||||
specializationsPictures:
|
||||
specializationsPictures ?? this.specializationsPictures,
|
||||
schedules: schedules ?? this.schedules,
|
||||
paymentMethods: paymentMethods ?? this.paymentMethods,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'id': id,
|
||||
|
||||
@@ -28,6 +28,25 @@ class ScheduleEntity extends Equatable {
|
||||
range2Hour2: null,
|
||||
);
|
||||
|
||||
// copy func
|
||||
ScheduleEntity copyWith({
|
||||
bool? enabled,
|
||||
bool? continuousDay,
|
||||
TimeOfDay? range1Hour1,
|
||||
TimeOfDay? range1Hour2,
|
||||
TimeOfDay? range2Hour1,
|
||||
TimeOfDay? range2Hour2,
|
||||
}) {
|
||||
return ScheduleEntity(
|
||||
enabled: enabled ?? this.enabled,
|
||||
continuousDay: continuousDay ?? this.continuousDay,
|
||||
range1Hour1: range1Hour1 ?? this.range1Hour1,
|
||||
range1Hour2: range1Hour2 ?? this.range1Hour2,
|
||||
range2Hour1: range2Hour1 ?? this.range2Hour1,
|
||||
range2Hour2: range2Hour2 ?? this.range2Hour2,
|
||||
);
|
||||
}
|
||||
|
||||
static ScheduleEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return ScheduleEntity(
|
||||
enabled: doc['habilitado'] as bool,
|
||||
@@ -40,17 +59,18 @@ class ScheduleEntity extends Equatable {
|
||||
}
|
||||
|
||||
static TimeOfDay? _parseTime(String? time) {
|
||||
if (time == null) return null;
|
||||
final components = time.split(' ');
|
||||
final hourMinutes = components[0].split(':');
|
||||
final hour = int.parse(hourMinutes[0]);
|
||||
final minutes = int.parse(hourMinutes[1]);
|
||||
if (components[1] == 'PM' && hour < 12) {
|
||||
return TimeOfDay(hour: hour + 12, minute: minutes);
|
||||
} else if (components[1] == 'AM' && hour == 12) {
|
||||
return TimeOfDay(hour: 0, minute: minutes);
|
||||
try {
|
||||
if (time == null) return null;
|
||||
final components = time.split(':');
|
||||
if (components.length != 2) {
|
||||
return null;
|
||||
}
|
||||
final hour = int.parse(components[0]);
|
||||
final minutes = int.parse(components[1]);
|
||||
return TimeOfDay(hour: hour, minute: minutes);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
return TimeOfDay(hour: hour, minute: minutes);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -66,15 +86,22 @@ class ScheduleEntity extends Equatable {
|
||||
|
||||
String? formatTimeOfDay(TimeOfDay? time) {
|
||||
if (time != null) {
|
||||
final now = DateTime.now();
|
||||
final dateTime =
|
||||
DateTime(now.year, now.month, now.day, time.hour, time.minute);
|
||||
final format = DateFormat.jm();
|
||||
return format.format(dateTime);
|
||||
return "${time.hour.toString()}:${time.minute.toString()}";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? getFormatTime(TimeOfDay? time) {
|
||||
if (time == null) {
|
||||
return null;
|
||||
}
|
||||
final now = DateTime.now();
|
||||
final dateTime =
|
||||
DateTime(now.year, now.month, now.day, time.hour, time.minute);
|
||||
final format = DateFormat.jm();
|
||||
return format.format(dateTime);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
enabled,
|
||||
|
||||
@@ -29,6 +29,27 @@ class Schedules extends Equatable {
|
||||
sunday: ScheduleEntity.empty,
|
||||
);
|
||||
|
||||
// Copy function
|
||||
Schedules copyWith({
|
||||
ScheduleEntity? monday,
|
||||
ScheduleEntity? tuesday,
|
||||
ScheduleEntity? wednesday,
|
||||
ScheduleEntity? thursday,
|
||||
ScheduleEntity? friday,
|
||||
ScheduleEntity? saturday,
|
||||
ScheduleEntity? sunday,
|
||||
}) {
|
||||
return Schedules(
|
||||
monday: monday ?? this.monday,
|
||||
tuesday: tuesday ?? this.tuesday,
|
||||
wednesday: wednesday ?? this.wednesday,
|
||||
thursday: thursday ?? this.thursday,
|
||||
friday: friday ?? this.friday,
|
||||
saturday: saturday ?? this.saturday,
|
||||
sunday: sunday ?? this.sunday,
|
||||
);
|
||||
}
|
||||
|
||||
factory Schedules.fromDocument(Map<String, dynamic> doc) {
|
||||
return Schedules(
|
||||
monday: ScheduleEntity.fromDocument(doc['monday']),
|
||||
|
||||
+2
@@ -89,6 +89,7 @@ class FirebaseProfessionalRepository {
|
||||
LocationPreferences locationPreferences,
|
||||
double latitude,
|
||||
double longitude,
|
||||
Schedules schedules,
|
||||
PaymentMethodEntity paymentMethods,
|
||||
) async {
|
||||
if (_proInfo == null) {
|
||||
@@ -102,6 +103,7 @@ class FirebaseProfessionalRepository {
|
||||
'location_preferences': enumToInt(locationPreferences),
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'schedules': schedules.toJson(),
|
||||
'payment_methods': paymentMethods.toDocument(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user