Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
Hot-fix: Handle case attendance new day
Browse files Browse the repository at this point in the history
  • Loading branch information
Hieu Bui authored and hieutbui committed Jan 2, 2025
1 parent 557216f commit 7c002d4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/data/datasource/employee_datasource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ abstract class EmployeeDataSource {
required String clockOut,
required String date,
});
Future<Map<String, dynamic>> getEmployeeAttendance({
Future<Map<String, dynamic>?> getEmployeeAttendance({
required String employeeId,
});
Future<Map<String, dynamic>> saveAttendanceToXlsx({
Expand Down
4 changes: 2 additions & 2 deletions lib/data/datasource_impl/employee_datasource_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class EmployeeDataSourceImpl extends EmployeeDataSource {
}

@override
Future<Map<String, dynamic>> getEmployeeAttendance({
Future<Map<String, dynamic>?> getEmployeeAttendance({
required String employeeId,
}) async {
const table = EmployeeAttendanceTable();
Expand All @@ -272,7 +272,7 @@ class EmployeeDataSourceImpl extends EmployeeDataSource {
.select()
.eq(table.employeeId, employeeId)
.eq(table.date, dateFormatter.format(now))
.single();
.maybeSingle();
}

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/data/repository/employee_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class EmployeeRepositoryImpl implements EmployeeRepository {
}

@override
Future<Map<String, dynamic>> getEmployeeAttendance({
Future<Map<String, dynamic>?> getEmployeeAttendance({
required String employeeId,
}) {
return _dataSource.getEmployeeAttendance(employeeId: employeeId);
Expand Down
2 changes: 1 addition & 1 deletion lib/domain/repository/employee_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ abstract class EmployeeRepository {
required String date,
});

Future<Map<String, dynamic>> getEmployeeAttendance({
Future<Map<String, dynamic>?> getEmployeeAttendance({
required String employeeId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GetEmployeeAttendanceStatusInteractor with InteractorLoggy {
employeeId: employeeId,
);

if (result.isEmpty) {
if (result == null || result.isEmpty) {
yield const Right(GetEmployeeAttendanceStatusEmpty());
} else {
final employeeAttendance = EmployeeAttendance.fromJson(result);
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/live_overview/live_overview_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ Widget? _buildCheckInButton(
return ValueListenableBuilder(
valueListenable: controller.getEmployeeAttendanceStatusStateNotifier,
builder: (context, statusState, child) {
print('statusState: $statusState');
if (statusState is GetEmployeeAttendanceStatusInitial) {
return TextButton.icon(
onPressed: controller.onCheckInPressed,
Expand Down Expand Up @@ -579,7 +580,7 @@ Widget? _buildCheckInButton(
builder: (context, state, child) {
if (state is CheckInInitial) {
return TextButton.icon(
onPressed: () {},
onPressed: controller.onCheckInPressed,
label: Text(
'Check in',
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
Expand Down Expand Up @@ -626,7 +627,7 @@ Widget? _buildCheckInButton(

if (state is CheckInFailure) {
return TextButton.icon(
onPressed: () {},
onPressed: controller.onCheckInPressed,
label: Text(
'Check in: Failed',
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
Expand Down

0 comments on commit 7c002d4

Please sign in to comment.