Files
prosappco/lib/blocs/service_bloc/service_event.dart
T
Lizandro GuarnizoandClaude Opus 5 8631e6f729 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>
2026-08-24 16:45:42 -05:00

177 lines
3.7 KiB
Dart

part of 'service_bloc.dart';
abstract class ServiceEvent extends Equatable {
const ServiceEvent();
@override
List<Object?> get props => [];
}
class LoadService extends ServiceEvent {
final String serviceId;
const LoadService(this.serviceId);
@override
List<Object?> get props => [serviceId];
}
class UpdateServiceStatus extends ServiceEvent {
final String serviceId;
final ServiceStatus newStatus;
const UpdateServiceStatus(this.serviceId, this.newStatus);
@override
List<Object> get props => [serviceId, newStatus];
}
class BlockSlot extends ServiceEvent {
final String day;
final TimeOfDay hour1;
const BlockSlot({required this.day, required this.hour1});
@override
List<Object> get props => [day, hour1];
}
class LoadServicesForUser extends ServiceEvent {
final String userId;
const LoadServicesForUser(this.userId);
@override
List<Object> get props => [userId];
}
class LoadPendingServicesForProfessional extends ServiceEvent {
final String userId;
const LoadPendingServicesForProfessional(this.userId);
@override
List<Object> get props => [userId];
}
class LoadServicesForProfessional extends ServiceEvent {
final String userId;
const LoadServicesForProfessional(this.userId);
@override
List<Object> get props => [userId];
}
class LoadServicesHistoryForProfessional extends ServiceEvent {
final String userId;
const LoadServicesHistoryForProfessional(this.userId);
@override
List<Object> get props => [userId];
}
class LoadServicesHistoryForUser extends ServiceEvent {
final String userId;
const LoadServicesHistoryForUser(this.userId);
@override
List<Object> get props => [userId];
}
class LoadServicesByDay extends ServiceEvent {
final String day;
const LoadServicesByDay(this.day);
@override
List<Object> get props => [day];
}
class UpdateProfessionalScored extends ServiceEvent {
final String serviceId;
const UpdateProfessionalScored(this.serviceId);
@override
List<Object> get props => [serviceId];
}
class UpdateUserScored extends ServiceEvent {
final String serviceId;
const UpdateUserScored(this.serviceId);
@override
List<Object> get props => [serviceId];
}
class CountPendingServicesForProfessional extends ServiceEvent {
final String professionalId;
const CountPendingServicesForProfessional(this.professionalId);
@override
List<Object?> get props => [professionalId];
}
class CreateService extends ServiceEvent {
final String professionalId;
final bool? professionalScored;
final String userId;
final bool? userScored;
final String address;
final String aditionalAddress;
final double latitude;
final double longitude;
final String day;
final String createdAt;
final String description;
final TimeOfDay range1Hour1;
final TimeOfDay range1Hour2;
final String rate;
final ServiceStatus? status;
final ServiceLocationPreferences location;
const CreateService({
required this.professionalId,
this.professionalScored,
required this.userId,
this.userScored,
required this.address,
required this.aditionalAddress,
required this.latitude,
required this.longitude,
required this.day,
required this.createdAt,
required this.description,
required this.range1Hour1,
required this.range1Hour2,
required this.rate,
this.status,
required this.location,
});
@override
List<Object?> get props => [
professionalId,
professionalScored,
userId,
userScored,
address,
aditionalAddress,
latitude,
longitude,
day,
createdAt,
description,
range1Hour1,
range1Hour2,
rate,
status,
location,
];
}