From 2527d429bcc5fc8db5b35360dd78b3ce630c6b10 Mon Sep 17 00:00:00 2001 From: Prayag Prajapati Date: Wed, 6 Sep 2023 14:30:19 +0530 Subject: [PATCH] Fix cards --- src/components/buttons/likeButton.jsx | 11 +++++++- src/components/buttons/markPlayedButton.jsx | 4 ++- src/components/card/card.jsx | 29 ++++++++++++++------- src/main.jsx | 3 +++ src/routes/login/index.jsx | 6 +++-- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/components/buttons/likeButton.jsx b/src/components/buttons/likeButton.jsx index fc07768..65a7662 100644 --- a/src/components/buttons/likeButton.jsx +++ b/src/components/buttons/likeButton.jsx @@ -75,22 +75,31 @@ const LikeButton = ({ itemId, isFavorite, queryKey, userId, itemName }) => { return { currentLatestMedia }; }, onError: (error, a, context) => { + enqueueSnackbar(`${error}`, { + variant: "error", + }); enqueueSnackbar( `An error occured while updating "${itemName}"`, { variant: "error", }, ); + queryClient.setQueryData(queryKey, context.previousData); - console.error(error); + setIsLoading(false); setIsError(true); + console.log("set"); + + console.error(error); }, onSuccess: () => { console.log("Successfully updated", itemId); queryClient.invalidateQueries(queryKey); + setIsLoading(false); setIsSuccess(true); }, onSettled: () => { + console.log("set"); setIsLoading(false); }, }); diff --git a/src/components/buttons/markPlayedButton.jsx b/src/components/buttons/markPlayedButton.jsx index d582616..dded071 100644 --- a/src/components/buttons/markPlayedButton.jsx +++ b/src/components/buttons/markPlayedButton.jsx @@ -80,12 +80,14 @@ const MarkPlayedButton = ({ itemId, isPlayed, queryKey, userId, itemName }) => { }, ); queryClient.setQueryData(queryKey, context.previousData); - console.error(error); + setIsLoading(false); setIsError(true); + console.error(error); }, onSuccess: () => { console.log("Successfully updated", itemId); queryClient.invalidateQueries(queryKey); + setIsLoading(false); setIsSuccess(true); }, onSettled: () => { diff --git a/src/components/card/card.jsx b/src/components/card/card.jsx index 14374ff..8f43d44 100644 --- a/src/components/card/card.jsx +++ b/src/components/card/card.jsx @@ -56,6 +56,7 @@ export const Card = ({ onClick, disableOverlay = false, disablePadding, + overrideIcon, }) => { const ref = useRef(); const isVisible = useIntersecting(ref); @@ -172,18 +173,26 @@ export const Card = ({ /> )} - {TypeIconCollectionCard[item.Type]} + {!!overrideIcon + ? TypeIconCollectionCard[overrideIcon] + : TypeIconCollectionCard[item.Type]} { > { `/login/withImg/${item.Name}/${item.Id}/`, ) } + overrideIcon="User" + imageType="Primary" /> );