mirror of
https://github.com/FranP-code/Reflecto.git
synced 2025-10-13 00:43:31 +00:00
feat: enhance SpacesGrid to display snapshot data and improve space rendering
This commit is contained in:
@@ -147,7 +147,11 @@ export function SpacesGrid() {
|
|||||||
|
|
||||||
{/* Spaces Grid */}
|
{/* Spaces Grid */}
|
||||||
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||||
{filteredSpaces.map((space) => (
|
{filteredSpaces.map((space) => {
|
||||||
|
const snapshot = space.snapshotText
|
||||||
|
? JSON.parse(space.snapshotText).document
|
||||||
|
: undefined;
|
||||||
|
return (
|
||||||
<Card
|
<Card
|
||||||
className="group cursor-pointer border-border/50 transition-all duration-200 hover:border-border hover:shadow-lg"
|
className="group cursor-pointer border-border/50 transition-all duration-200 hover:border-border hover:shadow-lg"
|
||||||
key={space.id}
|
key={space.id}
|
||||||
@@ -205,21 +209,18 @@ export function SpacesGrid() {
|
|||||||
onMount={(editor) => {
|
onMount={(editor) => {
|
||||||
editor.updateInstanceState({ isReadonly: true });
|
editor.updateInstanceState({ isReadonly: true });
|
||||||
}}
|
}}
|
||||||
snapshot={
|
snapshot={snapshot}
|
||||||
space.snapshotText
|
|
||||||
? JSON.parse(space.snapshotText).document
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
||||||
<CardFooter className="flex items-center justify-between pt-0 text-muted-foreground text-sm">
|
<CardFooter className="flex items-center justify-between pt-0 text-muted-foreground text-sm">
|
||||||
<span>{space.itemCount} items</span>
|
<span>{snapshot?.itemCount} items</span>
|
||||||
<span>Edited {space.lastEdited}</span>
|
<span>Edited {space.lastEdited}</span>
|
||||||
</CardFooter>
|
</CardFooter>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Empty State (when no spaces exist) */}
|
{/* Empty State (when no spaces exist) */}
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ export async function upsertSpaceSnapshot(
|
|||||||
spaceId,
|
spaceId,
|
||||||
userId: uid,
|
userId: uid,
|
||||||
snapshot: JSON.stringify(payload),
|
snapshot: JSON.stringify(payload),
|
||||||
|
title: existing?.title,
|
||||||
|
color: existing?.color,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
} from "tldraw";
|
} from "tldraw";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import "tldraw/tldraw.css";
|
import "tldraw/tldraw.css";
|
||||||
|
import Loader from "@/components/loader";
|
||||||
import {
|
import {
|
||||||
getLatestSpaceSnapshot,
|
getLatestSpaceSnapshot,
|
||||||
type RemoteSnapshot,
|
type RemoteSnapshot,
|
||||||
@@ -78,6 +79,10 @@ function SpaceRoute() {
|
|||||||
};
|
};
|
||||||
}, [id, session, store]);
|
}, [id, session, store]);
|
||||||
|
|
||||||
|
if (!(id && session)) {
|
||||||
|
return <Loader />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-4 mt-4" style={{ position: "relative", inset: 0 }}>
|
<div className="mx-4 mt-4" style={{ position: "relative", inset: 0 }}>
|
||||||
<Tldraw
|
<Tldraw
|
||||||
|
|||||||
Reference in New Issue
Block a user