Add: Getting items by its ids

This commit is contained in:
2024-05-23 22:12:07 +03:00
parent d6f64465b3
commit 0438a6feec
3 changed files with 34 additions and 23 deletions

View File

@@ -60,12 +60,12 @@ class _BasketPageState extends State<BasketPage> {
List<GymItem> cartItems = [];
double totalPrice = 0;
List<GymItem> gymCart = [];
bool _isLoading = true;
@override
void initState() {
super.initState();
Future.microtask(() => getCart().then((value) async {
//TODO: Сделать через получение конкретных товаров через getItemsByIds
final itemIds =
value.map((element) => element['id'] as String).toList();
final items = await getItemsByIds(context, itemIds);
@@ -78,6 +78,7 @@ class _BasketPageState extends State<BasketPage> {
}).toList();
totalPrice = cartItems.fold(
0, (sum, item) => sum + item.price * item.localCount);
_isLoading = false;
});
}));
}
@@ -230,7 +231,7 @@ class _BasketPageState extends State<BasketPage> {
body: Column(
children: [
const GymLinkHeader(title: "Корзина"),
gymCart.isEmpty
_isLoading
? const Expanded(
child: Center(child: CircularProgressIndicator()))
: cartItems.isEmpty