fix: port 7 web features and repair the endless-loading screens

Root cause behind most "stuck loading" reports: the backend changed shape
(schedules became an array, location_preferences a string) while the mobile
parser still hard-cast to Map/int. The TypeError was swallowed by a silent
catch that returned null, and screens only handled the success state, so a
parse failure rendered as a permanent spinner. Same class of bug appeared
across service lists via non-null map lookups and a total absence of
request timeouts.

Ported from prosappweb:
- in-app suggestions (POST /suggestions)
- policies/terms from GET /settings/policies
- configurable appointment length (slot_duration_minutes)
- block/unblock calendar slots (POST /services/block)
- GPS city detection on the profile (Nominatim)
- server-side professional search with haversine distance
- retry cooldown after a rejected professional application

Reliability:
- parse schedules array (day_of_week 0=Mon) and string location_preferences
- read times as wall clock, so 08:00 stays 08:00 across timezones
- carry minutes into hours in TimeOfDay.add; a minute-based step used to
  loop forever and freeze the calendar (covered by test/time_slots_test.dart)
- semver update check instead of string equality, which blocked every build
  that did not exactly match the configured version
- request timeouts across all repositories
- surface HTTP >= 400 instead of reporting failed writes as success
- error states with retry instead of an indefinite shimmer

Includes pre-existing uncommitted work from the UI redesign.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-08-24 16:45:42 -05:00
co-authored by Claude Opus 5
parent 06a89df690
commit 8631e6f729
86 changed files with 5470 additions and 5291 deletions
@@ -30,6 +30,8 @@ class _ProfessionalFormScreenState extends State<ProfessionalFormScreen> {
PlatformFile? _certificadoPdfFile;
List<PlatformFile>? _especializacionesPdfFiles = [];
bool _isSubmitting = false;
late final AuthBloc authBloc;
@override
@@ -50,7 +52,37 @@ class _ProfessionalFormScreenState extends State<ProfessionalFormScreen> {
Widget build(BuildContext context) {
return BlocProvider<AuthBloc>(
create: (context) => authBloc,
child: Scaffold(
child: BlocListener<ProfessionalBloc, ProfessionalState>(
listener: (context, professionalState) {
if (professionalState is SendProfessionalToReviewLoading) {
setState(() => _isSubmitting = true);
} else if (professionalState is SendProfessionalToReviewSuccess) {
setState(() => _isSubmitting = false);
// The picture upload only runs once the application actually landed.
final user = context.read<MyUserBloc>().state.user;
if (user != null) {
context.read<ProfileBloc>().add(UpdateUserInfo(
myUser: user.copyWith(proState: ProState.pending),
filePicture: _imageFile?.path));
}
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Información enviada a revisión')),
);
Navigator.pop(context);
} else if (professionalState is SendProfessionalToReviewFailure) {
setState(() => _isSubmitting = false);
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'No se pudo enviar tu solicitud. Revisa tu conexión e inténtalo de nuevo.')),
);
}
},
child: Scaffold(
appBar: AppBar(
title: const Text('Perfil profesional'),
),
@@ -247,9 +279,20 @@ class _ProfessionalFormScreenState extends State<ProfessionalFormScreen> {
horizontal: 15,
),
child: FilledButton(
onPressed: () {
onPressed: _isSubmitting
? null
: () {
final userId =
context.read<MyUserBloc>().state.user!.id;
context.read<MyUserBloc>().state.user?.id;
if (userId == null) {
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'No se pudo identificar tu usuario, vuelve a iniciar sesión')));
return;
}
final String? cedulaPdfPath = _cedulaPdfFile?.path;
final String? certificadoPdfPath =
@@ -300,20 +343,6 @@ class _ProfessionalFormScreenState extends State<ProfessionalFormScreen> {
specializationsPictures:
especializacionesPdfPaths,
));
final myUser =
state.user!.copyWith(proState: ProState.pending);
context.read<ProfileBloc>().add(UpdateUserInfo(
myUser: myUser, filePicture: _imageFile?.path));
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Información enviada a revisión')),
);
Navigator.pop(context);
},
style: FilledButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary,
@@ -325,19 +354,27 @@ class _ProfessionalFormScreenState extends State<ProfessionalFormScreen> {
child: Container(
alignment: Alignment.center,
width: double.infinity,
child: const Text(
'Enviar a revisión',
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
child: _isSubmitting
? const SizedBox(
height: 22,
width: 22,
child: CircularProgressIndicator(
strokeWidth: 2, color: Colors.white),
)
: const Text(
'Enviar a revisión',
style: TextStyle(
color: Colors.white,
fontSize: 18,
),
),
),
)),
],
);
},
),
),
),
);
}