import React from "react";
import CreateStaff, { comboItem } from "./CreateStaff";
import CreateStaffLoading from "./CreateStaffLoading";
import { fetchStaff, fetchTeamLeads } from "@/app/api/staff";
import { useSearchParams } from "next/navigation";
import { fetchTeamCombo } from "@/app/api/team/actions";
import { fetchDepartmentCombo } from "@/app/api/departments/actions";
import { fetchPositionCombo } from "@/app/api/positions/actions";
import { fetchGradeCombo } from "@/app/api/grades/actions";
import { fetchSkillCombo } from "@/app/api/skill/actions";
import { fetchSalaryCombo } from "@/app/api/salarys/actions";
import { fetchCompanyCombo } from "@/app/api/companys/actions";
interface SubComponents {
  Loading: typeof CreateStaffLoading;
} 

const CreateStaffWrapper: React.FC & SubComponents = async () => {
  const [
    CompanyCombo,
    TeamCombo,
    DepartmentCombo,
    PositionCombo,
    GradeCombo,
    SkillCombo,
    SalaryCombo,
  ] = await Promise.all([
    fetchCompanyCombo(),
    fetchTeamCombo(),
    fetchDepartmentCombo(),
    fetchPositionCombo(),
    fetchGradeCombo(),
    fetchSkillCombo(),
    fetchSalaryCombo(),
  ]);
  const combos: comboItem = {
    company: CompanyCombo.records,
    team: TeamCombo.records,
    department: DepartmentCombo.records,
    position: PositionCombo.records,
    grade: GradeCombo.records,
    skill: SkillCombo.records,
    salary: SalaryCombo.records,
  } 

  return <CreateStaff combos={combos}/>;
};

CreateStaffWrapper.Loading = CreateStaffLoading;

export default CreateStaffWrapper;
