Giter Site home page Giter Site logo

Comments (5)

michaelbromley avatar michaelbromley commented on August 14, 2024 1

@benjamin-corailfactory I recently have been updating our docs, you might find this guide helpful: https://beta-docs.vendure.io/guides/storefront/listing-products/#listing-products-in-a-collection

from storefront-qwik-starter.

gioboa avatar gioboa commented on August 14, 2024

Hi @benjamin-corailfactory, with GraphQL we load products by category and then we loop through them.
Here is the code
In the search variable we stored the GraphQL response

from storefront-qwik-starter.

benjamin-corailfactory avatar benjamin-corailfactory commented on August 14, 2024

Hi @gioboa,
Sorry, I've just started react ... And I try your storefront-qwik-starter.

I tried to refactor as component (<CollectionItems collection={collection} />)
But I have problem with : searchSignal.value ...
Do you have any idea ?

import { component$, useStore } from '@builder.io/qwik';
import { Collection } from '~/generated/graphql';
import ProductCard from '~/components/products/ProductCard';
import { SearchResponse } from '~/generated/graphql';
import {
	searchQueryWithCollectionSlug,
} from '~/providers/shop/products/products';


interface IProps {
	collection: Collection;
}

export async function useSearchLoader(slug: any) {
        return await searchQueryWithCollectionSlug(slug);
}

export default component$(({ collection }: IProps) => 
{

	const searchSignal = useSearchLoader(collection.slug);

	const state = useStore<{
		search: SearchResponse;
	}>({
		search: searchSignal.value as SearchResponse,
	});


	return (
		
				<div class="sm:col-span-5 lg:col-span-4">
					<div class="grid grid-cols-1 gap-y-10 gap-x-6 sm:grid-cols-2 lg:grid-cols-4 xl:gap-x-8">
						{state.search.items.map((item) => (
							<ProductCard
								key={item.productId}
								productAsset={item.productAsset}
								productName={item.productName}
								slug={item.slug}
								priceWithTax={item.priceWithTax}
								currencyCode={item.currencyCode}
							></ProductCard>
						))}
					</div>
				</div>

	);
});

Thanks, and ... sorry (I'm sure it's a silly mistake)

from storefront-qwik-starter.

gioboa avatar gioboa commented on August 14, 2024

Have you got a public repo with this project?

from storefront-qwik-starter.

benjamin-corailfactory avatar benjamin-corailfactory commented on August 14, 2024

@gioboa No, sorry... I'm not at that stage yet. But the structure is exactly the same. No big changes. Just this file in the components. Thanks

from storefront-qwik-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.