From b80ae05820fcb67ba0581408b01217babb300b9b Mon Sep 17 00:00:00 2001 From: Lea Date: Sun, 3 Sep 2023 15:04:15 +0200 Subject: [PATCH] feat: user stream UI --- app/panel/stream/page.tsx | 46 +++++++++++ components/common/NavigationLinks.tsx | 7 ++ components/pages/stream/UserReviewCard.tsx | 96 ++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 app/panel/stream/page.tsx create mode 100644 components/pages/stream/UserReviewCard.tsx diff --git a/app/panel/stream/page.tsx b/app/panel/stream/page.tsx new file mode 100644 index 0000000..628aa15 --- /dev/null +++ b/app/panel/stream/page.tsx @@ -0,0 +1,46 @@ +"use client" + +import { UserReviewCard } from "@/components/pages/stream/UserReviewCard"; +import { Card, CardDescription } from "@/components/ui/card"; +import { Account, fetchAccountById, fetchUserById } from "@/lib/db"; +import { Circle } from "lucide-react"; +import { useEffect, useMemo, useState } from "react"; +import { User } from "revolt-api"; + +export default function UserStream() { + const [connectionState, setConnectionState] = useState<"Connecting"|"Connected"|"Disconnected">("Connecting"); + const [user, setUser] = useState(null); + const [account, setAccount] = useState(null); + + const connectionColour = useMemo(() => { + switch(connectionState) { + case "Connected": return "#55aa7f"; + case "Connecting": return "#fb923c"; + case "Disconnected": return "#ef4444"; + } + }, [connectionState]); + + useEffect(() => { + fetchUserById("01H6BZB5F4B6GTKSJCV6TRGZ22").then(setUser); + fetchAccountById("01H6BZB5F4B6GTKSJCV6TRGZ22").then(setAccount); + + setTimeout(() => setConnectionState("Connected"), 1000); + }, []); + + return account ? ( +
+ + + + {connectionState} + + + + +
+ + +
+
+ ) : null; +} diff --git a/components/common/NavigationLinks.tsx b/components/common/NavigationLinks.tsx index 1a147c9..53a47c3 100644 --- a/components/common/NavigationLinks.tsx +++ b/components/common/NavigationLinks.tsx @@ -11,6 +11,7 @@ import { Siren, Sparkles, TrendingUp, + ClipboardList, } from "lucide-react"; export function NavigationLinks() { @@ -40,6 +41,12 @@ export function NavigationLinks() { > + + + + + { + user + ? {user.username}#{user.discriminator} + : Pending onboarding + } + {account.email} · {dayjs(decodeTime(account._id)).fromNow()} + + + + + + + + + + + + + + + + + + ; +}