|
- import { Metadata } from "next";
- import { getServerI18n, I18nProvider } from "@/i18n";
- // import { getServerI18n, I18nProvider } from "../../../../../i18n";
- import Typography from "@mui/material/Typography";
- import { isArray, parseInt } from "lodash";
- import { notFound } from "next/navigation";
- import { SearchParams, ServerFetchError } from "@/app/utils/fetchUtil";
- import DetailedScheduleDetail from "@/components/DetailedScheduleDetail";
- import { type } from "os";
- import { fetchDetailedProdScheduleDetail } from "@/app/api/scheduling";
- import { Suspense } from "react";
- // import { ServerFetchError } from "../../../../../app/utils/fetchUtil";
- // import DetailedScheduleDetail from "../../../../../components/DetailedScheduleDetail";
-
- export const metadata: Metadata = {
- title: "FG Production Schedule",
- };
-
- // interface Props {
- // searchParams: { [key: string]: string | string[] | undefined };
- // }
-
- type Props = SearchParams;
-
- const DetailScheduling: React.FC<Props> = async ({ searchParams }) => {
- const { t } = await getServerI18n("schedule");
- const id = searchParams["id"];
- const type = "detailed"
-
- if (!id || isArray(id) || !isFinite(parseInt(id))) {
- notFound();
- }
-
- try {
- await fetchDetailedProdScheduleDetail(parseInt(id))
- } catch (e) {
- if (e instanceof ServerFetchError && (e.response?.status === 404 || e.response?.status === 400)) {
- console.log(e)
- notFound();
- }
- }
-
- return (
- <>
- <Typography variant="h4" marginInlineEnd={2}>
- {t("FG Production Schedule")}
- </Typography>
- <I18nProvider namespaces={["schedule", "common"]}>
- <Suspense fallback={<DetailedScheduleDetail.Loading />}>
- <DetailedScheduleDetail type={type} id={parseInt(id)} />
- </Suspense>
- </I18nProvider>
- </>
- );
- };
-
- export default DetailScheduling;
|