import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/form_detail_entity.dart';
import 'package:domain/entity/form_content_entity.dart';


FormDetailEntity $FormDetailEntityFromJson(Map<String, dynamic> json) {
  final FormDetailEntity formDetailEntity = FormDetailEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    formDetailEntity.id = id;
  }
  final String? userId = jsonConvert.convert<String>(json['user_id']);
  if (userId != null) {
    formDetailEntity.userId = userId;
  }
  final FormContentEntity? content = jsonConvert.convert<FormContentEntity>(json['content']);
  if (content != null) {
    formDetailEntity.content = content;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    formDetailEntity.status = status;
  }
  final String? sentOn = jsonConvert.convert<String>(json['sent_on']);
  if (sentOn != null) {
    formDetailEntity.sentOn = sentOn;
  }
  final String? rejectedOn = jsonConvert.convert<String>(json['rejected_on']);
  if (rejectedOn != null) {
    formDetailEntity.rejectedOn = rejectedOn;
  }
  final String? approvedOn = jsonConvert.convert<String>(json['approved_on']);
  if (approvedOn != null) {
    formDetailEntity.approvedOn = approvedOn;
  }
  final FormOrder? order = jsonConvert.convert<FormOrder>(json['order']);
  if (order != null) {
    formDetailEntity.order = order;
  }
  return formDetailEntity;
}

Map<String, dynamic> $FormDetailEntityToJson(FormDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['user_id'] = entity.userId;
  data['content'] = entity.content?.toJson();
  data['status'] = entity.status;
  data['sent_on'] = entity.sentOn;
  data['rejected_on'] = entity.rejectedOn;
  data['approved_on'] = entity.approvedOn;
  data['order'] = entity.order?.toJson();
  return data;
}

extension FormDetailEntityExtension on FormDetailEntity {
  FormDetailEntity copyWith({
    String? id,
    String? userId,
    FormContentEntity? content,
    int? status,
    String? sentOn,
    String? rejectedOn,
    String? approvedOn,
    FormOrder? order,
  }) {
    return FormDetailEntity()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..content = content ?? this.content
      ..status = status ?? this.status
      ..sentOn = sentOn ?? this.sentOn
      ..rejectedOn = rejectedOn ?? this.rejectedOn
      ..approvedOn = approvedOn ?? this.approvedOn
      ..order = order ?? this.order;
  }
}

FormOrder $FormOrderFromJson(Map<String, dynamic> json) {
  final FormOrder formOrder = FormOrder();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    formOrder.id = id;
  }
  final String? totalAmount = jsonConvert.convert<String>(json['total_amount']);
  if (totalAmount != null) {
    formOrder.totalAmount = totalAmount;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['order_amount']);
  if (orderAmount != null) {
    formOrder.orderAmount = orderAmount;
  }
  final String? depositAmount = jsonConvert.convert<String>(json['deposit_amount']);
  if (depositAmount != null) {
    formOrder.depositAmount = depositAmount;
  }
  final int? paymentStatus = jsonConvert.convert<int>(json['payment_status']);
  if (paymentStatus != null) {
    formOrder.paymentStatus = paymentStatus;
  }
  final int? refundStatus = jsonConvert.convert<int>(json['refund_status']);
  if (refundStatus != null) {
    formOrder.refundStatus = refundStatus;
  }
  return formOrder;
}

Map<String, dynamic> $FormOrderToJson(FormOrder entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['total_amount'] = entity.totalAmount;
  data['order_amount'] = entity.orderAmount;
  data['deposit_amount'] = entity.depositAmount;
  data['payment_status'] = entity.paymentStatus;
  data['refund_status'] = entity.refundStatus;
  return data;
}

extension FormOrderExtension on FormOrder {
  FormOrder copyWith({
    String? id,
    String? totalAmount,
    String? orderAmount,
    String? depositAmount,
    int? paymentStatus,
    int? refundStatus,
  }) {
    return FormOrder()
      ..id = id ?? this.id
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderAmount = orderAmount ?? this.orderAmount
      ..depositAmount = depositAmount ?? this.depositAmount
      ..paymentStatus = paymentStatus ?? this.paymentStatus
      ..refundStatus = refundStatus ?? this.refundStatus;
  }
}