actualiza todos los campos excepto schedule
This commit is contained in:
@@ -25,7 +25,7 @@ class PaymentMethodEntity extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> toDocument() {
|
||||
return {
|
||||
'nequi': nequi,
|
||||
'datafono': datafono,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:professional_repository/src/models/location_preferences.dart';
|
||||
|
||||
class ProfessionalEntity extends Equatable {
|
||||
final String id;
|
||||
@@ -13,8 +12,8 @@ class ProfessionalEntity extends Equatable {
|
||||
final String bannerPicture;
|
||||
final String identificationPicture;
|
||||
final String certificatePicture;
|
||||
final String latitude;
|
||||
final String longitude;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final List<String> specializations;
|
||||
final List<String> specializationsPictures;
|
||||
final Schedules schedules;
|
||||
@@ -51,8 +50,8 @@ class ProfessionalEntity extends Equatable {
|
||||
bannerPicture: doc['banner_picture'] as String,
|
||||
identificationPicture: doc['identification_picture'] as String,
|
||||
certificatePicture: doc['certificate_picture'] as String,
|
||||
latitude: doc['latitude'] as String,
|
||||
longitude: doc['longitude'] 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']),
|
||||
@@ -78,7 +77,7 @@ class ProfessionalEntity extends Equatable {
|
||||
'specializations': specializations,
|
||||
'specializations_pictures': specializationsPictures,
|
||||
'schedules': schedules.toJson(),
|
||||
'payment_methods': paymentMethods.toJson(),
|
||||
'payment_methods': paymentMethods.toDocument(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+34
-6
@@ -25,7 +25,7 @@ class FirebaseProfessionalRepository {
|
||||
|
||||
FirebaseAuth.instance.userChanges().listen((user) async {
|
||||
if (user != null) {
|
||||
await updateFromFirebase2(
|
||||
await updateFromFirebase(
|
||||
userId: user.uid,
|
||||
);
|
||||
} else {
|
||||
@@ -43,7 +43,7 @@ class FirebaseProfessionalRepository {
|
||||
return _proInfoBroadcast.stream;
|
||||
}
|
||||
|
||||
Future<void> updateFromFirebase2({
|
||||
Future<void> updateFromFirebase({
|
||||
required String userId,
|
||||
}) async {
|
||||
try {
|
||||
@@ -82,18 +82,46 @@ class FirebaseProfessionalRepository {
|
||||
_isProModeActiveBroadcast.add(isProModeActive);
|
||||
}
|
||||
|
||||
Future<void> updateProfessionalInfo(
|
||||
String address,
|
||||
String aditionalAddress,
|
||||
String rate,
|
||||
LocationPreferences locationPreferences,
|
||||
double latitude,
|
||||
double longitude,
|
||||
PaymentMethodEntity paymentMethods,
|
||||
) async {
|
||||
if (_proInfo == null) {
|
||||
log('_proInfo is null');
|
||||
return;
|
||||
}
|
||||
await professionalCollection.doc(_proInfo!.id).update({
|
||||
'address': address,
|
||||
'aditional_address': aditionalAddress,
|
||||
'rate': rate,
|
||||
'location_preferences': enumToInt(locationPreferences),
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'payment_methods': paymentMethods.toDocument(),
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> saveProfessionalInfo(ProfessionalEntity entity) async {
|
||||
await professionalCollection.doc(entity.id).set(entity.toDocument());
|
||||
}
|
||||
|
||||
Future<String> uploadBannerPicture(String file, String userId) async {
|
||||
Future<void> uploadBannerPicture(String file) async {
|
||||
try {
|
||||
File imageFile = File(file);
|
||||
Reference firebaseStoreRef =
|
||||
FirebaseStorage.instance.ref().child('$userId/BN/${userId}_banner');
|
||||
Reference firebaseStoreRef = FirebaseStorage.instance
|
||||
.ref()
|
||||
.child('${_proInfo!.id}/BN/${_proInfo!.id}_banner');
|
||||
await firebaseStoreRef.putFile(imageFile);
|
||||
String url = await firebaseStoreRef.getDownloadURL();
|
||||
return url;
|
||||
|
||||
await professionalCollection
|
||||
.doc(_proInfo!.id)
|
||||
.update({'banner_picture': url});
|
||||
} catch (e) {
|
||||
log(e.toString());
|
||||
rethrow;
|
||||
|
||||
Reference in New Issue
Block a user