fix: safe parsing of Prisma Decimal fields to prevent data loss on save
Prisma serializes Decimal fields (rate, latitude, longitude) as JSON strings, causing 'as num?' casts to throw in fromDocument(). The catch block in getProfessional() then returned an empty Profesional, so saving overwrote all existing data with empty strings. Also added try-catch in all patch API calls to surface errors to user instead of silently failing with a stuck loading button. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7451b7c57b
commit
706b78b737
@@ -134,14 +134,16 @@ class Profesional {
|
||||
address: (doc['address'] as String?) ?? '',
|
||||
aditionalAddress: (doc['additional_address'] as String?) ?? '',
|
||||
profession: (doc['profession'] as String?) ?? '',
|
||||
ratePreferences: (doc['rate_preferences'] as bool?) ?? false,
|
||||
rate: (doc['rate'] as num?)?.toString() ?? '',
|
||||
ratePreferences: doc['rate_preferences'] is bool
|
||||
? doc['rate_preferences'] as bool
|
||||
: doc['rate_preferences'] == 'true',
|
||||
rate: doc['rate']?.toString() ?? '',
|
||||
locationPreferences: locationPrefsFromValue(doc['location_preferences']),
|
||||
bannerPicture: (doc['banner_picture'] as String?) ?? '',
|
||||
identificationPicture: (doc['identification_picture'] as String?) ?? '',
|
||||
certificatePicture: (doc['certificate_picture'] as String?) ?? '',
|
||||
latitude: (doc['latitude'] as num?)?.toDouble() ?? 0.0,
|
||||
longitude: (doc['longitude'] as num?)?.toDouble() ?? 0.0,
|
||||
latitude: double.tryParse(doc['latitude']?.toString() ?? '') ?? 0.0,
|
||||
longitude: double.tryParse(doc['longitude']?.toString() ?? '') ?? 0.0,
|
||||
specializations: specs,
|
||||
specializationsPictures: specPics,
|
||||
schedules: parsedSchedules,
|
||||
|
||||
Reference in New Issue
Block a user