import 'package:rasadyar_app/presentation/routes/app_pages.dart';
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_inspection/injection/inspection_di.dart';
import 'package:rasadyar_inspection/inspection.dart';
import 'package:rasadyar_livestock/injection/live_stock_di.dart';
import 'package:rasadyar_livestock/presentation/routes/app_pages.dart';

Future<void> seedTargetPage() async {
  var box = Hive.box<AppModel>("appBox");
  AppModel appModel = AppModel(
    targetPages: [
      TargetPage(
        route: InspectionRoutes.init,
        module: Module.inspection,
        functions: ["setupInspectionDI"],
      ),
      TargetPage(
        route: LiveStockRoutes.init,
        module: Module.liveStocks,
        functions: ["setupLiveStockDI"],
      ),
      TargetPage(
        route: ChickenRoutes.initSteward,
        module: Module.chicken,
        functions: ["setupChickenDI"],
      ),
      TargetPage(route: AppPaths.moduleList),
    ],
  );

  box.add(appModel);
}

Iterable<Future>? getFunctionsList(List<String>? functions) {
  return functions?.map((e) async => getFunctionByName(e));
}

Future? getFunctionByName(String? name) {
  switch (name) {
    case "setupInspectionDI":
      return setupInspectionDI();
    case "setupLiveStockDI":
      return setupLiveStockDI();
    case "setupChickenDI":
      return setupChickenDI();
    default:
      return null;
  }
}
