replace: swap prosappweb content for prosapp_web_app (more complete version)
prosapp_web_app has chat, dashboard, calendar, support, 13 providers and Fluro URL routing. Keep Dockerfile + nginx.conf from previous prosappweb. Upgrade google_fonts 6.2.1 → 8.1.0 (Dart 3.12 compat fix). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
74a4f41902
commit
15175c1b91
@@ -0,0 +1,45 @@
|
||||
import 'package:prosapp_web_app/models/message_entity.dart';
|
||||
|
||||
class ChatEntity {
|
||||
final String? id;
|
||||
final String userId;
|
||||
final String professionalId;
|
||||
final List<MessageEntity> messages;
|
||||
|
||||
const ChatEntity({
|
||||
required this.id,
|
||||
required this.userId,
|
||||
required this.professionalId,
|
||||
required this.messages,
|
||||
});
|
||||
|
||||
static ChatEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return ChatEntity(
|
||||
id: doc['id'] as String,
|
||||
userId: doc['user_id'] as String,
|
||||
professionalId: doc['professional_id'] as String,
|
||||
messages: (doc['messages'] as List)
|
||||
.map((e) => MessageEntity.fromDocument(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'id': id,
|
||||
'user_id': userId,
|
||||
'professional_id': professionalId,
|
||||
'messages': messages.map((e) => e.toDocument()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''ChatEntity{
|
||||
id: $id,
|
||||
userId: $userId,
|
||||
professionalId: $professionalId,
|
||||
messages: $messages
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class City {
|
||||
final String cityName;
|
||||
final String coordsOfCity;
|
||||
final String stateOfCity;
|
||||
final String countryOfCity;
|
||||
|
||||
const City({
|
||||
required this.cityName,
|
||||
required this.coordsOfCity,
|
||||
required this.stateOfCity,
|
||||
required this.countryOfCity,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
class CityEntity {
|
||||
final String name;
|
||||
final String coords;
|
||||
|
||||
const CityEntity({
|
||||
required this.name,
|
||||
required this.coords,
|
||||
});
|
||||
|
||||
Map<String, Object?> toDocument() {
|
||||
return {
|
||||
'name': name,
|
||||
'coords': coords,
|
||||
};
|
||||
}
|
||||
|
||||
static CityEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return CityEntity(
|
||||
name: doc['name'] as String,
|
||||
coords: doc['coords'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''CityEntity {
|
||||
name: $name
|
||||
coords: $coords
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
|
||||
class CommentEntity {
|
||||
final String authorId;
|
||||
final String destinationId;
|
||||
final String serviceId;
|
||||
final String content;
|
||||
final double score;
|
||||
final bool isFromUser;
|
||||
final Timestamp createdAt;
|
||||
|
||||
const CommentEntity({
|
||||
required this.authorId,
|
||||
required this.destinationId,
|
||||
required this.serviceId,
|
||||
required this.content,
|
||||
required this.score,
|
||||
required this.isFromUser,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
static CommentEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return CommentEntity(
|
||||
authorId: doc['author_id'] as String,
|
||||
destinationId: doc['destination_id'] as String,
|
||||
serviceId: doc['service_id'] as String,
|
||||
content: doc['content'] as String,
|
||||
score: doc['score'] as double,
|
||||
isFromUser: doc['is_from_user'] as bool,
|
||||
createdAt: doc['created_at'] as Timestamp,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'author_id': authorId,
|
||||
'destination_id': destinationId,
|
||||
'service_id': serviceId,
|
||||
'content': content,
|
||||
'score': score,
|
||||
'is_from_user': isFromUser,
|
||||
'created_at': createdAt,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''CommentEntity{
|
||||
authorId: $authorId,
|
||||
destinationId: $destinationId,
|
||||
serviceId: $serviceId,
|
||||
content: $content,
|
||||
score: $score,
|
||||
isFromUser: $isFromUser,
|
||||
createdAt: $createdAt
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'package:prosapp_web_app/models/region_entity.dart';
|
||||
|
||||
class CountryEntity {
|
||||
final String name;
|
||||
final List<RegionEntity> regions;
|
||||
|
||||
const CountryEntity({
|
||||
required this.name,
|
||||
required this.regions,
|
||||
});
|
||||
|
||||
Map<String, Object?> toDocument() {
|
||||
return {
|
||||
'name': name,
|
||||
'states': regions,
|
||||
};
|
||||
}
|
||||
|
||||
static CountryEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return CountryEntity(
|
||||
name: doc['name'] as String,
|
||||
regions: (doc['states'] as List)
|
||||
.map((region) => RegionEntity.fromDocument(region))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''CountryEntity {
|
||||
name: $name
|
||||
regions: $regions
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export 'location_preferences.dart';
|
||||
|
||||
enum LocationPreferences { office, delivery, both }
|
||||
|
||||
int enumToInt(LocationPreferences state) {
|
||||
return state.index;
|
||||
}
|
||||
|
||||
LocationPreferences intToEnum(int value) {
|
||||
return LocationPreferences.values[value];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
class MessageEntity {
|
||||
final String ownerId;
|
||||
final String content;
|
||||
final DateTime createdAt;
|
||||
|
||||
const MessageEntity({
|
||||
required this.ownerId,
|
||||
required this.content,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
static MessageEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return MessageEntity(
|
||||
ownerId: doc['owner_id'] as String,
|
||||
content: doc['content'] as String,
|
||||
createdAt: DateTime.parse(doc['created_at'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'owner_id': ownerId,
|
||||
'content': content,
|
||||
'created_at': createdAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''MessageEntity{
|
||||
ownerId: $ownerId,
|
||||
content: $content,
|
||||
createdAt: $createdAt
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
class PaymentMethodEntity {
|
||||
final bool nequi;
|
||||
final bool datafono;
|
||||
final bool transferencia;
|
||||
|
||||
static const empty = PaymentMethodEntity(
|
||||
nequi: false,
|
||||
datafono: false,
|
||||
transferencia: false,
|
||||
);
|
||||
|
||||
const PaymentMethodEntity({
|
||||
required this.nequi,
|
||||
required this.datafono,
|
||||
required this.transferencia,
|
||||
});
|
||||
|
||||
PaymentMethodEntity copyWith({
|
||||
bool? datafono,
|
||||
bool? nequi,
|
||||
bool? transferencia,
|
||||
}) {
|
||||
return PaymentMethodEntity(
|
||||
nequi: nequi ?? this.nequi,
|
||||
datafono: datafono ?? this.datafono,
|
||||
transferencia: transferencia ?? this.transferencia,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, Object?> toDocument() {
|
||||
return {
|
||||
'nequi': nequi,
|
||||
'datafono': datafono,
|
||||
'transferencia': transferencia,
|
||||
};
|
||||
}
|
||||
|
||||
static PaymentMethodEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return PaymentMethodEntity(
|
||||
nequi: doc['nequi'] as bool,
|
||||
datafono: doc['datafono'] as bool,
|
||||
transferencia: doc['transferencia'] as bool,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''PaymentMethodEntity {
|
||||
nequi: $nequi
|
||||
datafono: $datafono
|
||||
transferencia: $transferencia
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
enum ProState { inactive, pending, active, denied }
|
||||
|
||||
int enumToInt(ProState state) {
|
||||
return state.index;
|
||||
}
|
||||
|
||||
ProState intToEnum(int value) {
|
||||
return ProState.values[value];
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
import 'package:prosapp_web_app/models/location_preferences.dart';
|
||||
import 'package:prosapp_web_app/models/payment_method_entity.dart';
|
||||
import 'package:prosapp_web_app/models/schedules.dart';
|
||||
|
||||
class Profesional {
|
||||
final String id;
|
||||
final String identification;
|
||||
final String address;
|
||||
final String aditionalAddress;
|
||||
final String profession;
|
||||
final bool ratePreferences;
|
||||
final String rate;
|
||||
final LocationPreferences locationPreferences;
|
||||
final String bannerPicture;
|
||||
final String identificationPicture;
|
||||
final String certificatePicture;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final List<String> specializations;
|
||||
final List<String> specializationsPictures;
|
||||
final Schedules schedules;
|
||||
final PaymentMethodEntity paymentMethods;
|
||||
|
||||
const Profesional({
|
||||
required this.id,
|
||||
required this.identification,
|
||||
required this.address,
|
||||
required this.aditionalAddress,
|
||||
required this.profession,
|
||||
required this.ratePreferences,
|
||||
required this.rate,
|
||||
required this.locationPreferences,
|
||||
required this.bannerPicture,
|
||||
required this.identificationPicture,
|
||||
required this.certificatePicture,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.specializations,
|
||||
required this.specializationsPictures,
|
||||
required this.schedules,
|
||||
required this.paymentMethods,
|
||||
});
|
||||
|
||||
static Profesional fromDocument(Map<String, dynamic> doc) {
|
||||
return Profesional(
|
||||
id: doc['id'] as String,
|
||||
identification: doc['identification'] as String,
|
||||
address: doc['address'] as String,
|
||||
aditionalAddress: doc['aditional_address'] as String,
|
||||
profession: doc['profession'] as String,
|
||||
ratePreferences: doc['rate_preferences'] as bool,
|
||||
rate: doc['rate'] as String,
|
||||
locationPreferences: intToEnum(doc['location_preferences'] as int),
|
||||
bannerPicture: doc['banner_picture'] as String,
|
||||
identificationPicture: doc['identification_picture'] as String,
|
||||
certificatePicture: doc['certificate_picture'] as String,
|
||||
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']),
|
||||
schedules: Schedules.fromDocument(doc['schedules']),
|
||||
paymentMethods: PaymentMethodEntity.fromDocument(doc['payment_methods']),
|
||||
);
|
||||
}
|
||||
|
||||
Profesional copyWith({
|
||||
String? id,
|
||||
String? identification,
|
||||
String? address,
|
||||
String? aditionalAddress,
|
||||
String? profession,
|
||||
bool ratePreferences = false,
|
||||
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 Profesional(
|
||||
id: id ?? this.id,
|
||||
identification: identification ?? this.identification,
|
||||
address: address ?? this.address,
|
||||
aditionalAddress: aditionalAddress ?? this.aditionalAddress,
|
||||
profession: profession ?? this.profession,
|
||||
ratePreferences: ratePreferences,
|
||||
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,
|
||||
'identification': identification,
|
||||
'address': address,
|
||||
'aditional_address': aditionalAddress,
|
||||
'profession': profession,
|
||||
'rate_preferences': ratePreferences,
|
||||
'rate': rate,
|
||||
'location_preferences': enumToInt(locationPreferences),
|
||||
'banner_picture': bannerPicture,
|
||||
'identification_picture': identificationPicture,
|
||||
'certificate_picture': certificatePicture,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'specializations': specializations,
|
||||
'specializations_pictures': specializationsPictures,
|
||||
'schedules': schedules.toJson(),
|
||||
'payment_methods': paymentMethods.toDocument(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''Profesional{ {
|
||||
id: $id,
|
||||
identification: $identification,
|
||||
address: $address,
|
||||
aditional_address: $aditionalAddress,
|
||||
profession: $profession,
|
||||
rate_preferences: $ratePreferences,
|
||||
rate: $rate,
|
||||
location_preferences: $locationPreferences,
|
||||
bannerPicture: $bannerPicture,
|
||||
identificationPicture: $identificationPicture,
|
||||
certificatePicture: $certificatePicture,
|
||||
latitude: $latitude,
|
||||
longitude: $longitude,
|
||||
specializations: $specializations,
|
||||
specializationsPictures: $specializationsPictures,
|
||||
schedule: $schedules,
|
||||
paymentMethods: $paymentMethods
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
class Profession {
|
||||
final String name;
|
||||
|
||||
Profession({required this.name});
|
||||
|
||||
Map<String, Object?> toDocument() {
|
||||
return {
|
||||
'name': name,
|
||||
};
|
||||
}
|
||||
|
||||
static Profession fromDocument(Map<String, dynamic> doc) {
|
||||
return Profession(
|
||||
name: doc['name'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Profession{name: $name}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
import 'package:prosapp_web_app/models/city_entity.dart';
|
||||
|
||||
class RegionEntity {
|
||||
final String name;
|
||||
final List<CityEntity> cities;
|
||||
|
||||
const RegionEntity({
|
||||
required this.name,
|
||||
required this.cities,
|
||||
});
|
||||
|
||||
Map<String, Object?> toDocument() {
|
||||
return {
|
||||
'name': name,
|
||||
'cities': cities,
|
||||
};
|
||||
}
|
||||
|
||||
static RegionEntity fromDocument(Map<String, dynamic> doc) {
|
||||
return RegionEntity(
|
||||
name: doc['name'] as String,
|
||||
cities: (doc['cities'] as List)
|
||||
.map((city) => CityEntity.fromDocument(city))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''RegionEntity {
|
||||
name: $name
|
||||
cities: $cities
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import 'package:prosapp_web_app/models/schedules_entity.dart';
|
||||
|
||||
class Schedules {
|
||||
final ScheduleEntity monday;
|
||||
final ScheduleEntity tuesday;
|
||||
final ScheduleEntity wednesday;
|
||||
final ScheduleEntity thursday;
|
||||
final ScheduleEntity friday;
|
||||
final ScheduleEntity saturday;
|
||||
final ScheduleEntity sunday;
|
||||
|
||||
const Schedules({
|
||||
required this.monday,
|
||||
required this.tuesday,
|
||||
required this.wednesday,
|
||||
required this.thursday,
|
||||
required this.friday,
|
||||
required this.saturday,
|
||||
required this.sunday,
|
||||
});
|
||||
|
||||
static const empty = Schedules(
|
||||
monday: ScheduleEntity.empty,
|
||||
tuesday: ScheduleEntity.empty,
|
||||
wednesday: ScheduleEntity.empty,
|
||||
thursday: ScheduleEntity.empty,
|
||||
friday: ScheduleEntity.empty,
|
||||
saturday: ScheduleEntity.empty,
|
||||
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']),
|
||||
tuesday: ScheduleEntity.fromDocument(doc['tuesday']),
|
||||
wednesday: ScheduleEntity.fromDocument(doc['wednesday']),
|
||||
thursday: ScheduleEntity.fromDocument(doc['thursday']),
|
||||
friday: ScheduleEntity.fromDocument(doc['friday']),
|
||||
saturday: ScheduleEntity.fromDocument(doc['saturday']),
|
||||
sunday: ScheduleEntity.fromDocument(doc['sunday']),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'monday': monday.toJson(),
|
||||
'tuesday': tuesday.toJson(),
|
||||
'wednesday': wednesday.toJson(),
|
||||
'thursday': thursday.toJson(),
|
||||
'friday': friday.toJson(),
|
||||
'saturday': saturday.toJson(),
|
||||
'sunday': sunday.toJson(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class ScheduleEntity {
|
||||
final bool enabled;
|
||||
final bool continuousDay;
|
||||
final TimeOfDay? range1Hour1;
|
||||
final TimeOfDay? range1Hour2;
|
||||
final TimeOfDay? range2Hour1;
|
||||
final TimeOfDay? range2Hour2;
|
||||
|
||||
const ScheduleEntity({
|
||||
required this.enabled,
|
||||
required this.continuousDay,
|
||||
required this.range1Hour1,
|
||||
required this.range1Hour2,
|
||||
required this.range2Hour1,
|
||||
required this.range2Hour2,
|
||||
});
|
||||
|
||||
static const empty = ScheduleEntity(
|
||||
enabled: false,
|
||||
continuousDay: false,
|
||||
range1Hour1: null,
|
||||
range1Hour2: null,
|
||||
range2Hour1: null,
|
||||
range2Hour2: null,
|
||||
);
|
||||
|
||||
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,
|
||||
continuousDay: doc['continuous_day'] as bool,
|
||||
range1Hour1: _parseTime(doc['range1Hour1']),
|
||||
range1Hour2: _parseTime(doc['range1Hour2']),
|
||||
range2Hour1: _parseTime(doc['range2Hour1']),
|
||||
range2Hour2: _parseTime(doc['range2Hour2']),
|
||||
);
|
||||
}
|
||||
|
||||
static TimeOfDay? _parseTime(String? time) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'habilitado': enabled,
|
||||
'continuous_day': continuousDay,
|
||||
'range1Hour1': formatTimeOfDay(range1Hour1),
|
||||
'range1Hour2': formatTimeOfDay(range1Hour2),
|
||||
'range2Hour1': formatTimeOfDay(range2Hour1),
|
||||
'range2Hour2': formatTimeOfDay(range2Hour2),
|
||||
};
|
||||
}
|
||||
|
||||
String? formatTimeOfDay(TimeOfDay? time) {
|
||||
if (time != null) {
|
||||
return "${time.hour.toString()}:${time.minute.toString()}";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static 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
|
||||
String toString() {
|
||||
return '''ScheduleEntity {
|
||||
enabled: $enabled,
|
||||
continuousDay: $continuousDay,
|
||||
range1Hour1: $range1Hour1,
|
||||
range1Hour2: $range1Hour2,
|
||||
range2Hour1: $range2Hour1,
|
||||
range2Hour2: $range2Hour2
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
class ReputationEntity {
|
||||
final int total;
|
||||
final double average;
|
||||
final int totalPro;
|
||||
final double averagePro;
|
||||
|
||||
const ReputationEntity({
|
||||
required this.total,
|
||||
required this.average,
|
||||
required this.totalPro,
|
||||
required this.averagePro,
|
||||
});
|
||||
|
||||
static ReputationEntity fromDocument(Map<String, dynamic> doc) {
|
||||
final total = doc['total'] ?? 0;
|
||||
final totalPro = doc['total_pro'] ?? 0;
|
||||
final average = doc['average'] ?? 0.0;
|
||||
final averagePro = doc['average_pro'] ?? 0.0;
|
||||
|
||||
return ReputationEntity(
|
||||
total: int.parse(total.toString()),
|
||||
average: double.parse(average.toString()),
|
||||
totalPro: int.parse(totalPro.toString()),
|
||||
averagePro: double.parse(averagePro.toString()),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'total': total,
|
||||
'average': average,
|
||||
'total_pro': totalPro,
|
||||
'average_pro': averagePro,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:prosapp_web_app/models/service_location_preferences.dart';
|
||||
import 'package:prosapp_web_app/models/service_status.dart';
|
||||
|
||||
class Service {
|
||||
final String? id;
|
||||
final String professionalId;
|
||||
final bool professionalScored;
|
||||
final String userId;
|
||||
final bool userScored;
|
||||
final String address;
|
||||
final String aditionalAddress;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final String day;
|
||||
final Timestamp createdAt;
|
||||
final String description;
|
||||
final TimeOfDay range1Hour1;
|
||||
final TimeOfDay range1Hour2;
|
||||
final String rate;
|
||||
final ServiceStatus status;
|
||||
final ServiceLocationPreferences location;
|
||||
|
||||
Service({
|
||||
required this.id,
|
||||
required this.professionalId,
|
||||
required this.professionalScored,
|
||||
required this.userId,
|
||||
required this.userScored,
|
||||
required this.address,
|
||||
required this.aditionalAddress,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.day,
|
||||
required this.createdAt,
|
||||
required this.description,
|
||||
required this.range1Hour1,
|
||||
required this.range1Hour2,
|
||||
required this.rate,
|
||||
required this.status,
|
||||
required this.location,
|
||||
});
|
||||
|
||||
static Service fromJson(Map<String, dynamic> doc, String id) {
|
||||
return Service(
|
||||
id: id,
|
||||
professionalId: doc['professional_id'] as String,
|
||||
professionalScored: doc['professional_scored'] as bool,
|
||||
userId: doc['user_id'] as String,
|
||||
userScored: doc['user_scored'] as bool,
|
||||
address: doc['address'] as String,
|
||||
aditionalAddress: doc['aditional_address'] as String,
|
||||
latitude: doc['latitude'] as double,
|
||||
longitude: doc['longitude'] as double,
|
||||
day: doc['day'] as String,
|
||||
createdAt: doc['created_at'] as Timestamp,
|
||||
description: doc['description'] as String,
|
||||
range1Hour1: parseTimeOfDay(doc['range1_hour1'] as String),
|
||||
range1Hour2: parseTimeOfDay(doc['range1_hour2'] as String),
|
||||
status: intToEnumService(doc['status'] as int),
|
||||
rate: doc['rate'] as String,
|
||||
location: intToEnum(doc['location'] as int),
|
||||
);
|
||||
}
|
||||
|
||||
static Service fromDocument(DocumentSnapshot<Map<String, dynamic>> doc) {
|
||||
return fromJson(doc.data()!, doc.id);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'id': id,
|
||||
'professional_id': professionalId,
|
||||
'professional_scored': professionalScored,
|
||||
'user_id': userId,
|
||||
'user_scored': userScored,
|
||||
'address': address,
|
||||
'aditional_address': aditionalAddress,
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'day': day,
|
||||
'created_at': createdAt,
|
||||
'description': description,
|
||||
'range1_hour1': formatTimeOfDay(range1Hour1),
|
||||
'range1_hour2': formatTimeOfDay(range1Hour2),
|
||||
'rate': rate,
|
||||
'status': enumToIntService(status),
|
||||
'location': enumToInt(location),
|
||||
};
|
||||
}
|
||||
|
||||
static TimeOfDay parseTimeOfDay(String timeString) {
|
||||
final parts = timeString.split(':');
|
||||
return TimeOfDay(hour: int.parse(parts[0]), minute: int.parse(parts[1]));
|
||||
}
|
||||
|
||||
String? formatTimeOfDay(TimeOfDay? time) {
|
||||
if (time != null) {
|
||||
return "${time.hour.toString()}:${time.minute.toString()}";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''Service {
|
||||
professionalId: $professionalId,
|
||||
userId: $userId,
|
||||
day: $day,
|
||||
createdAt: $createdAt,
|
||||
status: $status,
|
||||
location: $location
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export 'service_location_preferences.dart';
|
||||
|
||||
enum ServiceLocationPreferences { office, delivery }
|
||||
|
||||
int enumToInt(ServiceLocationPreferences state) {
|
||||
return state.index;
|
||||
}
|
||||
|
||||
ServiceLocationPreferences intToEnum(int value) {
|
||||
return ServiceLocationPreferences.values[value];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
export 'service_status.dart';
|
||||
|
||||
enum ServiceStatus {
|
||||
pending, // 0
|
||||
acepted, // 1
|
||||
denied, // 2
|
||||
active, // 3
|
||||
cancelled, // 4
|
||||
completed, // 5
|
||||
selfBooked // 6
|
||||
}
|
||||
|
||||
int enumToIntService(ServiceStatus state) {
|
||||
return state.index;
|
||||
}
|
||||
|
||||
ServiceStatus intToEnumService(int value) {
|
||||
return ServiceStatus.values[value];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:prosapp_web_app/models/service.dart';
|
||||
import 'package:prosapp_web_app/models/usuario.dart';
|
||||
|
||||
class ServicioProfesional {
|
||||
final Service service;
|
||||
final Usuario user;
|
||||
|
||||
ServicioProfesional({
|
||||
required this.user,
|
||||
required this.service,
|
||||
});
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''UserProfessional{
|
||||
myUser: $user,
|
||||
service: $service
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
class Setting {
|
||||
final bool tarifas;
|
||||
final bool domicilios;
|
||||
final bool google;
|
||||
final String versionIos;
|
||||
final String versionAndroid;
|
||||
final String horaNotificacion;
|
||||
final String tituloSoporte;
|
||||
final String parrafoSoporte;
|
||||
final String numeroSoporte;
|
||||
final String emailSoporte;
|
||||
final String diasSoporte;
|
||||
final String horasSoporte;
|
||||
final String politicasPrivacidad;
|
||||
final String politicasPrivacidadTitle;
|
||||
final String politicasPrivacidadBody;
|
||||
final String terminosCondiciones;
|
||||
final String terminosCondicionesTitle;
|
||||
final String terminosCondicionesBody;
|
||||
|
||||
const Setting({
|
||||
required this.tarifas,
|
||||
required this.domicilios,
|
||||
required this.google,
|
||||
required this.versionIos,
|
||||
required this.versionAndroid,
|
||||
required this.horaNotificacion,
|
||||
required this.tituloSoporte,
|
||||
required this.parrafoSoporte,
|
||||
required this.numeroSoporte,
|
||||
required this.emailSoporte,
|
||||
required this.diasSoporte,
|
||||
required this.horasSoporte,
|
||||
required this.politicasPrivacidad,
|
||||
required this.politicasPrivacidadTitle,
|
||||
required this.politicasPrivacidadBody,
|
||||
required this.terminosCondiciones,
|
||||
required this.terminosCondicionesTitle,
|
||||
required this.terminosCondicionesBody,
|
||||
});
|
||||
|
||||
static Setting fromDocument(Map<String, dynamic> doc) {
|
||||
return Setting(
|
||||
tarifas: doc['tarifas'] as bool,
|
||||
domicilios: doc['domicilios'] as bool,
|
||||
google: doc['google'] as bool,
|
||||
versionIos: doc['version_ios'] as String,
|
||||
versionAndroid: doc['version_android'] as String,
|
||||
horaNotificacion: doc['hora_notificacion'] as String,
|
||||
tituloSoporte: doc['titulo_soporte'] as String,
|
||||
parrafoSoporte: doc['parrafo_soporte'] as String,
|
||||
numeroSoporte: doc['numero_soporte'] as String,
|
||||
emailSoporte: doc['email_soporte'] as String,
|
||||
diasSoporte: doc['dias_soporte'] as String,
|
||||
horasSoporte: doc['horas_soporte'] as String,
|
||||
politicasPrivacidad: doc['politicas_privacidad'] as String,
|
||||
politicasPrivacidadTitle: doc['politicas_privacidad_title'] as String,
|
||||
politicasPrivacidadBody: doc['politicas_privacidad_body'] as String,
|
||||
terminosCondiciones: doc['terminos_condiciones'] as String,
|
||||
terminosCondicionesTitle: doc['terminos_condiciones_title'] as String,
|
||||
terminosCondicionesBody: doc['terminos_condiciones_body'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''Setting {
|
||||
tarifas: $tarifas
|
||||
domicilios: $domicilios
|
||||
google: $google
|
||||
versionIos: $versionIos
|
||||
versionAndroid: $versionAndroid
|
||||
horaNotificacion: $horaNotificacion
|
||||
tituloSoporte: $tituloSoporte
|
||||
parrafoSoporte: $parrafoSoporte
|
||||
numeroSoporte: $numeroSoporte
|
||||
emailSoporte: $emailSoporte
|
||||
diasSoporte: $diasSoporte
|
||||
horasSoporte: $horasSoporte
|
||||
politicasPrivacidad: $politicasPrivacidad
|
||||
politicasPrivacidadTitle: $politicasPrivacidadTitle
|
||||
politicasPrivacidadBody: $politicasPrivacidadBody
|
||||
terminosCondiciones: $terminosCondiciones
|
||||
terminosCondicionesTitle: $terminosCondicionesTitle
|
||||
terminosCondicionesBody: $terminosCondicionesBody
|
||||
}''';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:prosapp_web_app/models/pro_state.dart';
|
||||
|
||||
class Usuario {
|
||||
final String id;
|
||||
final String? email;
|
||||
final String? phone;
|
||||
final String name;
|
||||
final String? nickname;
|
||||
final String? city;
|
||||
final String? picture;
|
||||
final String? birthday;
|
||||
final String? gender;
|
||||
final ProState proState;
|
||||
final String? token;
|
||||
|
||||
Usuario({
|
||||
required this.id,
|
||||
required this.email,
|
||||
required this.phone,
|
||||
required this.name,
|
||||
required this.nickname,
|
||||
required this.city,
|
||||
required this.picture,
|
||||
required this.birthday,
|
||||
required this.gender,
|
||||
required this.proState,
|
||||
required this.token,
|
||||
});
|
||||
|
||||
Map<String, Object?> toDocument() {
|
||||
return {
|
||||
'id': id,
|
||||
'email': email,
|
||||
'phone': phone,
|
||||
'name': name,
|
||||
'nickname': name.toLowerCase().trim().replaceAll(' ', '_'),
|
||||
'city': city,
|
||||
'picture': picture,
|
||||
'birthday': birthday,
|
||||
'gender': gender,
|
||||
'professional_state': enumToInt(proState),
|
||||
'token': token,
|
||||
};
|
||||
}
|
||||
|
||||
static Usuario fromDocument(Map<String, dynamic> doc) {
|
||||
return Usuario(
|
||||
id: doc['id'],
|
||||
email: doc['email'],
|
||||
phone: doc['phone'],
|
||||
name: doc['name'] ?? '',
|
||||
nickname: doc['nickname'],
|
||||
city: doc['city'],
|
||||
picture: doc['picture'],
|
||||
birthday: doc['birthday'],
|
||||
gender: doc['gender'],
|
||||
proState: intToEnum(doc['professional_state'] as int),
|
||||
token: doc['token'],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'User(id: $id, email: $email, phone: $phone, name: $name, nickname: $nickname, city: $city, picture: $picture, birthday: $birthday, gender: $gender, proState: $proState, token: $token)';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:prosapp_web_app/models/profesional.dart';
|
||||
import 'package:prosapp_web_app/models/usuario.dart';
|
||||
|
||||
class UsuarioProfesional {
|
||||
final Usuario user;
|
||||
final Profesional professionalInfo;
|
||||
final double averageScore;
|
||||
|
||||
UsuarioProfesional({
|
||||
required this.user,
|
||||
required this.professionalInfo,
|
||||
required this.averageScore,
|
||||
});
|
||||
|
||||
// Método para serializar a JSON
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'user': user.toDocument(),
|
||||
'professionalInfo': professionalInfo.toDocument(),
|
||||
'averageScore': averageScore,
|
||||
};
|
||||
}
|
||||
|
||||
// Método para deserializar desde JSON
|
||||
factory UsuarioProfesional.fromJson(Map<String, dynamic> json) {
|
||||
return UsuarioProfesional(
|
||||
user: Usuario.fromDocument(json['user']),
|
||||
professionalInfo: Profesional.fromDocument(json['professionalInfo']),
|
||||
averageScore: json['averageScore'].toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '''UsuarioProfesional{
|
||||
user: $user,
|
||||
professionalInfo: $professionalInfo,
|
||||
averageScore: $averageScore
|
||||
}''';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user