import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../database/database.dart'; import 'database_provider.dart'; class DashboardData { final List topCustomers; final List topItems; final int newOrdersCount; final int ordersOnHoldCount; final int newCustomersCount; DashboardData({ this.topCustomers = const [], this.topItems = const [], this.newOrdersCount = 0, this.ordersOnHoldCount = 0, this.newCustomersCount = 0, }); } final dashboardProvider = FutureProvider.family((ref, idAgente) async { final clientiDao = ref.read(clientiDaoProvider); final articoliDao = ref.read(articoliDaoProvider); final ordiniDao = ref.read(ordiniDaoProvider); final topCusts = await clientiDao.topCustomers(5); final topItems = await articoliDao.getMostSoldItems(5); final newOrdC = await ordiniDao.countNewOrders(); final ordHold = await ordiniDao.countOrdersOnHold(); final newCust = await clientiDao.countNewCustomers(); return DashboardData( topCustomers: topCusts, topItems: topItems, newOrdersCount: newOrdC, ordersOnHoldCount: ordHold, newCustomersCount: newCust, ); });