Tab changed to arrived in my appointments

pull/359/head
haroon amjad 1 week ago
parent f20e6e8b16
commit dc6b71a4ca

@ -363,11 +363,25 @@ class MyAppointmentsViewModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
changeTabToArrived() {
if (patientUpcomingAppointmentsHistoryList.isEmpty && patientArrivedAppointmentsHistoryList.isNotEmpty && selectedTabIndex == 0) {
selectedTabIndex = 1;
updateListWRTTab(1);
notifyListeners();
}
}
/// Loads full arrived appointments list if not already loaded /// Loads full arrived appointments list if not already loaded
/// This is called when navigating to My Appointments page from landing page /// This is called when navigating to My Appointments page from landing page
Future<void> loadFullArrivedAppointmentsIfNeeded({Function(dynamic)? onSuccess, Function(String)? onError}) async { Future<void> loadFullArrivedAppointmentsIfNeeded({Function(dynamic)? onSuccess, Function(String)? onError}) async {
// Skip if already loaded // Skip if already loaded
if (isFullArrivedAppointmentsLoaded) { if (isFullArrivedAppointmentsLoaded) {
// Auto-switch to Arrived tab if no upcoming appointments (even when data is already loaded)
if (patientUpcomingAppointmentsHistoryList.isEmpty && patientArrivedAppointmentsHistoryList.isNotEmpty && selectedTabIndex == 0) {
selectedTabIndex = 1;
updateListWRTTab(1);
notifyListeners();
}
return; return;
} }
@ -394,8 +408,14 @@ class MyAppointmentsViewModel extends ChangeNotifier {
isMyAppointmentsLoading = false; isMyAppointmentsLoading = false;
// Update filtered list based on current tab // Auto-switch to Arrived tab if no upcoming appointments
updateListWRTTab(selectedTabIndex); if (patientUpcomingAppointmentsHistoryList.isEmpty && patientArrivedAppointmentsHistoryList.isNotEmpty && selectedTabIndex == 0) {
selectedTabIndex = 1;
updateListWRTTab(1);
} else {
// Update filtered list based on current tab
updateListWRTTab(selectedTabIndex);
}
notifyListeners(); notifyListeners();
if (onSuccess != null) { if (onSuccess != null) {

@ -47,8 +47,7 @@ class _MyAppointmentsPageState extends State<MyAppointmentsPage> {
myAppointmentsViewModel.initAppointmentsViewModel(); myAppointmentsViewModel.initAppointmentsViewModel();
myAppointmentsViewModel.getPatientAppointments(true, false, isForTimeLine: false); myAppointmentsViewModel.getPatientAppointments(true, false, isForTimeLine: false);
} }
// Load full arrived appointments if not already loaded myAppointmentsViewModel.changeTabToArrived();
// myAppointmentsViewModel.loadFullArrivedAppointmentsIfNeeded();
}); });
super.initState(); super.initState();
} }

Loading…
Cancel
Save