import { useLogin, useCheckoutSession } from '@ollie-shop/sdk';
import styles from './styles.module.css';
function FavoriteButton({ productId }: { productId: string }) {
const { openLogin } = useLogin();
const { session: { user } } = useCheckoutSession();
const handleFavorite = () => {
if (user.isGuest) {
openLogin({
isRequired: true,
title: "Sign in to save favorites"
});
return;
}
// User is logged in, add to favorites
addToFavorites(productId);
};
return (
<button className={styles.button} onClick={handleFavorite}>
Add to Favorites
</button>
);
}