feat(shifts): implement submit for approval functionality

- Added `submitForApproval` method to `ShiftsRepositoryInterface` and its implementation in `ShiftsRepositoryImpl`.
- Created `SubmitForApprovalUseCase` to handle the submission logic.
- Updated `ShiftsBloc` to handle `SubmitForApprovalEvent` and manage submission state.
- Enhanced `HistoryShiftsTab` and `MyShiftsTab` to support submission actions and display appropriate UI feedback.
- Refactored date utilities for better calendar management and filtering of past shifts.
- Improved UI components for better spacing and alignment.
- Localized success messages for shift submission actions.
This commit is contained in:
Achintha Isuru
2026-03-18 14:37:55 -04:00
parent 3e5b6af8dc
commit 3a5f2cc9c6
50 changed files with 1269 additions and 408 deletions

View File

@@ -1,5 +1,6 @@
import 'dart:async';
import 'package:core_localization/core_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_core/core.dart';
@@ -84,7 +85,7 @@ class _SessionListenerState extends State<SessionListener> {
if (!_isInitialState) {
debugPrint('[SessionListener] Session error: ${state.errorMessage}');
_showSessionErrorDialog(
state.errorMessage ?? 'Session error occurred',
state.errorMessage ?? t.session.error_title,
);
} else {
_isInitialState = false;
@@ -101,22 +102,21 @@ class _SessionListenerState extends State<SessionListener> {
/// Shows a dialog when the session expires.
void _showSessionExpiredDialog() {
final Translations translations = t;
showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
builder: (BuildContext dialogContext) {
return AlertDialog(
title: const Text('Session Expired'),
content: const Text(
'Your session has expired. Please log in again to continue.',
),
title: Text(translations.session.expired_title),
content: Text(translations.session.expired_message),
actions: <Widget>[
TextButton(
onPressed: () {
Modular.to.popSafe();
Navigator.of(dialogContext).pop();
_proceedToLogin();
},
child: const Text('Log In'),
child: Text(translations.session.log_in),
),
],
);
@@ -126,27 +126,28 @@ class _SessionListenerState extends State<SessionListener> {
/// Shows a dialog when a session error occurs, with retry option.
void _showSessionErrorDialog(String errorMessage) {
final Translations translations = t;
showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
builder: (BuildContext dialogContext) {
return AlertDialog(
title: const Text('Session Error'),
title: Text(translations.session.error_title),
content: Text(errorMessage),
actions: <Widget>[
TextButton(
onPressed: () {
// User can retry by dismissing and continuing
Modular.to.popSafe();
Navigator.of(dialogContext).pop();
},
child: const Text('Continue'),
child: Text(translations.common.continue_text),
),
TextButton(
onPressed: () {
Modular.to.popSafe();
Navigator.of(dialogContext).pop();
_proceedToLogin();
},
child: const Text('Log Out'),
child: Text(translations.session.log_out),
),
],
);