Moves card-browser state and handlers to lib/use-cards-page.js and markup to components/CardsPageView.js, leaving a thin ProtectedRoute composer in pages/cards.js. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1 KiB
JavaScript
38 lines
1 KiB
JavaScript
import Layout from '../components/Layout';
|
|
import CardsPageView from '../components/CardsPageView';
|
|
import PublicCardsView from '../components/PublicCardsView';
|
|
import ProtectedRoute from '../components/ProtectedRoute';
|
|
import { useAuth } from '../lib/use-auth';
|
|
import { useCardsPage } from '../lib/use-cards-page.js';
|
|
|
|
function AuthenticatedCards() {
|
|
const { user } = useAuth();
|
|
const cardsPage = useCardsPage();
|
|
|
|
if (cardsPage.showInitialLoading) {
|
|
return (
|
|
<Layout user={user}>
|
|
<div className="flex items-center justify-center min-h-screen">
|
|
<div className="animate-spin rounded-full h-32 w-32 border-b-2" style={{ borderColor: 'var(--text-accent)' }} />
|
|
</div>
|
|
</Layout>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Layout user={user}>
|
|
<CardsPageView {...cardsPage} />
|
|
</Layout>
|
|
);
|
|
}
|
|
|
|
export default function Cards() {
|
|
return (
|
|
<ProtectedRoute
|
|
allowPublic={true}
|
|
publicFallback={<PublicCardsView />}
|
|
>
|
|
<AuthenticatedCards />
|
|
</ProtectedRoute>
|
|
);
|
|
}
|