feat: migrate prosapp_web_app from Firebase to NestJS API

- Replace Firebase Auth with JWT stored in SharedPreferences
- Replace Firestore with REST API calls via new ApiService
- Replace Firebase Storage with POST /storage/upload
- Remove firebase_auth, firebase_core, cloud_firestore,
  firebase_storage, firebase_messaging, google_sign_in deps
- Add api_service.dart as central HTTP client

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-17 13:19:28 -05:00
co-authored by Claude Sonnet 4.6
parent 1c20d0c0cd
commit b95e0630de
45 changed files with 2531 additions and 5865 deletions
+41 -63
View File
@@ -1,75 +1,53 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:prosappco/src/presentation/screens/professional.dart';
class UserModel {
final String id;
final String name;
final String city;
final String? profession;
final String? state;
final Reference? photo;
final int proState;
final String? picture;
final String? banner;
final int? tarifa;
final String? phoneNumber;
final String? token;
final String? email;
final String? gender;
final String? birthday;
UserModel(this.name, this.city, this.profession, this.state, this.photo,
this.tarifa, this.phoneNumber, this.token);
UserModel({
required this.id,
required this.name,
required this.city,
this.profession,
this.proState = 0,
this.picture,
this.banner,
this.tarifa,
this.phoneNumber,
this.email,
this.gender,
this.birthday,
});
static Future<UserModel> fromJson(
Map<String, dynamic>? json, String uid) async {
try {
if (json == null) return UserModel('', '', '', null, null, 0, '', '');
String? avatar = json['photo'];
return UserModel(
json['name'],
json['city'],
json['profesion'],
json['estado'],
avatar != null ? storage.ref().child(avatar) : null,
json['tarifas'] ?? 0,
json['phoneNumber'],
json['token'],
);
} catch (e) {
print('$e');
return UserModel('', '', '', null, null, 0, '', '');
}
factory UserModel.fromApi(Map<String, dynamic> json) {
final professional = json['professionals'] as Map<String, dynamic>?;
return UserModel(
id: json['id'] ?? '',
name: json['name'] ?? 'Sin nombre',
city: json['city'] ?? '',
profession: professional?['profession'],
proState: json['pro_state'] ?? 0,
picture: json['picture'],
banner: professional?['banner_picture'],
tarifa: professional?['rate'] != null
? double.tryParse(professional!['rate'].toString())?.toInt()
: null,
phoneNumber: json['phone'],
email: json['email'],
gender: json['gender'],
birthday: json['birthday'],
);
}
@override
String toString() {
return 'UserModel(name: $name, city: $city, profession: $profession, state: $state, tarifa: $tarifa, phoneNumber: $phoneNumber, token: $token)';
}
static UserModel fromFirestore(Map<String, dynamic> firestoreMap) {
try {
String? avatar = firestoreMap['photo'];
return UserModel(
firestoreMap['name'] ?? 'Sin nombre',
firestoreMap['city'] ?? 'Sin ciudad',
firestoreMap['profesion'],
firestoreMap['estado'],
avatar != null ? storage.ref().child(avatar) : null,
firestoreMap['tarifas'] ?? 0,
firestoreMap['phoneNumber'] ?? 'Sin numero',
firestoreMap['token'],
);
} catch (e) {
print('DesdeProvider $e');
return UserModel('', '', '', null, null, 0, '', '');
}
}
static Future<UserModel> getUser(String uid) async {
try {
final snapshot =
await FirebaseFirestore.instance.collection('users').doc(uid).get();
final Map<String, dynamic>? data = snapshot.data();
return fromJson(data, uid);
} catch (e) {
print('Error getting user: $e');
return UserModel('', '', '', null, null, 0, '', '');
}
}
String toString() =>
'UserModel(id: $id, name: $name, city: $city, profession: $profession, proState: $proState)';
}