type fixes
This commit is contained in:
+19
-7
@@ -13,7 +13,7 @@
|
||||
* via a query param (kept simple — no new route for the form).
|
||||
*/
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { Suspense, useEffect } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import {
|
||||
AtSign,
|
||||
@@ -30,11 +30,6 @@ export default function MeLayout({ children }: { children: React.ReactNode }) {
|
||||
const { user, loading } = useAuth();
|
||||
const { requireAuth } = useAuthGate();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
// /u/me?edit=1 swaps the Posts grid for the inline edit form (see
|
||||
// app/u/me/page.tsx). The tab strip would just be in the way while the
|
||||
// user is editing — hide it for that one URL state.
|
||||
const editMode = searchParams.get("edit") === "1";
|
||||
|
||||
useEffect(() => {
|
||||
if (loading || user) return;
|
||||
@@ -91,8 +86,25 @@ export default function MeLayout({ children }: { children: React.ReactNode }) {
|
||||
joinedAt={user.created_at}
|
||||
editHref="/u/me?edit=1"
|
||||
/>
|
||||
{editMode ? null : <ProfileTabs tabs={tabs} />}
|
||||
{/* Tab strip hides on /u/me?edit=1 (see ConditionalTabs). The
|
||||
Suspense boundary is required by Next.js because useSearchParams
|
||||
forces a CSR bailout during prerender. Without it, every
|
||||
/u/me/* route fails to build. Fallback renders the tabs as-is
|
||||
so the visual default (tabs visible) is what users see while
|
||||
the search params resolve. */}
|
||||
<Suspense fallback={<ProfileTabs tabs={tabs} />}>
|
||||
<ConditionalTabs tabs={tabs} />
|
||||
</Suspense>
|
||||
<div className="py-6">{children}</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function ConditionalTabs({ tabs }: { tabs: ProfileTab[] }) {
|
||||
const searchParams = useSearchParams();
|
||||
// /u/me?edit=1 swaps the Posts grid for the inline edit form (see
|
||||
// app/u/me/page.tsx). The tab strip would just be in the way while the
|
||||
// user is editing — hide it for that one URL state.
|
||||
const editMode = searchParams.get("edit") === "1";
|
||||
return editMode ? null : <ProfileTabs tabs={tabs} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user