Skip to content

Commit

Permalink
add chat
Browse files Browse the repository at this point in the history
  • Loading branch information
caroluchoa committed Feb 12, 2024
1 parent 0db8398 commit 7b53531
Show file tree
Hide file tree
Showing 25 changed files with 2,497 additions and 90 deletions.
6 changes: 3 additions & 3 deletions components/minicart/vtex/Cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ function Cart() {
const { cart, loading, updateItems, addCouponsToCart } = useCart();
const { items, totalizers } = cart.value ?? { items: [] };
const total = totalizers?.find((item) => item.id === "Items")?.value || 0;
const discounts = (totalizers?.find((item) => item.id === "Discounts")?.value || 0) * -1;
const discounts =
(totalizers?.find((item) => item.id === "Discounts")?.value || 0) * -1;
const locale = cart.value?.clientPreferencesData.locale ?? "pt-BR";
const currency = cart.value?.storePreferencesData.currencyCode ?? "BRL";
const coupon = cart.value?.marketingData?.coupon ?? undefined;
Expand All @@ -31,8 +32,7 @@ function Cart() {
coupon={coupon}
onAddCoupon={(text) => addCouponsToCart({ text })}
onUpdateQuantity={(quantity, index) =>
updateItems({ orderItems: [{ index, quantity }] })
}
updateItems({ orderItems: [{ index, quantity }] })}
itemToAnalyticsItem={(index) => {
const item = items[index];

Expand Down
12 changes: 9 additions & 3 deletions components/product/AddToCartButton/vtex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ import Button, { Props as BtnProps } from "./common.tsx";
export interface Props extends Omit<BtnProps, "onAddItem"> {
seller: string;
productID: string;
onClick?: () => void;
}

function AddToCartButton({ seller, productID, eventParams }: Props) {
function AddToCartButton({ seller, productID, eventParams, onClick }: Props) {
const { addItems } = useCart();
const onAddItem = () =>
addItems({
const onAddItem = () => {
if (onClick) {
onClick();
}

return addItems({
orderItems: [{
id: productID,
seller: seller,
quantity: 1,
}],
});
};

return <Button onAddItem={onAddItem} eventParams={eventParams} />;
}
Expand Down
Loading

0 comments on commit 7b53531

Please sign in to comment.