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