From eedb0bab243d4b0bed9980894e0f228058225de7 Mon Sep 17 00:00:00 2001 From: Lucieo Date: Tue, 19 Sep 2023 11:35:09 +0200 Subject: [PATCH] Trending bookmarks listing (#20) * Trending bookmarks listing * Fix newsletter bookmark * Fix type on search * Naming and delete popover style * Fix draggable id --- .../digests/[digestId]/edit/page.tsx | 13 +- src/app/(routes)/teams/[teamSlug]/page.tsx | 6 +- src/app/providers.tsx | 1 - src/components/Input.tsx | 6 +- src/components/Popover.tsx | 54 ++++- src/components/Tooltip.tsx | 2 +- src/components/bookmark/BookmarkAddButton.tsx | 15 +- src/components/bookmark/BookmarkItem.tsx | 128 +++++++----- src/components/bookmark/BookmarkListDnd.tsx | 21 +- .../bookmark/BookmarksListControls.tsx | 2 +- src/components/bookmark/BookmarksTeamList.tsx | 26 ++- .../{Bookmark.tsx => NewsBookmark.tsx} | 16 +- src/components/pages/DigestEditPage.tsx | 19 +- src/components/pages/Team.tsx | 14 +- src/emails/templates/NewsletterEmail.tsx | 4 +- src/lib/queries.ts | 188 ++++++------------ src/messages/en.ts | 9 +- src/pages/api/bookmark/index.ts | 2 +- .../api/teams/[teamId]/bookmark/index.ts | 20 +- src/utils/bookmark.ts | 33 +++ 20 files changed, 321 insertions(+), 258 deletions(-) rename src/components/bookmark/{Bookmark.tsx => NewsBookmark.tsx} (88%) diff --git a/src/app/(routes)/teams/[teamSlug]/digests/[digestId]/edit/page.tsx b/src/app/(routes)/teams/[teamSlug]/digests/[digestId]/edit/page.tsx index 402b420..97d6e33 100644 --- a/src/app/(routes)/teams/[teamSlug]/digests/[digestId]/edit/page.tsx +++ b/src/app/(routes)/teams/[teamSlug]/digests/[digestId]/edit/page.tsx @@ -3,7 +3,7 @@ import { TeamProvider } from '@/contexts/TeamContext'; import { checkUserTeamBySlug, getDigest, - getTeamBookmarksNotInDigest, + getTeamLinks, updateDefaultTeam, } from '@/lib/queries'; import { getCurrentUserOrRedirect } from '@/lib/sessions'; @@ -32,17 +32,16 @@ const page = async ({ params, searchParams }: TeamPageProps) => { const page = Number(searchParams?.page || 1); const search = searchParams?.search || ''; - const dataBookmarks = await getTeamBookmarksNotInDigest( - team.id, + const teamLinksData = await getTeamLinks(team.id, { page, - 10, - search - ); + onlyNotInDigest: true, + search, + }); return ( diff --git a/src/app/(routes)/teams/[teamSlug]/page.tsx b/src/app/(routes)/teams/[teamSlug]/page.tsx index 3a4813d..75d39d6 100644 --- a/src/app/(routes)/teams/[teamSlug]/page.tsx +++ b/src/app/(routes)/teams/[teamSlug]/page.tsx @@ -2,7 +2,7 @@ import Team from '@/components/pages/Team'; import db from '@/lib/db'; import { checkUserTeamBySlug, - getTeamBookmarks, + getTeamLinks, getTeamDigests, updateDefaultTeam, } from '@/lib/queries'; @@ -39,7 +39,7 @@ const TeamPage = async ({ params, searchParams }: TeamPageProps) => { const page = Number(searchParams?.page || 1); const search = searchParams?.search || ''; - const { totalCount, bookmarks } = await getTeamBookmarks(team.id, { + const { totalCount, teamLinks } = await getTeamLinks(team.id, { page, onlyNotInDigest: !searchParams?.all, search, @@ -51,7 +51,7 @@ const TeamPage = async ({ params, searchParams }: TeamPageProps) => { diff --git a/src/app/providers.tsx b/src/app/providers.tsx index 4376465..f43d570 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -3,7 +3,6 @@ import { Toaster } from 'react-hot-toast'; import { SessionProvider } from 'next-auth/react'; import { QueryClient, QueryClientProvider } from 'react-query'; -import messages from '../messages/en.json'; const locale = 'en'; diff --git a/src/components/Input.tsx b/src/components/Input.tsx index aac8981..c73d052 100644 --- a/src/components/Input.tsx +++ b/src/components/Input.tsx @@ -63,7 +63,7 @@ export const Select = forwardRef>( ); export const Switch = forwardRef>( - function Switch({ label, onClick, checked, ...props }, ref) { + function Switch({ label, onChange, checked, ...props }, ref) { const [isChecked, setIsChecked] = useState(checked); return (