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.

page.tsx 1.4 KiB

hace 10 meses
hace 10 meses
hace 10 meses
hace 10 meses
hace 10 meses
hace 10 meses
hace 10 meses
hace 10 meses
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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","navigation","common"]}>
  36. <Suspense fallback={<GeneralLoading />}>
  37. <JoSave id={parseInt(id)} defaultValues={undefined} />
  38. </Suspense>
  39. </I18nProvider>
  40. </>
  41. );
  42. };
  43. export default JodetailEdit;