// "use client";
import { Edit } from "@mui/icons-material";
import { useSearchParams } from "next/navigation";
import EditStaff from "@/components/EditStaff";
import { Suspense } from "react";
import { I18nProvider } from "@/i18n";
import EditStaffWrapper from "@/components/EditStaff/EditStaffWrapper";
import { Metadata } from "next";
import { searchParamsProps } from "@/app/utils/fetchUtil";
import { fetchIndivStaff, fetchStaffInvolvedProjects, fetchStaffSalaryEffectiveInfo } from "@/app/api/staff";
import { fetchCompanyCombo } from "@/app/api/companys/actions";
import { fetchTeamCombo } from "@/app/api/team";
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";

// export const metadata: Metadata = {
//     title: "staff-edit",
//   };

const EditStaffPage: React.FC<searchParamsProps> = async ({
    searchParams,
  }) => {
  
  // preload 
  fetchIndivStaff(parseInt(searchParams.id as string)),
  fetchCompanyCombo(),
  fetchTeamCombo(),
  fetchDepartmentCombo(),
  fetchPositionCombo(),
  fetchGradeCombo(),
  fetchSkillCombo(),
  fetchSalaryCombo(),
  fetchStaffSalaryEffectiveInfo(parseInt(searchParams.id as string)),
  fetchStaffInvolvedProjects(parseInt(searchParams.id as string))

  return (
    <>
      <I18nProvider namespaces={["staff", "common"]}>
        <Suspense fallback={<EditStaff.Loading />}>
          <EditStaff id={parseInt(searchParams.id as string)}/>
        </Suspense>
      </I18nProvider>
      {/* <EditStaff /> */}
    </>
  );
};

export default EditStaffPage;
