Complete "Creating Contacts".
This commit is contained in:
@@ -2,8 +2,14 @@ import React, { Suspense } from "react";
|
||||
import Link from "next/link";
|
||||
import Form from "next/form";
|
||||
import ContactList from "./sidebar-contacts";
|
||||
import { getContacts } from "@/app/data";
|
||||
import type { Metadata } from "next";
|
||||
import { createEmptyContact, getContacts } from "@/app/data";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
async function newContact() {
|
||||
"use server";
|
||||
await createEmptyContact();
|
||||
revalidatePath('/');
|
||||
}
|
||||
|
||||
export default function SidebarRootLayout({
|
||||
children,
|
||||
@@ -31,7 +37,7 @@ export default function SidebarRootLayout({
|
||||
hidden={true}
|
||||
id="search-spinner"/>
|
||||
</Form>
|
||||
<Form action="." formMethod="post">
|
||||
<Form action={newContact}>
|
||||
<button type="submit">New</button>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user