import React from "react";
import SubsidiarySearch from "./SubsidiarySearch";
import SubsidiarySearchLoading from "./SubsidiarySearchLoading";
import { fetchAllSubsidiaries } from "@/app/api/subsidiary";
import { fetchUserAbilities } from "@/app/utils/fetchUtil";

interface SubComponents {
  Loading: typeof SubsidiarySearchLoading;
}

const SubsidiarySearchWrapper: React.FC & SubComponents = async () => {
  const [subsidiaries, abilities] = await Promise.all([fetchAllSubsidiaries(), fetchUserAbilities()]);

  return <SubsidiarySearch subsidiaries={subsidiaries} abilities={abilities} />;
};

SubsidiarySearchWrapper.Loading = SubsidiarySearchLoading;

export default SubsidiarySearchWrapper;