diff --git a/src/app/discover/page.tsx b/src/app/discover/page.tsx new file mode 100644 index 0000000..99bb9f7 --- /dev/null +++ b/src/app/discover/page.tsx @@ -0,0 +1,27 @@ +import Link from "next/link"; +import { getServerSession } from "next-auth"; +import { redirect } from "next/navigation"; +import { authOptions } from "@/lib/auth"; + +export default async function DiscoverPage() { + const session = await getServerSession(authOptions); + if (!session?.user?.id) { + redirect("/login"); + } + + return ( +
+

You're all set!

+

+ Your profile is saved. Browsing other members isn't built yet — that's next on the + roadmap. +

+ + Back to your profile + +
+ ); +} diff --git a/src/app/profile/profile-editor.tsx b/src/app/profile/profile-editor.tsx index bf5094c..f03b78a 100644 --- a/src/app/profile/profile-editor.tsx +++ b/src/app/profile/profile-editor.tsx @@ -17,13 +17,26 @@ export default function ProfileEditor({ e.preventDefault(); setStatus("saving"); - const res = await fetch("/api/profile", { - method: "PATCH", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ name, bio }), - }); + try { + const res = await fetch("/api/profile", { + method: "PATCH", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ name, bio }), + }); - setStatus(res.ok ? "saved" : "error"); + if (!res.ok) { + setStatus("error"); + return; + } + + setStatus("saved"); + // Give the "Saved." confirmation a moment to be seen before moving on. + setTimeout(() => { + window.location.href = "/discover"; + }, 700); + } catch { + setStatus("error"); + } } return ( diff --git a/src/proxy.ts b/src/proxy.ts index 783e4db..3f774da 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -14,5 +14,5 @@ export default async function proxy(request: NextRequest) { } export const config = { - matcher: ["/profile/:path*"], + matcher: ["/profile/:path*", "/discover/:path*"], };