41 lines
830 B
React
41 lines
830 B
React
import { useShop } from "../shop/useShop";
|
|
import "./ShopDrawer.css";
|
|
|
|
function CartToast() {
|
|
const {
|
|
cartToast,
|
|
dismissToast,
|
|
openCart,
|
|
openProfile,
|
|
} = useShop();
|
|
|
|
if (!cartToast) return null;
|
|
|
|
const runAction = () => {
|
|
dismissToast();
|
|
if (cartToast.actionPanel === "cart") {
|
|
openCart();
|
|
}
|
|
if (cartToast.actionPanel === "profile") {
|
|
openProfile();
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="cart-toast">
|
|
<button className="cart-toast-close" type="button" onClick={dismissToast}>
|
|
x
|
|
</button>
|
|
<strong>{cartToast.title}</strong>
|
|
<p>{cartToast.message}</p>
|
|
{cartToast.actionLabel && (
|
|
<button type="button" onClick={runAction}>
|
|
{cartToast.actionLabel}
|
|
</button>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default CartToast;
|