///todo deleted
// import 'package:flutter/material.dart';
// import 'package:provider/provider.dart';
// import 'package:test_sa/controllers/providers/api/service_requests_provider.dart';
// import 'package:test_sa/extensions/context_extension.dart';
// import 'package:test_sa/models/employee.dart';
// import 'package:test_sa/models/lookup.dart';
// import 'package:test_sa/models/service_request/search_work_order.dart';
// import 'package:test_sa/views/pages/sub_workorder/workorder_list.dart';
// import 'package:test_sa/views/widgets/app_text_form_field.dart';
// import 'package:test_sa/views/widgets/date_and_time/date_picker.dart';
// import 'package:test_sa/views/widgets/hospitals/hospital_auto_complete_field_new.dart';
//
// import '../../../controllers/api_routes/http_status_manger.dart';
// import '../../../controllers/providers/api/status_drop_down/report/service_report_maintenance_situation_provider.dart';
// import '../../../models/new_models/assigned_employee.dart';
// import '../../widgets/buttons/app_back_button.dart';
// import '../../widgets/buttons/app_button.dart';
// import '../../widgets/status/report/service_report_all_users.dart';
// import '../../widgets/status/report/service_report_maintenance_situation.dart';
// import '../../widgets/status/report/service_report_visit_date_operator.dart';
// import '../../widgets/titles/app_sub_title.dart';
//  todo remove this class after work
// class SearchSubWorkOrderPage extends StatefulWidget {
//   static String id = "/SubWorkOrderPage";
//
//   const SearchSubWorkOrderPage({Key? key}) : super(key: key);
//
//   @override
//   State<SearchSubWorkOrderPage> createState() => _SearchSubWorkOrderPageState();
// }
//
// class _SearchSubWorkOrderPageState extends State<SearchSubWorkOrderPage> {
//   final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
//   final SearchWorkOrder _searchWorkOrders = SearchWorkOrder();
//
//   bool _isLoading = false;
//   String _callerId = "", _site = "";
//   Lookup _dateOperator;
//
//   @override
//   void initState() {
//     super.initState();
//     if (context.mounted) {
//       Provider.of<ServiceReportMaintenanceSituationProvider>(context, listen: false).reset();
//     }
//   }
//
//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       body: SafeArea(
//         child: SingleChildScrollView(
//           child: Column(
//             children: [
//               Container(
//                 // color: AColors.primaryColor,
//                 padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 4),
//                 child: Column(
//                   children: [
//                     Row(
//                       children: [
//                         const ABackButton(),
//                         Expanded(
//                           child: Center(
//                             child: Text(
//                               "Search Work Order",
//                               // style: Theme.of(context).textTheme.titleLarge.copyWith(color: AColors.white, fontStyle: FontStyle.italic),
//                             ),
//                           ),
//                         ),
//                         const SizedBox(
//                           width: 48,
//                         )
//                       ],
//                     ),
//                   ],
//                 ),
//               ),
//               const SizedBox(height: 8),
//               Form(
//                 key: _formKey,
//                 child: Padding(
//                   padding: const EdgeInsets.all(16.0),
//                   child: Column(
//                     crossAxisAlignment: CrossAxisAlignment.start,
//                     children: [
//                       ATextFormField(
//                         labelText: "Call ID",
//                         onSaved: (value) {
//                           _callerId = value;
//                         },
//                       ),
//                       const SizedBox(height: 16),
//                       ATextFormField(
//                         labelText: "Asset S.N.",
//                         textInputType: TextInputType.number,
//                         onSaved: (value) {
//                           if (value != null) {
//                             _searchWorkOrders.assetType = Lookup(name: value);
//                           }
//                         },
//                       ),
//                       const SizedBox(height: 16),
//                       ATextFormField(
//                         labelText: "Work Order No.",
//                         onSaved: (value) {
//                           _searchWorkOrders.workOrderNo = value;
//                         },
//                       ),
//                       const SizedBox(height: 16),
//                       ASubTitle(context.translation.assignedEmployee),
//                       const SizedBox(height: 4),
//                       ServiceReportAllUsers(
//                         initialValue: _searchWorkOrders.assignedEmployee == null ? null : Employee(id: _searchWorkOrders.assignedEmployee.id, name: _searchWorkOrders.assignedEmployee.name),
//                         onSelect: (engineer) {
//                           _searchWorkOrders.assignedEmployee = AssignedEmployee(id: engineer.id, name: engineer.name);
//                         },
//                       ),
//                       const SizedBox(height: 16),
//                       const ASubTitle("Maintenance Situation"),
//                       const SizedBox(height: 4),
//                       ServiceReportMaintenanceSituation(
//                         initialValue: _searchWorkOrders.calllastSituation,
//                         onSelect: (status) {
//                           if (status?.value == 12 || _searchWorkOrders.calllastSituation?.value == 12) {
//                             _searchWorkOrders.calllastSituation = status;
//                             setState(() {});
//                           } else {
//                             _searchWorkOrders.calllastSituation = status;
//                           }
//                         },
//                         woId: _searchWorkOrders.id?.toString(),
//                       ),
//                       const SizedBox(height: 16),
//                       HospitalAutoCompleteField(
//                         initialValue: _site,
//                         onSearch: (value) {
//                           _site = value.name;
//                           setState(() {});
//                         },
//                       ),
//                       const SizedBox(height: 16),
//                       ASubTitle(context.translation.visitDate),
//                       const SizedBox(height: 4),
//                       ServiceReportVisitDateOperator(
//                         initialValue: _dateOperator,
//                         onSelect: (status) {
//                           _dateOperator = status;
//                         },
//                       ),
//                       Row(
//                         children: [
//                           Expanded(
//                             child: ADatePicker(
//                               date: DateTime.tryParse(_searchWorkOrders.visitDate ?? ""),
//                               from: DateTime(1950),
//                               onDatePicker: (date) {
//                                 _searchWorkOrders.visitDate = date?.toIso8601String();
//                                 setState(() {});
//                               },
//                             ),
//                           ),
//                         ],
//                       ),
//                     ],
//                   ),
//                 ),
//               ),
//               const SizedBox(height: 100),
//             ],
//           ),
//         ),
//       ),
//       floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
//       floatingActionButton: _isLoading
//           ? const CircularProgressIndicator()
//           : Padding(
//               padding: const EdgeInsets.symmetric(horizontal: 16),
//               child: AButton(
//                 text: context.translation.search,
//                 onPressed: () async {
//                   _isLoading = true;
//                   setState(() {});
//                   if (_formKey.currentState?.validate() ?? false) {}
//                   _formKey.currentState?.save();
//                   final serviceRequestsProvider = Provider.of<ServiceRequestsProvider>(context, listen: false);
//                   serviceRequestsProvider.reset();
//                   final List<SearchWorkOrder> woList = await serviceRequestsProvider.searchForWorkOrders(
//                     _searchWorkOrders,
//                     _callerId,
//                     _dateOperator,
//                     _site,
//                   );
//                   _isLoading = false;
//                   setState(() {});
//                   if (serviceRequestsProvider.stateCode >= 200 && serviceRequestsProvider.stateCode < 300) {
//                     Navigator.push(
//                       context,
//                       MaterialPageRoute(
//                         builder: (context) => WorkOrderList(
//                           items: woList,
//                           onLazyLoading: () async {
//                             return await serviceRequestsProvider.searchForWorkOrders(
//                               _searchWorkOrders,
//                               _callerId,
//                               _dateOperator,
//                               _site,
//                             );
//                           },
//                         ),
//                       ),
//                     );
//                   } else {
//                     String errorMessage = HttpStatusManger.getStatusMessage(status: serviceRequestsProvider.stateCode, subtitle: context.translation);
//                     ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(errorMessage)));
//                   }
//                 },
//               ),
//             ),
//     );
//   }
// }
