diff --git a/src/app/(sidebar)/contacts/[contactId]/edit/page.tsx b/src/app/(sidebar)/contacts/[contactId]/edit/page.tsx index ce2068c..3801c6b 100644 --- a/src/app/(sidebar)/contacts/[contactId]/edit/page.tsx +++ b/src/app/(sidebar)/contacts/[contactId]/edit/page.tsx @@ -1,8 +1,16 @@ import Form from "next/form"; import { fetchContact } from "@/app/(sidebar)/loaders"; -import { notFound } from "next/navigation"; +import { notFound, redirect } from "next/navigation"; +import { updateContact } from "@/app/data"; +async function editContact(contactId: string, formData: FormData) { + "use server"; + const updates = Object.fromEntries(formData); + await updateContact(contactId, updates); + redirect(`/contacts/${contactId}`); +} + export default async function EditContactPage({ params }: { @@ -13,9 +21,10 @@ export default async function EditContactPage({ if (c === null) notFound(); return c; }); + const editThisContact = editContact.bind(null, contactId); return ( -
+

Name