import 'package:cloud_firestore/cloud_firestore.dart';

Future<List<Map<String, dynamic>>> dbGetCategories() async {
  final snapshot = await FirebaseFirestore.instance.collection('categories').get();
  return snapshot.docs.map((doc) => doc.data()).toList();
}

Future<Map<String, dynamic>?> dbGetItemById(String itemId) async {
  try {
    final doc = await FirebaseFirestore.instance.collection('items').doc(itemId).get();

    if (doc.exists) {
      return doc.data();
    }
    return null;
  } catch (e) {
    print('Error fetching item: $e');
    return null;
  }
}
