fix phone dashboard

This commit is contained in:
root
2026-05-27 03:11:45 -04:00
parent 7ca43ba2f3
commit 1112b04516
48 changed files with 1222 additions and 368 deletions
@@ -15,6 +15,33 @@ class _ContractsScreenState extends ConsumerState<ContractsScreen> {
final _searchCtrl = TextEditingController();
String _search = '';
List<Reservation> _visibleContracts(List<Reservation> reservations) {
final query = _search.trim().toLowerCase();
return reservations.where((reservation) {
if (reservation.contractNumber == null) {
return false;
}
if (query.isEmpty) {
return true;
}
final customer = reservation.customer;
final vehicle = reservation.vehicle;
final haystack = [
customer?.fullName,
customer?.email,
vehicle?.displayName,
vehicle?.licensePlate,
reservation.contractNumber,
reservation.invoiceNumber,
].whereType<String>().join(' ').toLowerCase();
return haystack.contains(query);
}).toList();
}
@override
void dispose() {
_searchCtrl.dispose();
@@ -23,12 +50,14 @@ class _ContractsScreenState extends ConsumerState<ContractsScreen> {
@override
Widget build(BuildContext context) {
final params = {
'page': 1,
'pageSize': 100,
'status': 'CONFIRMED,ACTIVE,COMPLETED,CLOSED',
if (_search.isNotEmpty) 'search': _search,
};
final ReservationQuery params = (
page: 1,
pageSize: 100,
status: null,
source: null,
search: null,
customerId: null,
);
final asyncData = ref.watch(reservationsProvider(params));
@@ -69,9 +98,7 @@ class _ContractsScreenState extends ConsumerState<ContractsScreen> {
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, _) => Center(child: Text('Error: $e')),
data: (response) {
final contracts = response.data
.where((r) => r.contractNumber != null)
.toList();
final contracts = _visibleContracts(response.data);
if (contracts.isEmpty) {
return const Center(