diff --git a/src/features/community/components/PlaylistCard.svelte b/src/features/community/components/PlaylistCard.svelte index 8d3e115..fffec30 100644 --- a/src/features/community/components/PlaylistCard.svelte +++ b/src/features/community/components/PlaylistCard.svelte @@ -5,6 +5,7 @@ name: string | null; user_name: string | null; liked: boolean; + onAddToLiked?: (id?: string) => void; } @@ -14,7 +15,7 @@ import { MousePointerClick, UserRound, Heart } from 'lucide-svelte'; import { Button } from '$comp/ui/button'; - const { id, link, name, user_name }: PlaylistCardProps = $props(); + const { id, link, name, user_name, onAddToLiked, liked }: PlaylistCardProps = $props(); @@ -36,12 +37,17 @@ + {liked ? 'Liked' : 'Like'} + +
diff --git a/src/lib/hooks/h1_locals_population.ts b/src/lib/hooks/h1_locals_population.ts index 54bd5e5..101a33e 100644 --- a/src/lib/hooks/h1_locals_population.ts +++ b/src/lib/hooks/h1_locals_population.ts @@ -4,7 +4,7 @@ import { authService } from '$server/services/AuthService'; export const h1LocalsPopulation: Handle = async ({ event, resolve }) => { const authInfo = await event.locals.auth(); const maybeUserEmail = authInfo?.user?.email; - console.log('authInfo', authInfo); + event.locals.info = await authService.populateUserSession(maybeUserEmail); return resolve(event); diff --git a/src/routes/dashboard/community/+page.svelte b/src/routes/dashboard/community/+page.svelte index f3c7f33..3934129 100644 --- a/src/routes/dashboard/community/+page.svelte +++ b/src/routes/dashboard/community/+page.svelte @@ -1,6 +1,8 @@ -{#each data.playlists as playlist} - -{/each} +
+ {#each data.playlists as playlist} + { + await trpc.community.likeCommunityPlaylist.mutate({ + playlist_id: playlist.id, + like: !playlist.liked + }); + + await invalidateAll(); + }} + liked={playlist.liked} + id={playlist.id} + user_name={playlist.user_name} + name={playlist.name} + link={playlist.link} + /> + {/each} +