change and sync wishlist with api
This commit is contained in:
@@ -14,8 +14,7 @@ import {useEffect, useState} from "react";
|
||||
export function NoticeCard({notice}) {
|
||||
const noticeId = notice?.noticeId;
|
||||
|
||||
const addNoticeToWishlist = useWishlist((state) => state.addNoticeToWishlist);
|
||||
const removeNoticeFromWishlist = useWishlist((state) => state.removeNoticeFromWishlist);
|
||||
const toggleNoticeInWishlist = useWishlist((state) => state.toggleNoticeInWishlist);
|
||||
const isInWishlist = useWishlist((state) =>
|
||||
noticeId ? state.wishlistNotices.some((item) => item.noticeId === noticeId) : false
|
||||
);
|
||||
@@ -94,11 +93,7 @@ export function NoticeCard({notice}) {
|
||||
</Heading>
|
||||
<Pressable
|
||||
onPress={() => {
|
||||
if (isInWishlist) {
|
||||
removeNoticeFromWishlist(noticeId);
|
||||
} else {
|
||||
addNoticeToWishlist(notice);
|
||||
}
|
||||
toggleNoticeInWishlist(noticeId);
|
||||
}}
|
||||
>
|
||||
<Ionicons
|
||||
|
||||
Reference in New Issue
Block a user