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

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

  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 = "";
    assetName?.controller?.text = "";
    assetNo?.controller?.text = "";
    manufacture?.controller?.text = "";
    sn?.controller?.text = "";
    model?.controller?.text = "";
    isArchived = false;
  }
}

abstract class SearchAllRequestsBaseModel {
  String? label; // Now nullable
  String? value; // Now nullable
  BuildContext? context; // Now nullable
  TextInputType inputType;
  TextEditingController? controller; // Now nullable

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

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

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

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

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

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

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