hide professional-blocked slots from user-facing calendar
CalendarView now treats self_booked services as unavailable: - _isBlocked() filters slots with selfBooked status from the range list - _isHora1Ocupada() excludes selfBooked so they don't show as Ocupado - Blocked slots render as grey "No disponible" with block icon Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
52845c59fd
commit
1870159dea
@@ -3,6 +3,7 @@ import 'package:intl/intl.dart';
|
||||
import 'package:prosapp_web_app/models/profesional.dart';
|
||||
import 'package:prosapp_web_app/models/schedules_entity.dart';
|
||||
import 'package:prosapp_web_app/models/service.dart';
|
||||
import 'package:prosapp_web_app/models/service_status.dart';
|
||||
import 'package:prosapp_web_app/providers/professional_form_provider.dart';
|
||||
import 'package:prosapp_web_app/providers/professional_provider.dart';
|
||||
import 'package:prosapp_web_app/providers/calendar_services_provider.dart';
|
||||
@@ -215,12 +216,22 @@ class _CalendarViewState extends State<CalendarView> {
|
||||
}
|
||||
}
|
||||
|
||||
bool _isBlocked(TimeOfDay hora1, List<Service>? events, DateTime selectedDay) {
|
||||
if (events == null) return false;
|
||||
final dayStr = selectedDay.toIso8601String().split('T').first;
|
||||
return events.any((e) =>
|
||||
e.day == dayStr &&
|
||||
e.range1Hour1 == hora1 &&
|
||||
e.status == ServiceStatus.selfBooked);
|
||||
}
|
||||
|
||||
bool _isHora1Ocupada(
|
||||
TimeOfDay hora1, List<Service>? events, DateTime selectedDay) {
|
||||
if (events != null) {
|
||||
for (Service event in events) {
|
||||
if (selectedDay.toIso8601String().split('T').first == event.day) {
|
||||
if (hora1 == event.range1Hour1) {
|
||||
if (hora1 == event.range1Hour1 &&
|
||||
event.status != ServiceStatus.selfBooked) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -285,6 +296,46 @@ class _CalendarViewState extends State<CalendarView> {
|
||||
);
|
||||
}
|
||||
|
||||
if (_isBlocked(time, events, selectedDay)) {
|
||||
return Card(
|
||||
elevation: 4,
|
||||
margin: const EdgeInsets.only(top: 15, left: 10, right: 10),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
leading: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.grey,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(Icons.block, color: Colors.white),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
ScheduleEntity.getFormatTime(time) ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
subtitle: const Text(
|
||||
'No disponible',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (_isHora1Ocupada(time, events, selectedDay)) {
|
||||
return Card(
|
||||
elevation: 4,
|
||||
|
||||
Reference in New Issue
Block a user