refactor(clock_in): rename error handling variable for clarity in check-in interactions
This commit is contained in:
@@ -47,6 +47,7 @@ If any of these files are missing or unreadable, notify the user before proceedi
|
||||
- Skip tests for business logic
|
||||
|
||||
### ALWAYS:
|
||||
- **Use `package:` imports everywhere inside `lib/`** for consistency and robustness. Use relative imports only in `test/` and `bin/` directories. Example: `import 'package:staff_clock_in/src/presentation/bloc/clock_in/clock_in_bloc.dart';` not `import '../bloc/clock_in/clock_in_bloc.dart';`
|
||||
- Place reusable utility functions (math, geo, formatting, etc.) in `apps/mobile/packages/core/lib/src/utils/` and export from `core.dart` — never keep them as private methods in feature packages
|
||||
- Use feature-first packaging: `domain/`, `data/`, `presentation/`
|
||||
- Export public API via barrel files
|
||||
|
||||
@@ -16,7 +16,7 @@ abstract class CheckInInteraction {
|
||||
required bool isCheckedIn,
|
||||
required bool isDisabled,
|
||||
required bool isLoading,
|
||||
required bool hasError,
|
||||
required bool hasClockinError,
|
||||
required VoidCallback onCheckIn,
|
||||
required VoidCallback onCheckOut,
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ class NfcCheckInInteraction implements CheckInInteraction {
|
||||
required bool isCheckedIn,
|
||||
required bool isDisabled,
|
||||
required bool isLoading,
|
||||
required bool hasError,
|
||||
required bool hasClockinError,
|
||||
required VoidCallback onCheckIn,
|
||||
required VoidCallback onCheckOut,
|
||||
}) {
|
||||
|
||||
@@ -16,7 +16,7 @@ class SwipeCheckInInteraction implements CheckInInteraction {
|
||||
required bool isCheckedIn,
|
||||
required bool isDisabled,
|
||||
required bool isLoading,
|
||||
required bool hasError,
|
||||
required bool hasClockinError,
|
||||
required VoidCallback onCheckIn,
|
||||
required VoidCallback onCheckOut,
|
||||
}) {
|
||||
@@ -24,7 +24,7 @@ class SwipeCheckInInteraction implements CheckInInteraction {
|
||||
isCheckedIn: isCheckedIn,
|
||||
isDisabled: isDisabled,
|
||||
isLoading: isLoading,
|
||||
hasError: hasError,
|
||||
hasClockinError: hasClockinError,
|
||||
onCheckIn: onCheckIn,
|
||||
onCheckOut: onCheckOut,
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_modular/flutter_modular.dart';
|
||||
import 'package:krow_core/core.dart';
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'package:staff_clock_in/src/presentation/widgets/early_check_in_banner.dart';
|
||||
|
||||
import '../../domain/validators/clock_in_validation_context.dart';
|
||||
import '../../domain/validators/validators/time_window_validator.dart';
|
||||
@@ -34,7 +35,7 @@ class ClockInActionSection extends StatelessWidget {
|
||||
required this.checkOutTime,
|
||||
required this.checkInMode,
|
||||
required this.isActionInProgress,
|
||||
this.hasError = false,
|
||||
this.hasClockinError = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -61,7 +62,7 @@ class ClockInActionSection extends StatelessWidget {
|
||||
final bool isActionInProgress;
|
||||
|
||||
/// Whether the last action attempt resulted in an error.
|
||||
final bool hasError;
|
||||
final bool hasClockinError;
|
||||
|
||||
/// Resolves the [CheckInInteraction] for the current mode.
|
||||
///
|
||||
@@ -84,21 +85,21 @@ class ClockInActionSection extends StatelessWidget {
|
||||
|
||||
/// Builds the action widget for an active (not completed) shift.
|
||||
Widget _buildActiveShiftAction(BuildContext context) {
|
||||
// if (!isCheckedIn && !_isCheckInAllowed(selectedShift!)) {
|
||||
// return Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: <Widget>[
|
||||
// const GeofenceStatusBanner(),
|
||||
// const SizedBox(height: UiConstants.space3),
|
||||
// EarlyCheckInBanner(
|
||||
// availabilityTime: _getAvailabilityTimeText(
|
||||
// selectedShift!,
|
||||
// context,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
if (!isCheckedIn && !_isCheckInAllowed(selectedShift!)) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const GeofenceStatusBanner(),
|
||||
const SizedBox(height: UiConstants.space3),
|
||||
EarlyCheckInBanner(
|
||||
availabilityTime: _getAvailabilityTimeText(
|
||||
selectedShift!,
|
||||
context,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return BlocBuilder<GeofenceBloc, GeofenceState>(
|
||||
builder: (BuildContext context, GeofenceState geofenceState) {
|
||||
@@ -122,7 +123,7 @@ class ClockInActionSection extends StatelessWidget {
|
||||
isCheckedIn: isCheckedIn,
|
||||
isDisabled: isGeofenceBlocking,
|
||||
isLoading: isActionInProgress,
|
||||
hasError: hasError,
|
||||
hasClockinError: hasClockinError,
|
||||
onCheckIn: () => _handleCheckIn(context),
|
||||
onCheckOut: () => _handleCheckOut(context),
|
||||
),
|
||||
|
||||
@@ -111,7 +111,7 @@ class _ClockInBodyState extends State<ClockInBody> {
|
||||
checkInMode: state.checkInMode,
|
||||
isActionInProgress:
|
||||
state.status == ClockInStatus.actionInProgress,
|
||||
hasError: state.status == ClockInStatus.failure,
|
||||
hasClockinError: state.status == ClockInStatus.failure,
|
||||
),
|
||||
|
||||
// checked-in banner (only when checked in to the selected shift)
|
||||
|
||||
@@ -17,7 +17,7 @@ class SwipeToCheckIn extends StatefulWidget {
|
||||
this.isLoading = false,
|
||||
this.isCheckedIn = false,
|
||||
this.isDisabled = false,
|
||||
this.hasError = false,
|
||||
this.hasClockinError = false,
|
||||
});
|
||||
|
||||
/// Called when the user completes the swipe to check in.
|
||||
@@ -36,7 +36,7 @@ class SwipeToCheckIn extends StatefulWidget {
|
||||
final bool isDisabled;
|
||||
|
||||
/// Whether an error occurred during the last action attempt.
|
||||
final bool hasError;
|
||||
final bool hasClockinError;
|
||||
|
||||
@override
|
||||
State<SwipeToCheckIn> createState() => _SwipeToCheckInState();
|
||||
@@ -62,7 +62,7 @@ class _SwipeToCheckInState extends State<SwipeToCheckIn>
|
||||
if (_isComplete &&
|
||||
widget.isCheckedIn == oldWidget.isCheckedIn &&
|
||||
((oldWidget.isLoading && !widget.isLoading) ||
|
||||
(!oldWidget.hasError && widget.hasError))) {
|
||||
(!oldWidget.hasClockinError && widget.hasClockinError))) {
|
||||
setState(() {
|
||||
_isComplete = false;
|
||||
_dragValue = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user