chat primera face

This commit is contained in:
Juan Felipe Duarte
2023-05-03 17:07:26 -05:00
parent f1571e6374
commit 1a0e33328e
16 changed files with 785 additions and 95 deletions
+32 -2
View File
@@ -16,6 +16,7 @@ class EventoService {
String address,
double latitude,
double longitude,
String status,
) async {
try {
DateTime ahora = DateTime.now();
@@ -33,6 +34,7 @@ class EventoService {
'address': address,
'latitude': latitude,
'longitude': longitude,
'status': status,
'Timestamp': ahora
}).then((value) {
FirebaseFirestore.instance.collection('users').doc(uid).update({
@@ -72,17 +74,18 @@ Future<List<Event>> getByProId(String day) async {
}
}
Future<List<Event>> getByProIdAll() async {
Future<List<Event>> getByProIdAll(String state1, String state2) async {
try {
var snapshot = await FirebaseFirestore.instance
.collection('services')
.where('professional_id', isEqualTo: uid)
.get();
.where('status', whereIn: [state1, state2]).get();
List<Event> eventos = [];
for (var element in snapshot.docs) {
final event = Event.fromJson(element.data());
event.scoresModel = await ScoresModel.scoreTo(event.userId, false, false);
event.id = element.id;
eventos.add(event);
}
print('eventos $eventos');
@@ -94,6 +97,7 @@ Future<List<Event>> getByProIdAll() async {
}
class Event {
String? id;
String title;
String? description;
String day;
@@ -105,9 +109,11 @@ class Event {
String? address;
double? longitud;
double? latitud;
String status;
ScoresModel? scoresModel;
Event({
this.id,
required this.title,
this.description,
required this.day,
@@ -119,10 +125,12 @@ class Event {
this.address,
this.longitud,
this.latitud,
this.status = 'pendiente',
});
factory Event.fromJson(Map<String, dynamic> json) {
return Event(
id: json['id'] ?? '',
title: json['title'],
description: json['description'],
day: json['day'],
@@ -134,6 +142,7 @@ class Event {
address: json['address'] ?? '',
longitud: json['longitude'] ?? 0,
latitud: json['latitude'] ?? 0,
status: json['status'],
);
}
@@ -170,4 +179,25 @@ class Event {
return [];
}
}
static Future<List<Event>> getEventsAllByIdStatus(
String uid, String state) async {
try {
var snapshot = await FirebaseFirestore.instance
.collection('services')
.where('professional_id', isEqualTo: uid)
.where('status', isEqualTo: state)
.get();
List<Event> eventos = [];
for (var element in snapshot.docs) {
eventos.add(Event.fromJson(element.data()));
}
print('eventos $eventos');
return eventos;
} catch (e) {
print('Error getByProId $e');
return [];
}
}
}