Extract admin editor state into useCardEditor and UI into CardEditorView; keep dynamic(ssr: false) on the page export. Page is ~40 lines. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import { useRouter } from 'next/router';
|
|
import dynamic from 'next/dynamic';
|
|
import Layout from '../../components/Layout';
|
|
import AdminProtected from '../../components/AdminProtected';
|
|
import CardEditorView from '../../components/CardEditorView';
|
|
import { useCardEditor } from '../../lib/use-card-editor.js';
|
|
|
|
function CardEditorPage() {
|
|
const router = useRouter();
|
|
const editor = useCardEditor(router);
|
|
|
|
if (editor.loading) {
|
|
return (
|
|
<AdminProtected>
|
|
{(user) => (
|
|
<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>
|
|
)}
|
|
</AdminProtected>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<AdminProtected>
|
|
{(user) => (
|
|
<Layout user={user}>
|
|
<CardEditorView {...editor} />
|
|
</Layout>
|
|
)}
|
|
</AdminProtected>
|
|
);
|
|
}
|
|
|
|
export default dynamic(() => Promise.resolve(CardEditorPage), { ssr: false });
|