import 'package:equatable/equatable.dart';

class Field extends Equatable {
  final String id;
  final String? userId;
  final String name;
  final int plotCount;
  final String? region;
  final String? location; // Lokasi dalam bentuk teks (alamat)
  final double? latitude; // Koordinat latitude
  final double? longitude; // Koordinat longitude
  final double? areaSize;
  final String? areaUnit;
  final String? ownershipType;
  final String? ownerName;
  final Map<String, dynamic>? regionSpecificData;
  final DateTime? createdAt;
  final DateTime? updatedAt;

  const Field({
    required this.id,
    this.userId,
    required this.name,
    required this.plotCount,
    this.region,
    this.location,
    this.latitude,
    this.longitude,
    this.areaSize,
    this.areaUnit = 'm²',
    this.ownershipType = 'Milik Sendiri',
    this.ownerName,
    this.regionSpecificData,
    this.createdAt,
    this.updatedAt,
  });

  @override
  List<Object?> get props => [
    id,
        userId,
    name,
    plotCount,
    region,
    location,
        latitude,
        longitude,
    areaSize,
    areaUnit,
    ownershipType,
    ownerName,
    regionSpecificData,
    createdAt,
    updatedAt,
  ];

  Field copyWith({
    String? id,
    String? userId,
    String? name,
    int? plotCount,
    String? region,
    String? location,
    double? latitude,
    double? longitude,
    double? areaSize,
    String? areaUnit,
    String? ownershipType,
    String? ownerName,
    Map<String, dynamic>? regionSpecificData,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return Field(
      id: id ?? this.id,
      userId: userId ?? this.userId,
      name: name ?? this.name,
      plotCount: plotCount ?? this.plotCount,
      region: region ?? this.region,
      location: location ?? this.location,
      latitude: latitude ?? this.latitude,
      longitude: longitude ?? this.longitude,
      areaSize: areaSize ?? this.areaSize,
      areaUnit: areaUnit ?? this.areaUnit,
      ownershipType: ownershipType ?? this.ownershipType,
      ownerName: ownerName ?? this.ownerName,
      regionSpecificData: regionSpecificData ?? this.regionSpecificData,
      createdAt: createdAt ?? this.createdAt,
      updatedAt: updatedAt ?? this.updatedAt,
    );
  }
}
