import 'package:first_project/data/dtos/anime_dto.dart';
import 'package:first_project/domain/models/home.dart';
import 'package:first_project/presentation/home_page/home_page.dart';

extension AnimeDataDtoToModel on AnimeDataDto {
  CardData toDomain() => CardData(
        title ?? 'NOT',
        imageUrl: images?.jpg?.image ?? "NONE",
        score: score ?? 0,
        description: synopsis == null
            ? "NONE"
            : synopsis!.split('\n').sublist(0, synopsis!.split('\n').length - 1).join('\n'),
        id: id.toString(),
      );
}

extension AnimesDataDtoToModel on AnimesDto {
  HomeData toDomain() => HomeData(
        data: data?.map((e) => e.toDomain()).toList(),
        nextPage: pagination!.next! ? pagination!.current! + 1 : 0,
      );
}
