sorted the log view and removed close button
This commit is contained in:
parent
488a921f45
commit
6871eb3c92
@ -268,8 +268,16 @@ class AttendanceController extends GetxController {
|
||||
isLoading.value = false;
|
||||
|
||||
if (response != null) {
|
||||
attendenceLogsView =
|
||||
response.map((json) => AttendanceLogViewModel.fromJson(json)).toList();
|
||||
attendenceLogsView = response
|
||||
.map((json) => AttendanceLogViewModel.fromJson(json))
|
||||
.toList();
|
||||
|
||||
// Sort by activityTime field (latest first)
|
||||
attendenceLogsView.sort((a, b) {
|
||||
if (a.activityTime == null || b.activityTime == null) return 0; // Handle null values if any
|
||||
return b.activityTime!.compareTo(a.activityTime!); // Sort descending (latest first)
|
||||
});
|
||||
|
||||
log.i("Attendance log view fetched for ID: $id");
|
||||
update();
|
||||
} else {
|
||||
|
||||
@ -462,8 +462,19 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
MyText.titleMedium("Attendance Log Details",
|
||||
fontWeight: 700),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MyText.titleMedium(
|
||||
"Attendance Log Details",
|
||||
fontWeight: 700,
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (attendanceController
|
||||
.attendenceLogsView.isNotEmpty) ...[
|
||||
@ -602,14 +613,6 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
||||
],
|
||||
),
|
||||
)),
|
||||
const SizedBox(height: 16),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text("Close"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -872,10 +875,13 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
||||
label: MyText.labelLarge('Action', color: contentTheme.primary)),
|
||||
];
|
||||
|
||||
final rows = attendanceController.regularizationLogs
|
||||
.mapIndexed((index, log) {
|
||||
final uniqueLogKey = '${log.id}-${log.employeeId}'; // Unique key for each log
|
||||
final isUploading = attendanceController.uploadingStates[uniqueLogKey]?.value ?? false; // Check the upload state
|
||||
final rows =
|
||||
attendanceController.regularizationLogs.mapIndexed((index, log) {
|
||||
final uniqueLogKey =
|
||||
'${log.id}-${log.employeeId}'; // Unique key for each log
|
||||
final isUploading =
|
||||
attendanceController.uploadingStates[uniqueLogKey]?.value ??
|
||||
false; // Check the upload state
|
||||
|
||||
return DataRow(cells: [
|
||||
DataCell(
|
||||
@ -939,13 +945,16 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
||||
: () async {
|
||||
if (attendanceController.selectedProjectId == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("Please select a project first")),
|
||||
const SnackBar(
|
||||
content: Text("Please select a project first")),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
attendanceController.uploadingStates[uniqueLogKey]?.value = true; // Start loading
|
||||
final success = await attendanceController.captureAndUploadAttendance(
|
||||
attendanceController.uploadingStates[uniqueLogKey]
|
||||
?.value = true; // Start loading
|
||||
final success = await attendanceController
|
||||
.captureAndUploadAttendance(
|
||||
log.id,
|
||||
log.employeeId,
|
||||
attendanceController.selectedProjectId!,
|
||||
@ -972,18 +981,21 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
||||
attendanceController.selectedProjectId!);
|
||||
}
|
||||
|
||||
attendanceController.uploadingStates[uniqueLogKey]?.value = false; // End loading
|
||||
attendanceController.uploadingStates[uniqueLogKey]
|
||||
?.value = false; // End loading
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AttendanceActionColors
|
||||
.colors[ButtonActions.approve],
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 4, horizontal: 6),
|
||||
backgroundColor:
|
||||
AttendanceActionColors.colors[ButtonActions.approve],
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 4, horizontal: 6),
|
||||
minimumSize: const Size(60, 20),
|
||||
textStyle: const TextStyle(fontSize: 12),
|
||||
),
|
||||
child: isUploading
|
||||
? const CircularProgressIndicator(strokeWidth: 2) // Show loading indicator while uploading
|
||||
? const CircularProgressIndicator(
|
||||
strokeWidth:
|
||||
2) // Show loading indicator while uploading
|
||||
: const Text("Approve"),
|
||||
),
|
||||
|
||||
@ -997,14 +1009,17 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
||||
: () async {
|
||||
if (attendanceController.selectedProjectId == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text("Please select a project first")),
|
||||
const SnackBar(
|
||||
content: Text("Please select a project first")),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
attendanceController.uploadingStates[uniqueLogKey]?.value = true; // Start loading
|
||||
attendanceController.uploadingStates[uniqueLogKey]
|
||||
?.value = true; // Start loading
|
||||
|
||||
final success = await attendanceController.captureAndUploadAttendance(
|
||||
final success = await attendanceController
|
||||
.captureAndUploadAttendance(
|
||||
log.id,
|
||||
log.employeeId,
|
||||
attendanceController.selectedProjectId!,
|
||||
@ -1031,26 +1046,28 @@ class _AttendanceScreenState extends State<AttendanceScreen> with UIMixin {
|
||||
attendanceController.selectedProjectId!);
|
||||
}
|
||||
|
||||
attendanceController.uploadingStates[uniqueLogKey]?.value = false; // End loading
|
||||
attendanceController.uploadingStates[uniqueLogKey]
|
||||
?.value = false; // End loading
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
AttendanceActionColors.colors[ButtonActions.reject],
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 4, horizontal: 6),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 4, horizontal: 6),
|
||||
minimumSize: const Size(60, 20),
|
||||
textStyle: const TextStyle(fontSize: 12),
|
||||
),
|
||||
child: isUploading
|
||||
? const CircularProgressIndicator(strokeWidth: 2) // Show loading indicator while uploading
|
||||
? const CircularProgressIndicator(
|
||||
strokeWidth:
|
||||
2) // Show loading indicator while uploading
|
||||
: const Text("Reject"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]);
|
||||
})
|
||||
.toList();
|
||||
}).toList();
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user