import { useOffers } from '@tagadapay/headless-sdk/react';
function UpsellPage({ offerId, sessionId }) {
const { offer, loadOffer, acceptOffer, declineOffer, isLoading } = useOffers();
useEffect(() => { loadOffer(offerId); }, [offerId]);
if (isLoading) return <p>Loading...</p>;
return (
<div>
<h2>{offer?.title}</h2>
<p>${((offer?.pricing?.amount ?? 0) / 100).toFixed(2)}</p>
<button onClick={() => acceptOffer({ offerId, checkoutSessionId: sessionId })}>
Yes, Add It!
</button>
<button onClick={() => declineOffer({ offerId, checkoutSessionId: sessionId })}>
No Thanks
</button>
</div>
);
}