diff --git a/app/location/[id]/edit/LocationEditPage.tsx b/app/location/[id]/edit/LocationEditPage.tsx new file mode 100644 index 0000000..50d0b31 --- /dev/null +++ b/app/location/[id]/edit/LocationEditPage.tsx @@ -0,0 +1,16 @@ +import { notFound } from 'next/navigation'; +import { LocationEditForm } from '@/app/ui/LocationEditForm'; +import { fetchLocationById } from '@/app/lib/actions/locationActions'; + +export default async function LocationEditPage({ locationId }: { locationId:string }) { + + const location = await fetchLocationById(locationId); + + if (!location) { + return(notFound()); + } + + const result = ; + + return (result); +} \ No newline at end of file diff --git a/app/location/[id]/edit/page.tsx b/app/location/[id]/edit/page.tsx index b28cd30..251f944 100644 --- a/app/location/[id]/edit/page.tsx +++ b/app/location/[id]/edit/page.tsx @@ -1,13 +1,15 @@ -import { notFound } from 'next/navigation'; -import { LocationEditForm } from '@/app/ui/LocationEditForm'; -import { fetchLocationById } from '@/app/lib/actions/locationActions'; +import { Suspense } from 'react'; +import LocationEditPage from './LocationEditPage'; +import { Main } from '@/app/ui/Main'; +import { LocationEditFormSkeleton } from '@/app/ui/LocationEditForm'; export default async function Page({ params:{ id } }: { params: { id:string } }) { - const location = await fetchLocationById(id); - - if (!location) { - return(notFound()); - } - return (); + return ( + + }> + + + + ); } \ No newline at end of file diff --git a/app/ui/LocationEditForm.tsx b/app/ui/LocationEditForm.tsx index 97b5c49..387dca0 100644 --- a/app/ui/LocationEditForm.tsx +++ b/app/ui/LocationEditForm.tsx @@ -5,7 +5,6 @@ import { FC } from "react"; import { BillingLocation, YearMonth } from "../lib/db-types"; import { updateOrAddLocation } from "../lib/actions/locationActions"; import { useFormState } from "react-dom"; -import { Main } from "./Main"; import Link from "next/link"; import { gotoHome } from "../lib/actions/navigationActions"; @@ -32,52 +31,66 @@ export const LocationEditForm:FC = ({ location, yearMonth }; return( - - - - + + + + { + location && + + + + } + + + {state.errors?.locationName && + state.errors.locationName.map((error: string) => ( + + {error} + + ))} + + + + + {state.errors?.locationNotes && + state.errors.locationNotes.map((error: string) => ( + + {error} + + ))} + + + { - location && - - - + state.message && + + {state.message} + } - - - {state.errors?.locationName && - state.errors.locationName.map((error: string) => ( - - {error} - - ))} - + - - - {state.errors?.locationNotes && - state.errors.locationNotes.map((error: string) => ( - - {error} - - ))} - - - - { - state.message && - - {state.message} - - } - - - - Save - Cancel - - - + + Save + Cancel + + - + + ) +} + +export const LocationEditFormSkeleton:FC = () => +{ + return( + + + + + + Save + Cancel + + + ) }
+ {error} +
+ {state.message} +
- {error} -
- {state.message} -