Fix request professional flow for new users
- Add Profesional.empty() factory for users with no professional record - initState: catch error from getProfessional and show empty form instead of infinite spinner - Backend upsert: create professional record if none exists (no longer throws 404) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
f1dc2cb75d
commit
eb63a3e415
@@ -46,6 +46,28 @@ class Profesional {
|
||||
required this.paymentMethods,
|
||||
});
|
||||
|
||||
static Profesional empty() => Profesional(
|
||||
id: '',
|
||||
identification: '',
|
||||
rethusCode: '',
|
||||
rethusValidated: false,
|
||||
address: '',
|
||||
aditionalAddress: '',
|
||||
profession: '',
|
||||
ratePreferences: false,
|
||||
rate: '',
|
||||
locationPreferences: LocationPreferences.office,
|
||||
bannerPicture: '',
|
||||
identificationPicture: '',
|
||||
certificatePicture: '',
|
||||
latitude: 0.0,
|
||||
longitude: 0.0,
|
||||
specializations: [],
|
||||
specializationsPictures: [],
|
||||
schedules: Schedules.empty,
|
||||
paymentMethods: PaymentMethodEntity.empty,
|
||||
);
|
||||
|
||||
static Profesional fromDocument(Map<String, dynamic> doc) {
|
||||
// Backend returns schedules as array [{day_of_week, enabled, ...}]; convert to Schedules
|
||||
Schedules parsedSchedules = Schedules.empty;
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:typed_data';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:prosapp_web_app/models/pro_state.dart';
|
||||
import 'package:prosapp_web_app/models/profesional.dart';
|
||||
import 'package:prosapp_web_app/providers/auth_provider.dart';
|
||||
import 'package:prosapp_web_app/providers/professional_form_provider.dart';
|
||||
import 'package:prosapp_web_app/providers/professional_provider.dart';
|
||||
@@ -30,7 +31,10 @@ class _RequestProfessionalViewState extends State<RequestProfessionalView> {
|
||||
.read<ProfessionalProvider>()
|
||||
.getProfessional(auth.user!.id)
|
||||
.then((pro) =>
|
||||
context.read<ProfessionalFormProvider>().setProfesional(pro));
|
||||
context.read<ProfessionalFormProvider>().setProfesional(pro))
|
||||
.catchError((_) {
|
||||
context.read<ProfessionalFormProvider>().setProfesional(Profesional.empty());
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user