Skip to content

Commit

Permalink
added bookmarks page
Browse files Browse the repository at this point in the history
  • Loading branch information
NazireAta committed May 15, 2024
1 parent daa3ac1 commit faabafd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
49 changes: 49 additions & 0 deletions frontend/src/routes/bookmarks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { Recipe } from "../components/Recipe";
import { FullscreenLoading } from "../components/FullscreenLoading";
import { Alert, AlertDescription, AlertTitle } from "../components/ui/alert";
import { AlertCircle, Filter } from "lucide-react";

Check warning on line 5 in frontend/src/routes/bookmarks.tsx

View workflow job for this annotation

GitHub Actions / build

'Filter' is defined but never used

Check warning on line 5 in frontend/src/routes/bookmarks.tsx

View workflow job for this annotation

GitHub Actions / build

'Filter' is defined but never used
import { useNavigate } from "react-router-dom";
import { useGetMe } from "../services/api/semanticBrowseComponents";
import { renderError } from "../services/api/semanticBrowseFetcher";

// Inside the Bookmarks component
export const Bookmarks = () => {
const navigate = useNavigate();

Check warning on line 12 in frontend/src/routes/bookmarks.tsx

View workflow job for this annotation

GitHub Actions / build

'navigate' is assigned a value but never used

Check warning on line 12 in frontend/src/routes/bookmarks.tsx

View workflow job for this annotation

GitHub Actions / build

'navigate' is assigned a value but never used
const { data: bookmarksData, isLoading, error } = useGetMe({});

if (isLoading) {
return <FullscreenLoading overlay />;
}

if (error) {
return (
<div className="container flex flex-col gap-2 py-8">
<Alert variant="destructive">
<AlertCircle className="h-4 w-4" />
<AlertTitle>Error</AlertTitle>
<AlertDescription>{renderError(error)}</AlertDescription>
</Alert>
</div>
);
}

return (
<div className="container flex flex-col gap-2 py-8">
<div className="mt-4 flex justify-between items-center">
<h1 className="text-2xl font-bold text-center">Bookmarks</h1>
<p>{bookmarksData?.data?.bookmarks && (
<span className="text-gray-500"> {bookmarksData.data?.bookmarks.length} recipes</span>
)}</p>
</div>
<div className="mt-4 grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-4">
{bookmarksData?.data?.bookmarks?.map((recipe) => (
<Recipe
key={recipe.id}
recipe={recipe}
/>
))}
</div>
</div>
);
};
5 changes: 5 additions & 0 deletions frontend/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { signout } from "../services/auth";
import { Search } from "./search";
import { Feed } from "./feed";
import { NavbarLayout } from "../components/NavbarLayout";
import { Bookmarks } from "./bookmarks";

export const routes: RouteObject[] = [
{
Expand All @@ -24,6 +25,10 @@ export const routes: RouteObject[] = [
path: "/feed",
Component: Feed,
},
{
path: "/bookmarks",
Component: Bookmarks,
},
{
index: true,
Component: IndexRoute,
Expand Down

0 comments on commit faabafd

Please sign in to comment.