import React from "react";
import { SearchParams } from "@/app/utils/fetchUtil";
import { I18nProvider, getServerI18n } from "@/i18n";
import { Typography } from "@mui/material";
import isString from "lodash/isString";
import { notFound } from "next/navigation";
import UpdateMaintenanceForm from "@/components/UpdateMaintenance/UpdateMaintenanceForm";

type Props = {} & SearchParams;

const MaintenanceEditPage: React.FC<Props> = async ({ searchParams }) => {
  const type = "importBom";
  const { t } = await getServerI18n(type, "navigation", "common");
  const id = isString(searchParams["id"])
    ? parseInt(searchParams["id"])
    : undefined;
  if (!id) {
    notFound();
  }
  return (
    <>
      <Typography variant="h4">{t("Update Equipment Maintenance and Repair")}</Typography>
      <I18nProvider namespaces={[type, "navigation", "common"]}>
        <UpdateMaintenanceForm id={id} />
      </I18nProvider>
    </>
  );
};
export default MaintenanceEditPage;
