// "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";
import { fetchGradesLog, fetchPositionLog, fetchTeamLog } from "@/app/api/staffInfoHistory";

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

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

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

export default EditStaffPage;
