From 0335b0ad81169232a3dbb1be1341fdcfce548645 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 2 Jun 2026 02:12:57 -0700 Subject: migrate to pocketbase backend + auth/login --- src/app/page.tsx | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 141 insertions(+), 3 deletions(-) (limited to 'src/app/page.tsx') diff --git a/src/app/page.tsx b/src/app/page.tsx index f8e1c1b..7a9b718 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,5 +1,143 @@ -import { redirect } from "next/navigation"; +"use client"; +import { useEffect, useState } from "react"; +import { FaPlay, FaMusic, FaSearch } from "react-icons/fa"; +import { MdLibraryMusic } from "react-icons/md"; +import { useAuth } from "./context/auth"; +import pb from "./lib/pocketbase"; +import { + Root, + Navbar, + Logo, + LogoIcon, + NavCtaLink, + NavLeft, + NavCenter, + SearchBox, + SearchInput, + SearchButton, + NavRight, -export default function HomePage() { - redirect("/typing"); + GridContainer, + CardGrid, + Card, + ThumbnailWrapper, + Thumbnail, + PlayOverlay, + PlayCircle, + CardMeta, + CardInfo, + CardTitle, + CardSub, + EmptyState, + TypingGlobalStyle, +} from "./page.styles"; + +interface ChartRecord { + id: string; + title: string; + artist: string; + thumbnail: string; + lrc: string; + media: string; + offset: number; +} + + +export default function TypingPage() { + const { user, signOut } = useAuth(); + const [charts, setCharts] = useState([]); + const [search, setSearch] = useState(""); + + useEffect(() => { + pb.collection("charts") + .getFullList({ sort: "-created" }) + .then(setCharts) + .catch(console.error); + }, []); + + const normalizedSearch = search.trim().toLowerCase(); + const filtered = normalizedSearch + ? charts.filter( + (item) => + item.title.toLowerCase().includes(normalizedSearch) || + item.artist.toLowerCase().includes(normalizedSearch), + ) + : charts; + + return ( + <> + + + + + + + + + TypingMIXX + + + + + + setSearch(e.target.value)} + /> + + + + + + + + {user ? ( + <> + + {user.username || user.name} + + { e.preventDefault(); signOut(); }}> + Sign out + + + ) : ( + Sign in + )} + + + + + + {filtered.length === 0 ? ( + No results found. + ) : ( + filtered.map((item) => ( + + + {item.thumbnail ? ( + + ) : ( + + )} + + + + + + + + + {item.title} + {item.artist} + + + + )) + )} + + + + + ); } -- cgit v1.2.3