add dashboard to phone app
This commit is contained in:
@@ -5,6 +5,8 @@ import '../providers/dashboard_providers.dart';
|
||||
import '../../../widgets/reservation_card.dart';
|
||||
import '../../../widgets/loading_list.dart';
|
||||
import '../../../widgets/error_view.dart';
|
||||
import 'dashboard_shell.dart';
|
||||
import 'new_reservation_screen.dart';
|
||||
|
||||
class ReservationsScreen extends ConsumerStatefulWidget {
|
||||
const ReservationsScreen({super.key});
|
||||
@@ -16,8 +18,24 @@ class ReservationsScreen extends ConsumerStatefulWidget {
|
||||
class _ReservationsScreenState extends ConsumerState<ReservationsScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final TabController _tabs;
|
||||
final _statuses = [null, 'CONFIRMED', 'ACTIVE', 'COMPLETED', 'CANCELLED'];
|
||||
final _labels = ['All', 'Confirmed', 'Active', 'Completed', 'Cancelled'];
|
||||
final _statuses = [
|
||||
null,
|
||||
'DRAFT',
|
||||
'CONFIRMED',
|
||||
'ACTIVE',
|
||||
'COMPLETED',
|
||||
'CLOSED',
|
||||
'CANCELLED',
|
||||
];
|
||||
final _labels = [
|
||||
'All',
|
||||
'Pending',
|
||||
'Confirmed',
|
||||
'Active',
|
||||
'Completed',
|
||||
'Closed',
|
||||
'Cancelled',
|
||||
];
|
||||
final _searchController = TextEditingController();
|
||||
String _search = '';
|
||||
|
||||
@@ -35,15 +53,27 @@ class _ReservationsScreenState extends ConsumerState<ReservationsScreen>
|
||||
}
|
||||
|
||||
Map<String, dynamic> _params(int tabIndex) => {
|
||||
'page': 1,
|
||||
'pageSize': 50,
|
||||
if (_statuses[tabIndex] != null) 'status': _statuses[tabIndex],
|
||||
if (_search.isNotEmpty) 'search': _search,
|
||||
};
|
||||
'page': 1,
|
||||
'pageSize': 50,
|
||||
if (_statuses[tabIndex] != null) 'status': _statuses[tabIndex],
|
||||
if (_search.isNotEmpty) 'search': _search,
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
return DashboardShell(
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
final result = await Navigator.of(context).push<bool>(
|
||||
MaterialPageRoute(builder: (_) => const NewReservationScreen()),
|
||||
);
|
||||
if (result == true) {
|
||||
ref.invalidate(reservationsProvider);
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
child: const Icon(Icons.add),
|
||||
),
|
||||
appBar: AppBar(
|
||||
title: const Text('Reservations'),
|
||||
bottom: TabBar(
|
||||
@@ -74,8 +104,7 @@ class _ReservationsScreenState extends ConsumerState<ReservationsScreen>
|
||||
_statuses.length,
|
||||
(i) => _ReservationTab(
|
||||
params: _params(i),
|
||||
onTap: (id) =>
|
||||
context.push('/dashboard/reservations/$id'),
|
||||
onTap: (id) => context.push('/dashboard/reservations/$id'),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -103,8 +132,11 @@ class _ReservationTab extends ConsumerWidget {
|
||||
),
|
||||
data: (res) => res.data.isEmpty
|
||||
? const Center(
|
||||
child: Text('No reservations found',
|
||||
style: TextStyle(color: Color(0xFF9CA3AF))))
|
||||
child: Text(
|
||||
'No reservations found',
|
||||
style: TextStyle(color: Color(0xFF9CA3AF)),
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async =>
|
||||
ref.invalidate(reservationsProvider(params)),
|
||||
|
||||
Reference in New Issue
Block a user