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,200 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
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/profesional.dart';
|
||||
import 'package:prosapp_web_app/models/schedules.dart';
|
||||
import 'package:prosapp_web_app/services/notifications_service.dart';
|
||||
|
||||
class ProfessionalFormProvider with ChangeNotifier {
|
||||
Profesional? profesional;
|
||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
GlobalKey<FormState> profileFormKey = GlobalKey<FormState>();
|
||||
|
||||
copyProfesionalWith({
|
||||
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,
|
||||
}) {
|
||||
profesional = Profesional(
|
||||
id: id ?? profesional!.id,
|
||||
identification: identification ?? profesional!.identification,
|
||||
address: address ?? profesional!.address,
|
||||
aditionalAddress: aditionalAddress ?? profesional!.aditionalAddress,
|
||||
profession: profession ?? profesional!.profession,
|
||||
ratePreferences: ratePreferences,
|
||||
rate: rate ?? profesional!.rate,
|
||||
locationPreferences:
|
||||
locationPreferences ?? profesional!.locationPreferences,
|
||||
bannerPicture: bannerPicture ?? profesional!.bannerPicture,
|
||||
identificationPicture:
|
||||
identificationPicture ?? profesional!.identificationPicture,
|
||||
certificatePicture: certificatePicture ?? profesional!.certificatePicture,
|
||||
latitude: latitude ?? profesional!.latitude,
|
||||
longitude: longitude ?? profesional!.longitude,
|
||||
specializations: specializations ?? profesional!.specializations,
|
||||
specializationsPictures:
|
||||
specializationsPictures ?? profesional!.specializationsPictures,
|
||||
schedules: schedules ?? profesional!.schedules,
|
||||
paymentMethods: paymentMethods ?? profesional!.paymentMethods,
|
||||
);
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool _validForm() {
|
||||
return formKey.currentState!.validate();
|
||||
}
|
||||
|
||||
bool _validProfileForm() {
|
||||
return profileFormKey.currentState!.validate();
|
||||
}
|
||||
|
||||
setProfesional(Profesional profesional) {
|
||||
this.profesional = profesional;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<bool> updateProfesionalInfo(String userId) async {
|
||||
if (!_validForm()) return false;
|
||||
|
||||
final docProfessional = FirebaseFirestore.instance
|
||||
.collection('professional_info')
|
||||
.doc(userId)
|
||||
.withConverter(
|
||||
fromFirestore: (snapshot, _) =>
|
||||
Profesional.fromDocument(snapshot.data()!),
|
||||
toFirestore: (user, _) => user.toDocument(),
|
||||
);
|
||||
|
||||
await docProfessional.set(profesional!);
|
||||
|
||||
NotificationsService.showSnackbar('Información actualizada');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> updateProfesionalProfileInfo(String userId) async {
|
||||
if (!_validProfileForm()) return false;
|
||||
|
||||
final docProfessional = FirebaseFirestore.instance
|
||||
.collection('professional_info')
|
||||
.doc(userId)
|
||||
.withConverter(
|
||||
fromFirestore: (snapshot, _) =>
|
||||
Profesional.fromDocument(snapshot.data()!),
|
||||
toFirestore: (user, _) => user.toDocument(),
|
||||
);
|
||||
|
||||
await docProfessional.set(profesional!);
|
||||
|
||||
NotificationsService.showSnackbar('Información actualizada');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<bool> updateProfesionalProfileScheduleInfo(String userId) async {
|
||||
final docProfessional = FirebaseFirestore.instance
|
||||
.collection('professional_info')
|
||||
.doc(userId)
|
||||
.withConverter(
|
||||
fromFirestore: (snapshot, _) =>
|
||||
Profesional.fromDocument(snapshot.data()!),
|
||||
toFirestore: (user, _) => user.toDocument(),
|
||||
);
|
||||
|
||||
await docProfessional.set(profesional!);
|
||||
|
||||
NotificationsService.showSnackbar('Información actualizada');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<Profesional> uploadPdfIdentification(
|
||||
Uint8List fileBytes, String userId) async {
|
||||
try {
|
||||
final storageRef = FirebaseStorage.instance
|
||||
.ref()
|
||||
.child('$userId/PDF/${userId}_cedula.pdf');
|
||||
|
||||
await storageRef.putData(fileBytes);
|
||||
final url = await storageRef.getDownloadURL();
|
||||
|
||||
copyProfesionalWith(identificationPicture: url);
|
||||
|
||||
notifyListeners();
|
||||
|
||||
return profesional!;
|
||||
} catch (e) {
|
||||
print("Error al subir el PDF de identificación: $e");
|
||||
NotificationsService.showSnackbar('Error al subir el PDF');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Profesional> uploadPdfCertificate(
|
||||
Uint8List fileBytes, String userId) async {
|
||||
try {
|
||||
final storageRef = FirebaseStorage.instance
|
||||
.ref()
|
||||
.child('$userId/PDF/${userId}_certificado.pdf');
|
||||
|
||||
await storageRef.putData(fileBytes);
|
||||
final url = await storageRef.getDownloadURL();
|
||||
|
||||
copyProfesionalWith(certificatePicture: url);
|
||||
|
||||
notifyListeners();
|
||||
|
||||
return profesional!;
|
||||
} catch (e) {
|
||||
print("Error al subir el PDF de identificación: $e");
|
||||
NotificationsService.showSnackbar('Error al subir el PDF');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<Profesional> uploadPdfSpecializations(
|
||||
List<Uint8List> filesBytes, String userId) async {
|
||||
try {
|
||||
List<String> urls = [];
|
||||
|
||||
for (int i = 0; i < filesBytes.length; i++) {
|
||||
final storageRef = FirebaseStorage.instance.ref().child(
|
||||
'$userId/PDF/${userId}_${DateTime.now().millisecondsSinceEpoch}_especializacion_$i.pdf');
|
||||
|
||||
await storageRef.putData(filesBytes[i]);
|
||||
|
||||
final url = await storageRef.getDownloadURL();
|
||||
urls.add(url);
|
||||
}
|
||||
|
||||
copyProfesionalWith(specializationsPictures: urls);
|
||||
|
||||
notifyListeners();
|
||||
|
||||
return profesional!;
|
||||
} catch (e) {
|
||||
print("Error al subir los PDFs de especialización: $e");
|
||||
NotificationsService.showSnackbar('Error al subir los PDFs');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user