import 'package:hello_doctor_admin_dashboard/app/firebase/firebase_collection.dart';
import 'package:hello_doctor_admin_dashboard/app/models/help_model.dart';

class HelpService {
  Future<List<HelpModel>> getAllHelpRequests() async {
    try {
      var queryHelp = await FirebaseCollection()
          .helpCenterCol
          .orderBy("createdAt", descending: true)
          .get();
      List<HelpModel> listHelp =
          queryHelp.docs.map((doc) => doc.data()).toList();
      return listHelp;
    } catch (e) {
      return Future.error(e);
    }
  }

  Future<void> updateHelpStatus(String helpId, String newStatus) async {
    try {
      await FirebaseCollection().helpCenterCol.doc(helpId).update({
        'status': newStatus,
      });
    } catch (e) {
      return Future.error(e);
    }
  }
}
