Redirect to a new Discover page after saving profile
The Save button was working (PATCH /api/profile succeeded), but the only feedback was a small "Saved." text with no page change - easy to read as "nothing happened," especially with no next step to move to. Added a placeholder /discover page (protected, same as /profile) and redirect there after a successful save, once the "Saved." confirmation has been visible for a moment. This is a stand-in for the real browse-other-members feature that's next on the roadmap, not the full feature itself. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VL5YUEf2B9LG4xdVUQwcSg
This commit is contained in:
3 files changed
+47
-7
No files matched your search
@@ -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 (
|
||||
<main className="mx-auto flex min-h-screen max-w-sm flex-col items-center justify-center gap-4 px-6 py-12 text-center">
|
||||
<h1 className="text-2xl font-bold text-brand">You're all set!</h1>
|
||||
<p className="text-gray-600">
|
||||
Your profile is saved. Browsing other members isn't built yet — that's next on the
|
||||
roadmap.
|
||||
</p>
|
||||
<Link
|
||||
href="/profile"
|
||||
className="rounded-lg bg-brand px-4 py-3 font-semibold text-white transition hover:bg-brand-dark"
|
||||
>
|
||||
Back to your profile
|
||||
</Link>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -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 (
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@ export default async function proxy(request: NextRequest) {
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/profile/:path*"],
|
||||
matcher: ["/profile/:path*", "/discover/:path*"],
|
||||
};
|
||||
Reference in new issue
Block a user