Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(composables): new total price property for useCartItem composable #168

Merged
merged 6 commits into from
Apr 26, 2023

Conversation

mkucmus
Copy link
Collaborator

@mkucmus mkucmus commented Apr 24, 2023

Description

closes: #157

const { itemTotalPrice } = useCartItem(cartItem);

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Screenshots (if applicable)

image

Additional context

@vercel
Copy link

vercel bot commented Apr 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontends-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2023 6:34am
shopware-frontends-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2023 6:34am

Copy link
Collaborator

@patzick patzick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good, some suggestions left for improvements

Comment on lines 118 to 119
await removeCartItem(cartItem.value.id, apiInstance);
refreshCart();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cart operation is returning cart, what would you say to do something like this?

Suggested change
await removeCartItem(cartItem.value.id, apiInstance);
refreshCart();
const newCart = await removeCartItem(cartItem.value.id, apiInstance);
await refreshCart(newCart);

and then in useCart

async function refreshCart(newCart?: Cart): Promise<Cart> {
    if (newCart) {
      _storeCart.value = newCart;
      return newCart;
    }
    const result = await getCart(apiInstance);
    _storeCart.value = result;
    return result;
  }

so we can skip additional server request?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good improvement. I will do 🚀

}

/**
* @deprecated Method is not used anymore and the case should be solved on project level instead due to performance reasons.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add patch changeset entry for that

import { getSmallestThumbnailUrl } from "@shopware-pwa/helpers-next";
import { LineItem } from "@shopware-pwa/types";
import { getSmallestThumbnailUrl } from "@shopware-pwa/helpers-next";
import { LineItem } from "@shopware-pwa/types";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

script setup components have formatting from the first line without tabs, can you make sure you formatted this file? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk why but I had a prettier as default formatter. Switched back to volar and works good as expected :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] useCartItem composable returns invalid values
2 participants