Skip to content

Commit

Permalink
Generate only the necessary data
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Apr 6, 2023
1 parent 2b9c94f commit 8fff0e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
2 changes: 1 addition & 1 deletion import_map.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"imports": {
"$store/": "./",
"$live/": "https://denopkg.com/deco-cx/live@1793c3980d9244aac8da841a90da40dad5b37a68/",
"$live/": "https://denopkg.com/deco-cx/live@3a0864dffc10e001f8b170e3504dd89fe9ad9b21/",
"deco-sites/std/": "https://denopkg.com/deco-sites/[email protected]/",
"partytown/": "https://deno.land/x/[email protected]/",
"$fresh/": "https://deno.land/x/[email protected]/",
Expand Down
29 changes: 2 additions & 27 deletions schemas.gen.json
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,7 @@
],
"title": "deco-sites/fashion/components/ui/BannerGrid.tsx@Props"
},
"ZGVjby1zaXRlcy9mYXNoaW9uL3NlY3Rpb25zL1Z0ZXhQcm9kdWN0U2hlbGYudHN4@Props": {
"ZGVjby1zaXRlcy9mYXNoaW9uL2NvbXBvbmVudHMvcHJvZHVjdC9Qcm9kdWN0U2hlbGYudHN4@Props": {
"type": "object",
"properties": {
"title": {
Expand All @@ -2625,7 +2625,7 @@
"ZGVjby1zaXRlcy9mYXNoaW9uL3NlY3Rpb25zL1Z0ZXhQcm9kdWN0U2hlbGYudHN4@Props&Props": {
"allOf": [
{
"$ref": "#/definitions/ZGVjby1zaXRlcy9mYXNoaW9uL3NlY3Rpb25zL1Z0ZXhQcm9kdWN0U2hlbGYudHN4@Props"
"$ref": "#/definitions/ZGVjby1zaXRlcy9mYXNoaW9uL2NvbXBvbmVudHMvcHJvZHVjdC9Qcm9kdWN0U2hlbGYudHN4@Props"
},
{
"$ref": "#/definitions/ZGVjby1zaXRlcy9zdGQvZnVuY3Rpb25zL3Z0ZXhQcm9kdWN0TGlzdC50cw==@Props"
Expand Down Expand Up @@ -2684,31 +2684,6 @@
],
"title": "deco-sites/fashion/components/search/SearchResult.tsx@Props"
},
"ZGVjby1zaXRlcy9mYXNoaW9uL2NvbXBvbmVudHMvcHJvZHVjdC9Qcm9kdWN0U2hlbGYudHN4@Props": {
"type": "object",
"properties": {
"title": {
"type": "string",
"title": "Title"
},
"products": {
"$ref": "#/definitions/ZGVjby1zaXRlcy9zdGQvY29tbWVyY2UvdHlwZXMudHM=@Product[]|null",
"title": "Products"
},
"itemsPerPage": {
"type": [
"number",
"null"
],
"title": "Items Per Page"
}
},
"required": [
"title",
"products"
],
"title": "deco-sites/fashion/components/product/ProductShelf.tsx@Props"
},
"ZGVjby1zaXRlcy9mYXNoaW9uL2NvbXBvbmVudHMvZm9vdGVyL0Zvb3Rlci50c3g=@StringItem": {
"type": "object",
"properties": {
Expand Down
12 changes: 3 additions & 9 deletions sections/VtexProductShelf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import { HandlerContext } from "$fresh/src/server/types.ts";
import ProductShelf, {
Props as ProductShelfProps,
} from "$store/components/product/ProductShelf.tsx";
import { Product } from "deco-sites/std/commerce/types.ts";
import { StateVTEX } from "deco-sites/std/commerce/vtex/types.ts";
import loader, {
Props as LoaderProps,
} from "deco-sites/std/functions/vtexProductList.ts";
import { LiveConfig } from "https://denopkg.com/deco-cx/[email protected]/blocks/handler.ts";

export interface Props {
title: string;
itemsPerPage?: number;
}

function ProductShelfSection(props: ProductShelfProps) {
return <ProductShelf {...props} />;
}
Expand All @@ -22,11 +16,11 @@ export async function getProps(
request: Request,
ctx: HandlerContext<
unknown,
LiveConfig<Props & LoaderProps, StateVTEX>
LiveConfig<LoaderProps, StateVTEX>
>,
): Promise<ProductShelfProps> {
): Promise<Pick<ProductShelfProps, "products">> {
const { data: products } = await loader(request, ctx, ctx.state.$live);
return { ...ctx.state.$live, products };
return { products };
}

export default ProductShelfSection;

0 comments on commit 8fff0e5

Please sign in to comment.