fix: Update regularization time picker to use reference time and allow past times for regularization
This commit is contained in:
parent
82c2cc3c58
commit
f0d42edcc1
@ -41,33 +41,26 @@ class _AttendanceActionButtonState extends State<AttendanceActionButton> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<DateTime?> _pickRegularizationTime(DateTime checkInTime) async {
|
Future<DateTime?> _pickRegularizationTime(DateTime referenceTime) async {
|
||||||
final pickedTime = await showTimePicker(
|
final pickedTime = await showTimePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialTime: TimeOfDay.fromDateTime(DateTime.now()),
|
initialTime:
|
||||||
|
TimeOfDay.fromDateTime(referenceTime), // start from actual log time
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pickedTime == null) return null;
|
if (pickedTime == null) return null;
|
||||||
|
|
||||||
final selected = DateTime(
|
final selected = DateTime(
|
||||||
checkInTime.year,
|
referenceTime.year,
|
||||||
checkInTime.month,
|
referenceTime.month,
|
||||||
checkInTime.day,
|
referenceTime.day,
|
||||||
pickedTime.hour,
|
pickedTime.hour,
|
||||||
pickedTime.minute,
|
pickedTime.minute,
|
||||||
);
|
);
|
||||||
|
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
|
|
||||||
if (selected.isBefore(checkInTime)) {
|
// Allow times before check-in for regularization, but never future
|
||||||
showAppSnackbar(
|
|
||||||
title: "Invalid Time",
|
|
||||||
message: "Time must be after check-in.",
|
|
||||||
type: SnackbarType.warning,
|
|
||||||
);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selected.isAfter(now)) {
|
if (selected.isAfter(now)) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Invalid Time",
|
title: "Invalid Time",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user