Show overtime checkin when a user does not have a schedule for the day or the schedule ended for the day
This commit is contained in:
parent
3e3e4d560e
commit
84837c4bf2
|
|
@ -426,17 +426,19 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
.map((s) => s.endTime)
|
.map((s) => s.endTime)
|
||||||
.reduce((a, b) => a.isAfter(b) ? a : b)
|
.reduce((a, b) => a.isAfter(b) ? a : b)
|
||||||
: null;
|
: null;
|
||||||
final isPastScheduleEnd =
|
final hasScheduleEnded =
|
||||||
latestScheduleEnd != null && now.isAfter(latestScheduleEnd);
|
latestScheduleEnd != null && now.isAfter(latestScheduleEnd);
|
||||||
|
|
||||||
// If the user has an approved IT Service Request override, treat it as a "schedule" for
|
// If the user has an approved IT Service Request override, treat it as a "schedule" for
|
||||||
// purposes of showing the normal check-in UI (even if the duty schedule list is empty).
|
// purposes of showing the normal check-in UI (even if the duty schedule list is empty).
|
||||||
final hasEffectiveSchedule = hasScheduleToday || hasGeofenceOverride;
|
// (Note: this override should not prevent the overtime check-in from being shown.)
|
||||||
|
|
||||||
|
// Show overtime check-in when the user has no schedule today, or their last
|
||||||
|
// scheduled shift has already ended.
|
||||||
final showOvertimeCard =
|
final showOvertimeCard =
|
||||||
(activeOvertimeLog.isEmpty && _overtimeLogId == null) &&
|
(activeOvertimeLog.isEmpty && _overtimeLogId == null) &&
|
||||||
activeLog.isEmpty &&
|
activeLog.isEmpty &&
|
||||||
(!hasEffectiveSchedule || isPastScheduleEnd);
|
(!hasScheduleToday || hasScheduleEnded);
|
||||||
|
|
||||||
if (kDebugMode && showOvertimeCard) {
|
if (kDebugMode && showOvertimeCard) {
|
||||||
final assignedSchedules = schedules
|
final assignedSchedules = schedules
|
||||||
|
|
@ -447,7 +449,7 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
final assignedTodaySchedules = todaySchedule;
|
final assignedTodaySchedules = todaySchedule;
|
||||||
|
|
||||||
debugPrint(
|
debugPrint(
|
||||||
'Attendance: showOvertimeCard=true (profile=${profile.id}, hasScheduleToday=$hasScheduleToday, isPastScheduleEnd=$isPastScheduleEnd, schedules=${schedules.length}, assigned=${assignedSchedules.length}, assignedToday=${assignedTodaySchedules.length})',
|
'Attendance: showOvertimeCard=true (profile=${profile.id}, hasScheduleToday=$hasScheduleToday, hasScheduleEnded=$hasScheduleEnded, schedules=${schedules.length}, assigned=${assignedSchedules.length}, assignedToday=${assignedTodaySchedules.length})',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (assignedSchedules.isNotEmpty) {
|
if (assignedSchedules.isNotEmpty) {
|
||||||
|
|
@ -716,7 +718,12 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
if (activeOvertimeLog.isNotEmpty || _overtimeLogId != null)
|
if (activeOvertimeLog.isNotEmpty || _overtimeLogId != null)
|
||||||
_buildActiveOvertimeCard(context, theme, colors, activeOvertimeLog)
|
_buildActiveOvertimeCard(context, theme, colors, activeOvertimeLog)
|
||||||
else if (showOvertimeCard)
|
else if (showOvertimeCard)
|
||||||
_buildOvertimeCard(context, theme, colors)
|
_buildOvertimeCard(
|
||||||
|
context,
|
||||||
|
theme,
|
||||||
|
colors,
|
||||||
|
hasScheduleToday: hasScheduleToday,
|
||||||
|
)
|
||||||
else
|
else
|
||||||
...todaySchedule.map((schedule) {
|
...todaySchedule.map((schedule) {
|
||||||
// All logs for this schedule.
|
// All logs for this schedule.
|
||||||
|
|
@ -1405,12 +1412,17 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Card shown when user has no schedule — offers overtime check-in.
|
/// Card shown when user has no active schedule (or their schedule has ended).
|
||||||
|
/// Offers overtime check-in.
|
||||||
Widget _buildOvertimeCard(
|
Widget _buildOvertimeCard(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
ThemeData theme,
|
ThemeData theme,
|
||||||
ColorScheme colors,
|
ColorScheme colors, {
|
||||||
) {
|
required bool hasScheduleToday,
|
||||||
|
}) {
|
||||||
|
final headerText = hasScheduleToday
|
||||||
|
? 'Your scheduled shift has ended.'
|
||||||
|
: 'No schedule assigned for today.';
|
||||||
return Card(
|
return Card(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
|
|
@ -1423,7 +1435,7 @@ class _CheckInTabState extends ConsumerState<_CheckInTab> {
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'No schedule assigned for today.',
|
headerText,
|
||||||
style: theme.textTheme.bodyMedium?.copyWith(
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
color: colors.onSurfaceVariant,
|
color: colors.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user