mirrored_repositories/Expenses_Tracker_App/packages/expense_repository/lib/src
import 'package:expense_repository/src/entities/category_entity_new.dart';

class Category {
  String? categoryId;
  String name;
  String imagePath;

  Category({
    this.categoryId,
    required this.name,
    required this.imagePath,
  });

  static final empty = Category(categoryId: '', name: '', imagePath: '');

  Map<String, dynamic> toDocument() {
    return {
      'categoryId': categoryId,
      'name': name,
      'imagePath': imagePath,
    };
  }

  static Category fromDocument(Map<String, dynamic> doc) {
    return Category(
      categoryId: doc['categoryId'] ?? '',
      name: doc['name'] ?? '',
      imagePath: doc['imagePath'] ?? '',
    );
  }

  CategoryEntity toEntity() {
    return CategoryEntity(
      categoryId: categoryId,
      name: name,
      imagePath: imagePath,
    );
  }

  static Category fromEntity(CategoryEntity entity) {
    return Category(
      categoryId: entity.categoryId,
      name: entity.name,
      imagePath: entity.imagePath,
    );
  }
}
