Skip to content

Commit

Permalink
fix(composables): adds parameter to loadMore to accept an optional qu…
Browse files Browse the repository at this point in the history
…ery (#380)
  • Loading branch information
Dominik authored Sep 4, 2023
1 parent bd88d6f commit b2b6905
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-cameras-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-pwa/composables-next": patch
---

Adds the ability to specify a query for the loadMore function in the useListing composable.
20 changes: 12 additions & 8 deletions packages/composables/src/useListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export type UseListingReturn<ELEMENTS_TYPE> = {
/**
* Loads more (next page) elements to the listing
*/
loadMore(): Promise<void>;
loadMore(query?: Partial<ShopwareSearchParams>): Promise<void>;
/**
* Listing that is currently set
*/
Expand Down Expand Up @@ -305,15 +305,19 @@ export function createListingComposable<ELEMENTS_TYPE>({
}
}

const loadMore = async (): Promise<void> => {
const loadMore = async (
query?: Partial<ShopwareSearchParams>,
): Promise<void> => {
loadingMore.value = true;
try {
const query = {
// ...router.currentRoute.query,
p: getCurrentPage.value + 1,
};

const searchCriteria = merge({}, searchDefaults, query);
const q = query
? query
: {
// ...router.currentRoute.query,
p: getCurrentPage.value + 1,
};

const searchCriteria = merge({}, searchDefaults, q);
const result = await searchMethod(searchCriteria);
_storeAppliedListing.value = {
...getCurrentListing.value,
Expand Down

2 comments on commit b2b6905

@vercel
Copy link

@vercel vercel bot commented on b2b6905 Sep 4, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on b2b6905 Sep 4, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

frontends-demo – ./templates/vue-demo-store

frontends-demo.vercel.app
frontends-demo-git-main-shopware-frontends.vercel.app
frontends-demo-shopware-frontends.vercel.app

Please sign in to comment.