From f73942444a3a21bac7ca230dd41a053f03b442f0 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 16 Apr 2024 21:17:38 -0700 Subject: [PATCH] Add jank list of newest bottles --- apps/server/src/trpc/routes/bottleList.ts | 8 +++++ apps/web/app/components/header.tsx | 2 +- apps/web/app/components/layout.tsx | 2 +- apps/web/app/routes/_index.tsx | 40 ++++++++++++++++++++--- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/apps/server/src/trpc/routes/bottleList.ts b/apps/server/src/trpc/routes/bottleList.ts index 41f976741..51c3d53ce 100644 --- a/apps/server/src/trpc/routes/bottleList.ts +++ b/apps/server/src/trpc/routes/bottleList.ts @@ -19,10 +19,12 @@ import { publicProcedure } from ".."; const DEFAULT_SORT = "-tastings"; const SORT_OPTIONS = [ + "date", "name", "age", "rating", "tastings", + "-date", "-name", "-age", "-rating", @@ -143,6 +145,12 @@ export default publicProcedure let orderBy: SQL; switch (input.sort) { + case "date": + orderBy = asc(bottles.createdAt); + break; + case "-date": + orderBy = desc(bottles.createdAt); + break; case "name": orderBy = asc(bottles.fullName); break; diff --git a/apps/web/app/components/header.tsx b/apps/web/app/components/header.tsx index 4a60a3cea..fc42e1506 100644 --- a/apps/web/app/components/header.tsx +++ b/apps/web/app/components/header.tsx @@ -23,7 +23,7 @@ export default ({ mobileOnly = false, children, color = "default" }: Props) => { : "border-b border-b-slate-700 bg-slate-950", )} > -
+
{children}
diff --git a/apps/web/app/components/layout.tsx b/apps/web/app/components/layout.tsx index 02ead7ec7..bda6c62b4 100644 --- a/apps/web/app/components/layout.tsx +++ b/apps/web/app/components/layout.tsx @@ -46,7 +46,7 @@ export default function Layout({
-
+
{children}
diff --git a/apps/web/app/routes/_index.tsx b/apps/web/app/routes/_index.tsx index 8641207ea..25bda9cf1 100644 --- a/apps/web/app/routes/_index.tsx +++ b/apps/web/app/routes/_index.tsx @@ -1,3 +1,4 @@ +import { formatCategoryName } from "@peated/server/src/lib/format"; import Alert from "@peated/web/components/alert"; import Glyph from "@peated/web/components/assets/Glyph"; import BetaNotice from "@peated/web/components/betaNotice"; @@ -17,6 +18,7 @@ import { Link, useLoaderData, useLocation } from "@remix-run/react"; import { json } from "@remix-run/server-runtime"; import { Fragment } from "react"; import { useEventListener } from "usehooks-ts"; +import BottleLink from "../components/bottleLink"; import { makeIsomorphicLoader } from "../lib/isomorphicLoader"; const defaultViewParam = "global"; @@ -26,18 +28,27 @@ export const { loader, clientLoader } = makeIsomorphicLoader( const { searchParams } = new URL(request.url); const filter = mapFilterParam(searchParams.get("view")); - return json({ - tastingList: await trpc.tastingList.query({ + const [tastingList, newBottleList] = await Promise.all([ + trpc.tastingList.query({ filter, limit: 10, }), + trpc.bottleList.query({ + limit: 10, + sort: "-date", + }), + ]); + + return json({ + tastingList, + newBottleList, }); }, ); export default function Activity() { const { user } = useAuth(); - const { tastingList } = useLoaderData(); + const { tastingList, newBottleList } = useLoaderData(); const location = useLocation(); const qs = new URLSearchParams(location.search); const filterParam = mapFilterParam(qs.get("view")); @@ -45,7 +56,7 @@ export default function Activity() { return (
-
+
{user && (
-
+
{!user && (

@@ -78,6 +89,25 @@ export default function Activity() {

)}
+ + Newest Bottles + +
    + {newBottleList.results.map((b) => { + return ( +
  • + + + {b.fullName} + +
    + {formatCategoryName(b.category)} +
    +
  • + ); + })} +
+ Market Prices