blob: 7498443f67f66e8b1df9eaf7d121732bd9e86b78 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import { isCartOpen, addCartItem } from '../cartStore';
import type { CartItemDisplayInfo } from '../cartStore';
import type { ComponentChildren } from 'preact';
type Props = {
item: CartItemDisplayInfo;
children: ComponentChildren;
};
export default function AddToCartForm({ item, children }: Props) {
function addToCart(e: SubmitEvent) {
e.preventDefault();
isCartOpen.set(true);
addCartItem(item);
}
return <form onSubmit={addToCart}>{children}</form>;
}
|