FPSMS-frontend
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

50 linhas
1.4 KiB

  1. import { fetchJoDetail } from "@/app/api/jo";
  2. import { SearchParams, ServerFetchError } from "@/app/utils/fetchUtil";
  3. import JoSave from "@/components/JoSave/JoSave";
  4. import PageTitleBar from "@/components/PageTitleBar";
  5. import { I18nProvider, getServerI18n } from "@/i18n";
  6. import { isArray } from "lodash";
  7. import { Metadata } from "next";
  8. import { notFound } from "next/navigation";
  9. import { Suspense } from "react";
  10. import GeneralLoading from "@/components/General/GeneralLoading";
  11. export const metadata: Metadata = {
  12. title: "Edit Job Order Detail",
  13. };
  14. type Props = SearchParams;
  15. const JodetailEdit: React.FC<Props> = async ({ searchParams }) => {
  16. const { t } = await getServerI18n("jo");
  17. const id = searchParams["id"];
  18. if (!id || isArray(id) || !isFinite(parseInt(id))) {
  19. notFound();
  20. }
  21. try {
  22. await fetchJoDetail(parseInt(id));
  23. } catch (e) {
  24. if (
  25. e instanceof ServerFetchError &&
  26. (e.response?.status === 404 || e.response?.status === 400)
  27. ) {
  28. console.log(e);
  29. notFound();
  30. }
  31. }
  32. return (
  33. <>
  34. <PageTitleBar title={t("Edit Job Order Detail")} className="mb-4" />
  35. <I18nProvider namespaces={["jo", "common"]}>
  36. <Suspense fallback={<GeneralLoading />}>
  37. <JoSave id={parseInt(id)} defaultValues={undefined} />
  38. </Suspense>
  39. </I18nProvider>
  40. </>
  41. );
  42. };
  43. export default JodetailEdit;