Skip to content

Commit 752a7b3

Browse files
committed
Fix toast and add redirect
1 parent f863670 commit 752a7b3

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

app/layout.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import type { Metadata } from "next";
22
import { Inter } from "next/font/google";
33
import "./globals.css";
4+
import { Toaster } from "react-hot-toast";
45

56
const inter = Inter({ subsets: ["latin"] });
67

78
export const metadata: Metadata = {
8-
title: "Plain support portal",
9-
description: "Plain support portal example repo",
9+
title: "Plain support portal",
10+
description: "Plain support portal example repo",
1011
};
1112

1213
export default function RootLayout({
13-
children,
14+
children,
1415
}: Readonly<{
15-
children: React.ReactNode;
16+
children: React.ReactNode;
1617
}>) {
17-
return (
18-
<html lang="en">
19-
<body className={inter.className}>{children}</body>
20-
</html>
21-
);
18+
return (
19+
<html lang="en">
20+
<body className={inter.className}>
21+
<>
22+
{children}
23+
<Toaster />
24+
</>
25+
</body>
26+
</html>
27+
);
2228
}

app/thread/new/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import { useState } from "react";
88
import { RequestBody } from "@/app/api/contact-form/route";
99
import { toast } from "react-hot-toast";
1010
import { Button } from "@/components/button";
11+
import { useRouter } from "next/navigation";
1112

1213
export default function NewThreadPage() {
1314
const [subject, setSubject] = useState("");
1415
const [message, setMessage] = useState("");
1516
const [isLoading, setIsLoading] = useState(false);
17+
const router = useRouter();
1618

1719
async function onSubmit(e: React.FormEvent) {
1820
e.preventDefault();
@@ -30,6 +32,7 @@ export default function NewThreadPage() {
3032
});
3133
if (result.ok) {
3234
toast.success("Nice, we'll be in touch shortly!");
35+
router.push("/");
3336
} else {
3437
toast.error("Oops");
3538
}

0 commit comments

Comments
 (0)