import 'package:flutter/cupertino.dart';
import 'package:test_sa/extensions/context_extension.dart';

class SearchAllRequestsModel {
  SearchByRequestNumberModel requestNumber;
  SearchByAssetNameModel assetName;
  SearchByAssetNoModel assetNo;
  SearchByManufactureModel manufacture;
  SearchBySNModel sn;
  SearchByRequestModel model;
  SearchAllRequestsBaseModel searchBySelectedValue;
  List<int> statuses;
  List<int> typeTransaction;
  DateTime startDate, endDate;
  bool isArchived;

  SearchAllRequestsModel({
    this.requestNumber,
    this.assetName,
    this.assetNo,
    this.manufacture,
    this.sn,
    this.model,
    this.statuses,
    this.typeTransaction,
    this.startDate,
    this.endDate,
    this.isArchived = false,
  });

  void resetSearchValues() {
    requestNumber?.controller?.text = "";
    requestNumber?.value = "";
    assetName?.controller?.text = "";
    assetNo?.controller?.text = "";
    manufacture?.controller?.text = "";
    sn?.controller?.text = "";
    model?.controller?.text = "";
    isArchived = false;
  }
}

abstract class SearchAllRequestsBaseModel {
  String label;
  String value;
  BuildContext context;
  TextInputType inputType;
  TextEditingController controller;

  SearchAllRequestsBaseModel(this.context, {this.controller, this.label, this.value, this.inputType = TextInputType.text});
}

class SearchByRequestNumberModel extends SearchAllRequestsBaseModel {
  SearchByRequestNumberModel(BuildContext context, {TextEditingController controller, String value}) : super(context, controller: controller, label: "${context.translation.requestNo}.", value: value);
}

class SearchByAssetNameModel extends SearchAllRequestsBaseModel {
  SearchByAssetNameModel(BuildContext context, {TextEditingController controller, String value}) : super(context, controller: controller, label: context.translation.assetName, value: value);
}

class SearchByAssetNoModel extends SearchAllRequestsBaseModel {
  SearchByAssetNoModel(BuildContext context, {TextEditingController controller, String value}) : super(context, controller: controller, label: context.translation.assetNo, value: value);
}

class SearchByManufactureModel extends SearchAllRequestsBaseModel {
  SearchByManufactureModel(BuildContext context, {TextEditingController controller, String value}) : super(context, controller: controller, label: context.translation.manufacture, value: value);
}

class SearchBySNModel extends SearchAllRequestsBaseModel {
  SearchBySNModel(BuildContext context, {TextEditingController controller, String value}) : super(context, controller: controller, label: context.translation.sn, value: value);
}

class SearchByRequestModel extends SearchAllRequestsBaseModel {
  SearchByRequestModel(BuildContext context, {TextEditingController controller, String value}) : super(context, controller: controller, label: context.translation.model, value: value);
}
