-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeartButton.tsx
53 lines (46 loc) · 996 Bytes
/
HeartButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use client';
import { AiFillHeart, AiOutlineHeart } from "react-icons/ai";
import useFavorite from "@/app/hooks/useFavorite";
import { SafeUser } from "@/app/types";
import ClientOnly from "./ClientOnly";
interface HeartButtonProps {
listingId: string
currentUser?: SafeUser | null
}
const HeartButton: React.FC<HeartButtonProps> = ({
listingId,
currentUser
}) => {
const { hasFavorited, toggleFavorite } = useFavorite({
listingId,
currentUser
});
return (
<div
onClick={toggleFavorite}
className="
relative
hover:opacity-80
transition
cursor-pointer
"
>
<AiOutlineHeart
size={28}
className="
fill-white
absolute
-top-[2px]
-right-[2px]
"
/>
<AiFillHeart
size={24}
className={
hasFavorited ? 'fill-rose-500' : 'fill-neutral-500/70'
}
/>
</div>
);
}
export default HeartButton;