Dashboard date issue fix
This commit is contained in:
parent
7908c2278f
commit
9635548e26
@ -26,7 +26,7 @@ import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import '../../../../data/services/auth_service.dart';
|
||||
import '../../../../data/utils/Pagination.dart';
|
||||
import '../../../../data/utils/toastNotification.dart';
|
||||
import '../../../../data/utils/toastNotification.dart';
|
||||
import '../../../../data/utils/validators.dart';
|
||||
import '../../../layouts/main_layout.dart';
|
||||
import '../../../layouts/responsive_layout.dart';
|
||||
@ -44,12 +44,16 @@ import 'enquiry_inline_SubRow.dart';
|
||||
import 'multi_file_list.dart';
|
||||
|
||||
class EnquiryListStaffInline extends ConsumerStatefulWidget {
|
||||
|
||||
const EnquiryListStaffInline({super.key});
|
||||
@override
|
||||
ConsumerState<EnquiryListStaffInline> createState() => EnquiryStaffState();
|
||||
}
|
||||
|
||||
class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
// bool fromDashboard = false;
|
||||
bool _dashboardInitHandled = false;
|
||||
bool _resetKeyEnable = false;
|
||||
int currentPage = 1;
|
||||
int itemsPerPage = 10;
|
||||
// int itemsPerPage = 5;
|
||||
@ -234,6 +238,26 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
//---------------------- Assign Staff Ends -------------------------------- //
|
||||
//---------------------- Enquiry TAB Initializations Ends -------------------------------- //
|
||||
|
||||
// @override
|
||||
// void didChangeDependencies() {
|
||||
// super.didChangeDependencies();
|
||||
|
||||
// if (_dashboardInitHandled) return;
|
||||
// _dashboardInitHandled = true;
|
||||
|
||||
// final extra = GoRouterState.of(context).extra;
|
||||
|
||||
// if (extra is Map<String, dynamic>) {
|
||||
// fromDashboard = extra['fromDashboard'] ?? false;
|
||||
// }
|
||||
|
||||
// // 🔥 IMPORTANT: Clear date pickers ONLY when coming from dashboard
|
||||
// if (fromDashboard) {
|
||||
// controllers['startDate']?.clear();
|
||||
// controllers['endDate']?.clear();
|
||||
// }
|
||||
// }
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -505,6 +529,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
}
|
||||
|
||||
Future<void> refrshfilterDateRange() async {
|
||||
setState(() {
|
||||
_resetKeyEnable = true;
|
||||
});
|
||||
print('refrshfilterDateRange');
|
||||
// setState(() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@ -624,16 +651,21 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
|
||||
if (dashboardKey == 'fromDashboard' && SelectedStatus == "PrevPending") {
|
||||
setState(() {
|
||||
_dashboardInitHandled = true;
|
||||
});
|
||||
// For PREV PENDING → set date range until yesterday
|
||||
final today = DateTime.now();
|
||||
print('A813 => Fns called => $managerId | $role');
|
||||
// Change to dd-MM-yyyy
|
||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
// final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
//
|
||||
// final yesterday = today.subtract(Duration(days: 1));
|
||||
|
||||
final yesterday = today.subtract(Duration(days: 1));
|
||||
|
||||
fromDt = dateFormat.format(yesterday.subtract(Duration(days: 15)));
|
||||
toDt = dateFormat.format(yesterday);
|
||||
fromDt = _dashboardInitHandled ? controllers['startDate']?.text : '';
|
||||
toDt = _dashboardInitHandled ? controllers['endDate']?.text : '';
|
||||
// fromDt = dateFormat.format(yesterday.subtract(Duration(days: 15)));
|
||||
// toDt = dateFormat.format(yesterday);
|
||||
|
||||
print('PrevPending FROM TO - $fromDt - $toDt');
|
||||
} else if (dashboardKey == 'fromDashboard' &&
|
||||
@ -645,8 +677,11 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
// Change to dd-MM-yyyy
|
||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
|
||||
fromDt = dateFormat.format(today);
|
||||
toDt = dateFormat.format(today);
|
||||
// fromDt = dateFormat.format(today);
|
||||
// toDt = dateFormat.format(today);
|
||||
|
||||
fromDt = _dashboardInitHandled ? controllers['startDate']?.text : '';
|
||||
toDt = _dashboardInitHandled ? controllers['endDate']?.text : '';
|
||||
|
||||
print('PrevPending FROM TO - $fromDt - $toDt');
|
||||
} else if (dashboardKey != 'fromDashboard' &&
|
||||
@ -664,8 +699,25 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
} else {
|
||||
print('A1113 => Fns called => $managerId | $role');
|
||||
print('Enq 1- $fromDt - $toDt');
|
||||
fromDt = fromDateVal;
|
||||
toDt = toDateVal;
|
||||
|
||||
if(_resetKeyEnable = true){
|
||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
final today = DateTime.now();
|
||||
final yesterday = today.subtract(Duration(days: 1));
|
||||
|
||||
fromDt = dateFormat.format(yesterday.subtract(Duration(days: 15)));
|
||||
toDt = dateFormat.format(yesterday);
|
||||
setState(() {
|
||||
controllers['startDate']?.text = fromDt;
|
||||
controllers['endDate']?.text = toDt;
|
||||
});
|
||||
|
||||
} else {
|
||||
fromDt = fromDateVal;
|
||||
toDt = toDateVal;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
print('Enq 2- $fromDt - $toDt');
|
||||
String finalStatus = SelectedStatus;
|
||||
@ -678,8 +730,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
managerId,
|
||||
userId,
|
||||
role,
|
||||
fromDate: fromDt,
|
||||
toDate: toDt,
|
||||
fromDate: _dashboardInitHandled ? controllers['startDate']?.text : fromDt,
|
||||
toDate: _dashboardInitHandled ? controllers['endDate']?.text : toDt,
|
||||
// selectedStatus: (finalStatus != '' && finalStatus != 'PrevPending')
|
||||
// ? finalStatus
|
||||
// : '',
|
||||
@ -700,8 +752,13 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
|
||||
print('A1213 => Fns called => $managerId | $role');
|
||||
|
||||
setState(() {
|
||||
controllers['startDate']?.text = fromDate;
|
||||
controllers['endDate']?.text = toDate;
|
||||
_resetKeyEnable = false;
|
||||
|
||||
controllers['startDate']?.text = fromDate;
|
||||
controllers['endDate']?.text = toDate;
|
||||
|
||||
|
||||
|
||||
if (data is List) {
|
||||
getStaffData = List<Map<String, dynamic>>.from(data);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user