import 'package:injectable/injectable.dart';
import 'package:krow/features/profile/faq/data/faq_api_provider.dart';
import 'package:krow/features/profile/faq/data/models/faq_entry_model.dart';
import 'package:krow/features/profile/faq/domain/entities/faq_entry.dart';
import 'package:krow/features/profile/faq/domain/faq_repository.dart';

@Injectable(as: FaqRepository)
class FaqRepositoryImpl implements FaqRepository {
  FaqRepositoryImpl({required FaqApiProvider provider}) : _provider = provider;

  final FaqApiProvider _provider;

  FaqEntry _modelConverter(FaqEntryModel data) {
    return FaqEntry(question: data.question, answer: data.answer);
  }

  @override
  Future<List<FaqEntry>> getFaqData() async {
    return [
      for (final entry in await _provider.fetchFaqData())
        _modelConverter(entry),
    ];
  }
}
