From b2e1644acd142fb8705e3fb21fdbf755c89f5fa4 Mon Sep 17 00:00:00 2001 From: Jonathan Mumm Date: Sat, 11 May 2024 18:53:01 -0700 Subject: [PATCH] wip saving fixes --- src/app/(home)/layout.tsx | 4 +- src/app/@craft/components.client.tsx | 13 ++-- src/app/components.client.tsx | 91 +++++++++++----------------- src/app/history/page.tsx | 4 +- src/app/my-cookbook/page.tsx | 4 +- src/app/recipe/components.tsx | 4 +- src/db/queries/index.tsx | 4 +- 7 files changed, 56 insertions(+), 68 deletions(-) diff --git a/src/app/(home)/layout.tsx b/src/app/(home)/layout.tsx index 823f3ae9..6a5aab06 100644 --- a/src/app/(home)/layout.tsx +++ b/src/app/(home)/layout.tsx @@ -21,7 +21,7 @@ import { getSession } from "@/lib/auth/session"; import { formatDuration, shuffle, timeAgo } from "@/lib/utils"; import { getProfileByUserId, - getRecentRecipesByUser, + getRecentLikedRecipesByUser, getSortedMediaForMultipleRecipes, } from "../../db/queries"; import LayoutClient, { HomeTabs } from "./layout.client"; @@ -119,7 +119,7 @@ const MyRecipes = ({ userId }: { userId: string }) => { }; const RecipeList = async () => { - const recipes = await getRecentRecipesByUser(db, userId); + const recipes = await getRecentLikedRecipesByUser(db, userId); const slugs = recipes.map((recipe) => recipe.slug); const quotes = shuffle(quoteList); const mediaBySlug = slugs.length diff --git a/src/app/@craft/components.client.tsx b/src/app/@craft/components.client.tsx index 50374631..ed770d3f 100644 --- a/src/app/@craft/components.client.tsx +++ b/src/app/@craft/components.client.tsx @@ -1759,12 +1759,17 @@ export const SaveRecipeBadge = () => { )} > -
+
Added to{" "} - - {selectedList?.name || "My Cookbook"} + + + {selectedList?.name || "My Cookbook"} + + -
- ) : ( - - )} - - ); - })} -
- ); - }; - const RecentLists = () => { const lists = useSortedRecipeLists(); - console.log({ lists }); const isLoading = useIsLoadingRecipeLists(); const items = new Array(6).fill(""); @@ -1146,9 +1108,11 @@ export const SelectListCard = () => { > + Create List - + + + -
+
@@ -1228,16 +1192,35 @@ export const CreateNewListCard = () => { ); }; -const MyCookbookCard = () => { +const LikedRecipesCard = () => { return ( +
+

Liked Recipes

+

+ Recipes you have{" "} + + 'd. +

+
+ +
+ ); +}; + +const MakeLaterCard = () => { + return ( +
-

My Cookbook

+

Make Later

- Your personal collection of recipes. + Recipes you want to remember to make some time

diff --git a/src/app/history/page.tsx b/src/app/history/page.tsx index e71834cb..144db0cf 100644 --- a/src/app/history/page.tsx +++ b/src/app/history/page.tsx @@ -5,7 +5,7 @@ import { Skeleton } from "@/components/display/skeleton"; import { Button } from "@/components/input/button"; import { AsyncRenderFirstValue } from "@/components/util/async-render-first-value"; import { AsyncRenderLastValue } from "@/components/util/async-render-last-value"; -import { getProfileLifetimePoints, getRecentRecipesByUser } from "@/db/queries"; +import { getProfileLifetimePoints, getRecentLikedRecipesByUser } from "@/db/queries"; import { formatJoinDateStr } from "@/lib/utils"; import { ChefHatIcon } from "lucide-react"; import { RecipeListItem } from "../recipe/components"; @@ -26,7 +26,7 @@ export default async function Page() { redirect("/auth/signin"); } const userId = session.user.id; - const recipes$ = from(getRecentRecipesByUser(db, userId)).pipe(shareReplay(1)); + const recipes$ = from(getRecentLikedRecipesByUser(db, userId)).pipe(shareReplay(1)); // Rest of your existing components like Username, Points, ClaimDate etc. const quotaLimit$ = of(3); diff --git a/src/app/my-cookbook/page.tsx b/src/app/my-cookbook/page.tsx index a74b54a9..9f055aaf 100644 --- a/src/app/my-cookbook/page.tsx +++ b/src/app/my-cookbook/page.tsx @@ -8,7 +8,7 @@ import { AsyncRenderFirstValue } from "@/components/util/async-render-first-valu import { AsyncRenderLastValue } from "@/components/util/async-render-last-value"; import quoteList from "@/data/quotes.json"; import { db } from "@/db"; -import { getRecentRecipesByCreator, getRecentRecipesByUser, updateRecipeCreator } from "@/db/queries"; +import { getRecentRecipesByCreator, getRecentLikedRecipesByUser, updateRecipeCreator } from "@/db/queries"; import { getCurrentUserId } from "@/lib/auth/session"; import { getGuestId } from "@/lib/browser-session"; import { assert, shuffle } from "@/lib/utils"; @@ -40,7 +40,7 @@ export default async function Page() { const [recipes$] = [ createdBy - ? from(getRecentRecipesByUser(db, createdBy)).pipe(shareReplay(1)) + ? from(getRecentLikedRecipesByUser(db, createdBy)).pipe(shareReplay(1)) : of([]), ]; // const browserSessionId = await getGuestId(); diff --git a/src/app/recipe/components.tsx b/src/app/recipe/components.tsx index 1f124f77..a633f84e 100644 --- a/src/app/recipe/components.tsx +++ b/src/app/recipe/components.tsx @@ -25,7 +25,7 @@ import { getBestRecipes, getHotRecipes, getRecentRecipesByProfile, - getRecentRecipesByUser, + getRecentLikedRecipesByUser, } from "../../db/queries"; import { upvoteById } from "../recipe/actions"; import { RecipePropsProvider } from "./context"; @@ -35,7 +35,7 @@ type Recipes = | Awaited>[0] | Awaited>[0] | Awaited>[0] - | Awaited>[0]; + | Awaited>[0]; interface RecipeListItemProps { recipe: Recipes; // Define RecipeType according to your data structure diff --git a/src/db/queries/index.tsx b/src/db/queries/index.tsx index 00c6dc85..1723bbe6 100644 --- a/src/db/queries/index.tsx +++ b/src/db/queries/index.tsx @@ -266,11 +266,11 @@ export const getRecipesByListSlug = async ( return await withDatabaseSpan(query, "getRecipesByListSlug").execute(); }; -export const getRecentRecipesByUser = async ( +export const getRecentLikedRecipesByUser = async ( dbOrTransaction: DbOrTransaction, userId: string ) => { - return getRecipesByListSlug(dbOrTransaction, userId, "my-cookbook"); + return getRecipesByListSlug(dbOrTransaction, userId, "liked"); }; export const getRecentRecipesByCreator = async (createdBy: string) => {