fix(booking): read the live agenda and re-check the slot before confirming
/services/public-calendar also returns the professional's current opening hours; the client threw them away and drew the day from the snapshot the search list carried, which can be days old. It now uses the fresh ones. Between picking an hour and pressing "Pedir cita" another patient can take the slot. The confirm step asks the agenda again and, if the hour is gone, says so and clears the selection instead of creating a service the professional would have to deny. A failed re-check lets the booking through: a network hiccup should not block a patient. Also: - tapping a busy slot with no id explains itself instead of doing nothing - the profile refuses to save an empty rate with the rate switch on, which was reaching the backend as rate: '' Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
0a8e5d11a2
commit
6cb2755858
@@ -663,6 +663,26 @@ class _ProfessionalProfileScreenState
|
||||
}
|
||||
|
||||
void _save() {
|
||||
// Saving with the rate switch on and the field empty used to send
|
||||
// `rate: ''`, and the patient then saw a professional with no price.
|
||||
if (rateValue) {
|
||||
final rate = int.tryParse(_rateController.text.trim()) ?? 0;
|
||||
if (rate <= 0) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Escribe el valor de tu tarifa o desactívala'),
|
||||
));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (_addressController.text.trim().isEmpty) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Escribe la dirección donde atiendes'),
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
context.read<ProfessionalProfileBloc>().add(UpdateProfessionalProfileInfo(
|
||||
address: _addressController.text,
|
||||
aditionalAddress: _aditionalAddressController.text,
|
||||
@@ -682,7 +702,7 @@ class _ProfessionalProfileScreenState
|
||||
),
|
||||
schedules: schedules,
|
||||
ratePreferences: rateValue,
|
||||
rate: _rateController.text,
|
||||
rate: rateValue ? _rateController.text.trim() : '',
|
||||
slotDurationMinutes: _slotDurationMinutes,
|
||||
));
|
||||
if (_imageFile != null) {
|
||||
|
||||
Reference in New Issue
Block a user