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.
 
 

54 lines
1.3 KiB

  1. import { Metadata } from "next";
  2. import { getServerI18n, I18nProvider } from "@/i18n";
  3. import Typography from "@mui/material/Typography";
  4. import { fetchQcItemDetails, preloadQcItem } from "@/app/api/settings/qcItem";
  5. import QcItemSave from "@/components/QcItemSave";
  6. import { isArray } from "lodash";
  7. import { notFound } from "next/navigation";
  8. import { ServerFetchError } from "@/app/utils/fetchUtil";
  9. export const metadata: Metadata = {
  10. title: "Qc Item",
  11. };
  12. interface Props {
  13. searchParams: { [key: string]: string | string[] | undefined };
  14. }
  15. const qcItem: React.FC<Props> = async ({ searchParams }) => {
  16. const { t } = await getServerI18n("qcItem");
  17. const id = searchParams["id"];
  18. if (!id || isArray(id)) {
  19. notFound();
  20. }
  21. try {
  22. console.log("first");
  23. await fetchQcItemDetails(id);
  24. console.log("firsts");
  25. } catch (e) {
  26. if (
  27. e instanceof ServerFetchError &&
  28. (e.response?.status === 404 || e.response?.status === 400)
  29. ) {
  30. console.log(e);
  31. notFound();
  32. }
  33. }
  34. return (
  35. <>
  36. <Typography variant="h4" marginInlineEnd={2}>
  37. {t("Edit Qc Item")}
  38. </Typography>
  39. <I18nProvider namespaces={["qcItem"]}>
  40. <QcItemSave id={id} />
  41. </I18nProvider>
  42. </>
  43. );
  44. };
  45. export default qcItem;