import 'package:tugas_akhir_supabase/domain/entities/crop_progress_log.dart';

class CropProgressLogModel extends CropProgressLog {
  const CropProgressLogModel({
    required String id,
    required String scheduleId,
    required DateTime date,
    required String activity,
    String? notes,
  }) : super(
          id: id,
          scheduleId: scheduleId,
          date: date,
          activity: activity,
          notes: notes,
        );

  factory CropProgressLogModel.fromJson(Map<String, dynamic> json) {
    return CropProgressLogModel(
      id: json['id'],
      scheduleId: json['schedule_id'],
      date: DateTime.parse(json['date']),
      activity: json['activity'],
      notes: json['notes'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'schedule_id': scheduleId,
      'date': date.toIso8601String(),
      'activity': activity,
      'notes': notes,
    };
  }

  factory CropProgressLogModel.fromEntity(CropProgressLog entity) {
    return CropProgressLogModel(
      id: entity.id,
      scheduleId: entity.scheduleId,
      date: entity.date,
      activity: entity.activity,
      notes: entity.notes,
    );
  }
} 