import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/controllers/providers/api/status_drop_down/employee/nurse_provider.dart';
import 'package:test_sa/models/employee.dart';
import 'package:test_sa/models/new_models/assistant_employee.dart';
import 'package:test_sa/models/service_request/search_work_order.dart';
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
import 'package:test_sa/views/widgets/status/assistant_employee_menu.dart';
import 'package:test_sa/views/widgets/status/nurse_employee_menu.dart';

import '../../../../controllers/providers/api/status_drop_down/report/service_report_assistants_employee_provider.dart';

class NurseMenu extends StatelessWidget {
  final Function(Employee) onSelect;
  final Employee initialValue;

  final String title;
  final bool enable;

  const NurseMenu({Key key, @required this.onSelect, this.title, this.initialValue, this.enable = true}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    NurseProvider menuProvider = Provider.of<NurseProvider>(context);
    return LoadingManager(
      isLoading: menuProvider.isLoading,
      isFailedLoading: menuProvider.nursesList == null,
      stateCode: menuProvider.stateCode,
      onRefresh: () async {
        await menuProvider.getData();
        // menuProvider.setStateCode = null;
      },
      child: NurseEmployeeMenu(
        initialValue: initialValue,
        title: title,
        list: menuProvider.nursesList,
        onSelect: (employee) {
          onSelect(employee);
        },
        enable: enable,
      ),
    );
  }
}
