diff --git a/packages/web/src/routes/index.tsx b/packages/web/src/routes/index.tsx index ba981337..2167a73f 100644 --- a/packages/web/src/routes/index.tsx +++ b/packages/web/src/routes/index.tsx @@ -1,5 +1,13 @@ +import { useState, type FormEvent } from "react" import { createFileRoute, Link } from "@tanstack/react-router" import { ShaderBackground } from "@/components/ShaderBackground" +import { authClient } from "@/lib/auth-client" +import { useAccount } from "jazz-tools/react" +import { ViewerAccount, type SavedUrl } from "@/lib/jazz/schema" +import { Link2, Plus, Trash2, ExternalLink, Video, Settings, LogOut } from "lucide-react" + +// Feature flag: only this email can access stream features +const STREAM_ENABLED_EMAIL = "nikita@nikiv.dev" function LandingPage() { return ( @@ -44,6 +52,239 @@ function LandingPage() { ) } +function Dashboard() { + const { data: session } = authClient.useSession() + const me = useAccount(ViewerAccount) + + const [newUrl, setNewUrl] = useState("") + const [newTitle, setNewTitle] = useState("") + const [isAdding, setIsAdding] = useState(false) + + const canAccessStreams = session?.user?.email === STREAM_ENABLED_EMAIL + + const root = me.$isLoaded ? me.root : null + const urlList = root?.$isLoaded ? root.savedUrls : null + const savedUrls: SavedUrl[] = urlList?.$isLoaded ? [...urlList] : [] + + const handleAddUrl = (e: FormEvent) => { + e.preventDefault() + if (!newUrl.trim() || !root?.savedUrls?.$isLoaded) return + + root.savedUrls.$jazz.push({ + url: newUrl.trim(), + title: newTitle.trim() || null, + createdAt: Date.now(), + }) + + setNewUrl("") + setNewTitle("") + setIsAdding(false) + } + + const handleDeleteUrl = (index: number) => { + if (!root?.savedUrls?.$isLoaded) return + root.savedUrls.$jazz.splice(index, 1) + } + + const handleSignOut = async () => { + await authClient.signOut() + window.location.reload() + } + + if (!me.$isLoaded || !root?.$isLoaded) { + return ( +
Loading...
+{session?.user?.email}
++ Manage your live stream and archive settings. +
+No saved links yet
+Click "Add Link" to save your first bookmark
++ {item.title || item.url} +
+ {item.title && ( ++ {item.url} +
+ )} +Loading...
+