feat: added favorites page

This commit is contained in:
ner committed 2023-08-09 18:43:48 +03:00
1 parent 0cb860d0a0
commit 89e76f5df6
27 files changed
+412 -116

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ const Poster: FC<Props> = ({ title, poster, width, height, size = 250, className
alt={title}
/>
) : (
<div className={`h-[${height}px] w-full flex items-center justify-center rounded-lg border`}>
<div className={`h-[${height}px] w-full flex items-center justify-center rounded-lg border grow`}>
<ImageOff size={size} strokeWidth={1} />
</div>
)}
@@ -0,0 +1,37 @@
import { FC } from 'react';
import { Heart, Star } from 'lucide-react';
import useFavorites, { useFavoritesMutation } from '@/app/(site)/favorites/useFavorites';
interface Props {
movie: Movie;
}
const Rating: FC<Props> = ({ movie }) => {
const { map } = useFavorites();
const { add, remove } = useFavoritesMutation();
const isFavorite = map.has(movie.id);
return (
<span className='select-none flex w-full items-center ml-auto gap-1 mt-[-8px] justify-between'>
<span
onClick={(event) => {
event.stopPropagation();
isFavorite ? remove(movie.id) : add(movie);
}}
className='z-[2] cursor-pointer'
title={isFavorite ? 'Remove from favorites' : 'Add to favorite'}
>
<Heart className={isFavorite ? 'fill-accent-foreground' : ''} size={18} />
</span>
<span className='flex items-center'>
<Star size={18} className='fill-accent-foreground mr-1' />
<span className='font-semibold'>{movie.vote_average?.toFixed(1)}</span>
</span>
</span>
);
};
export default Rating;
+1 -1
View File
@@ -26,7 +26,7 @@ const Title: FC<Props> = ({ title }) => {
isScrollableTitle && setIsScrollableTitle(isScrollableTitle);
}}
>
{title} &nbsp;
{title}&nbsp;
</div>
</Marquee>
);