FPSMS-frontend
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

75 líneas
2.1 KiB

  1. import { TypeEnum } from "@/app/utils/typeEnum";
  2. import RoughSchedule from "@/components/RoughSchedule";
  3. import { getServerI18n, I18nProvider } from "@/i18n";
  4. import Add from "@mui/icons-material/Add";
  5. import Button from "@mui/material/Button";
  6. import Stack from "@mui/material/Stack";
  7. import Typography from "@mui/material/Typography";
  8. import { Metadata } from "next";
  9. import Link from "next/link";
  10. import { Suspense } from "react";
  11. import RoughScheduleDetailView from "@/components/RoughScheduleDetail";
  12. import { SearchParams, ServerFetchError } from "@/app/utils/fetchUtil";
  13. import { isArray, parseInt } from "lodash";
  14. import { notFound } from "next/navigation";
  15. import { fetchRoughProdScheduleDetail } from "@/app/api/scheduling";
  16. export const metadata: Metadata = {
  17. title: "Demand Forecast Detail",
  18. };
  19. type Props = SearchParams;
  20. const roughSchedulingDetail: React.FC<Props> = async ({ searchParams }) => {
  21. const { t } = await getServerI18n("schedule");
  22. const id = searchParams["id"];
  23. const type = "rough";
  24. if (!id || isArray(id) || !isFinite(parseInt(id))) {
  25. notFound();
  26. }
  27. try {
  28. await fetchRoughProdScheduleDetail(parseInt(id));
  29. } catch (e) {
  30. if (
  31. e instanceof ServerFetchError &&
  32. (e.response?.status === 404 || e.response?.status === 400)
  33. ) {
  34. console.log(e);
  35. notFound();
  36. }
  37. }
  38. // preloadClaims();
  39. return (
  40. <>
  41. <Stack
  42. direction="row"
  43. justifyContent="space-between"
  44. flexWrap="wrap"
  45. rowGap={2}
  46. >
  47. <Typography variant="h4" marginInlineEnd={2}>
  48. {t("FG & Material Demand Forecast Detail")}
  49. </Typography>
  50. {/* <Button
  51. variant="contained"
  52. startIcon={<Add />}
  53. LinkComponent={Link}
  54. href="product/create"
  55. >
  56. {t("Create product")}
  57. </Button> */}
  58. </Stack>
  59. <I18nProvider namespaces={["schedule","navigation","common"]}>
  60. <Suspense fallback={<RoughScheduleDetailView.Loading />}>
  61. <RoughScheduleDetailView type={type} id={parseInt(id)} />
  62. </Suspense>
  63. </I18nProvider>
  64. </>
  65. );
  66. };
  67. export default roughSchedulingDetail;