FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

  1. import { Metadata } from "next";
  2. import { getServerI18n, I18nProvider } from "@/i18n";
  3. // import { getServerI18n, I18nProvider } from "../../../../../i18n";
  4. import Typography from "@mui/material/Typography";
  5. import { isArray, parseInt } from "lodash";
  6. import { notFound } from "next/navigation";
  7. import { SearchParams, ServerFetchError } from "@/app/utils/fetchUtil";
  8. import DetailedScheduleDetail from "@/components/DetailedScheduleDetail";
  9. import { type } from "os";
  10. import { fetchDetailedProdScheduleDetail } from "@/app/api/scheduling";
  11. import { Suspense } from "react";
  12. // import { ServerFetchError } from "../../../../../app/utils/fetchUtil";
  13. // import DetailedScheduleDetail from "../../../../../components/DetailedScheduleDetail";
  14. export const metadata: Metadata = {
  15. title: "FG Production Schedule",
  16. };
  17. // interface Props {
  18. // searchParams: { [key: string]: string | string[] | undefined };
  19. // }
  20. type Props = SearchParams;
  21. const DetailScheduling: React.FC<Props> = async ({ searchParams }) => {
  22. const { t } = await getServerI18n("schedule");
  23. const id = searchParams["id"];
  24. const type = "detailed"
  25. if (!id || isArray(id) || !isFinite(parseInt(id))) {
  26. notFound();
  27. }
  28. try {
  29. await fetchDetailedProdScheduleDetail(parseInt(id))
  30. } catch (e) {
  31. if (e instanceof ServerFetchError && (e.response?.status === 404 || e.response?.status === 400)) {
  32. console.log(e)
  33. notFound();
  34. }
  35. }
  36. return (
  37. <>
  38. <Typography variant="h4" marginInlineEnd={2}>
  39. {t("FG Production Schedule")}
  40. </Typography>
  41. <I18nProvider namespaces={["schedule", "common"]}>
  42. <Suspense fallback={<DetailedScheduleDetail.Loading />}>
  43. <DetailedScheduleDetail type={type} id={parseInt(id)} />
  44. </Suspense>
  45. </I18nProvider>
  46. </>
  47. );
  48. };
  49. export default DetailScheduling;