FPSMS-frontend
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

72 lignes
2.2 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 { fetchProdScheduleDetail } 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 fetchProdScheduleDetail(parseInt(id))
  29. } catch(e) {
  30. if (e instanceof ServerFetchError && (e.response?.status === 404 || e.response?.status === 400)) {
  31. console.log(e)
  32. notFound();
  33. }
  34. }
  35. // preloadClaims();
  36. return (
  37. <>
  38. <Stack
  39. direction="row"
  40. justifyContent="space-between"
  41. flexWrap="wrap"
  42. rowGap={2}
  43. >
  44. <Typography variant="h4" marginInlineEnd={2}>
  45. {t("FG & Material Demand Forecast Detail")}
  46. </Typography>
  47. {/* <Button
  48. variant="contained"
  49. startIcon={<Add />}
  50. LinkComponent={Link}
  51. href="product/create"
  52. >
  53. {t("Create product")}
  54. </Button> */}
  55. </Stack>
  56. <I18nProvider namespaces={["schedule","common"]}>
  57. <Suspense fallback={<RoughScheduleDetailView.Loading />}>
  58. <RoughScheduleDetailView type={type} id={parseInt(id)}/>
  59. </Suspense>
  60. </I18nProvider>
  61. </>
  62. );
  63. };
  64. export default roughSchedulingDetail;