From 4176a56618837f7c4171682640a8e09b11bf1457 Mon Sep 17 00:00:00 2001 From: Fernando Souto <90011575+soutofernando@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:08:38 -0300 Subject: [PATCH] [WIP]: loader stock by store (#911) * feat: loader to pick up stock by store * deno check --- vtex/loaders/logistics/listStockByStore.ts | 32 ++++++++++ vtex/manifest.gen.ts | 70 +++++++++++----------- 2 files changed, 68 insertions(+), 34 deletions(-) create mode 100644 vtex/loaders/logistics/listStockByStore.ts diff --git a/vtex/loaders/logistics/listStockByStore.ts b/vtex/loaders/logistics/listStockByStore.ts new file mode 100644 index 000000000..4e97209e0 --- /dev/null +++ b/vtex/loaders/logistics/listStockByStore.ts @@ -0,0 +1,32 @@ +import type { AppContext } from "../../mod.ts"; +import type { ProductBalance } from "../../utils/types.ts"; + +interface Props { + /** + * @description Product SKU + */ + skuId: number; +} + +export default async function loader( + props: Props, + _req: Request, + ctx: AppContext, +): Promise { + const { skuId } = props; + const { vcs } = ctx; + + try { + const stockByStore = await vcs + ["GET /api/logistics/pvt/inventory/skus/:skuId"]({ skuId }) + .then((r) => r.json()) as { + skuId?: string; + balance?: ProductBalance[]; + }; + + return stockByStore.balance || []; + } catch (error) { + console.log(error); + return []; + } +} diff --git a/vtex/manifest.gen.ts b/vtex/manifest.gen.ts index a0f0c0ca2..b8863a721 100644 --- a/vtex/manifest.gen.ts +++ b/vtex/manifest.gen.ts @@ -46,23 +46,24 @@ import * as $$$15 from "./loaders/legacy/relatedProductsLoader.ts"; import * as $$$16 from "./loaders/legacy/suggestions.ts"; import * as $$$17 from "./loaders/logistics/listPickupPoints.ts"; import * as $$$18 from "./loaders/logistics/listPickupPointsByLocation.ts"; -import * as $$$19 from "./loaders/masterdata/searchDocuments.ts"; -import * as $$$20 from "./loaders/navbar.ts"; -import * as $$$21 from "./loaders/options/productIdByTerm.ts"; -import * as $$$22 from "./loaders/orders/list.ts"; -import * as $$$23 from "./loaders/paths/PDPDefaultPath.ts"; -import * as $$$24 from "./loaders/paths/PLPDefaultPath.ts"; -import * as $$$25 from "./loaders/product/extend.ts"; -import * as $$$26 from "./loaders/product/extensions/detailsPage.ts"; -import * as $$$27 from "./loaders/product/extensions/list.ts"; -import * as $$$28 from "./loaders/product/extensions/listingPage.ts"; -import * as $$$29 from "./loaders/product/extensions/suggestions.ts"; -import * as $$$30 from "./loaders/product/wishlist.ts"; -import * as $$$31 from "./loaders/proxy.ts"; -import * as $$$32 from "./loaders/user.ts"; -import * as $$$33 from "./loaders/wishlist.ts"; -import * as $$$34 from "./loaders/workflow/product.ts"; -import * as $$$35 from "./loaders/workflow/products.ts"; +import * as $$$19 from "./loaders/logistics/listStockByStore.ts"; +import * as $$$20 from "./loaders/masterdata/searchDocuments.ts"; +import * as $$$21 from "./loaders/navbar.ts"; +import * as $$$22 from "./loaders/options/productIdByTerm.ts"; +import * as $$$23 from "./loaders/orders/list.ts"; +import * as $$$24 from "./loaders/paths/PDPDefaultPath.ts"; +import * as $$$25 from "./loaders/paths/PLPDefaultPath.ts"; +import * as $$$26 from "./loaders/product/extend.ts"; +import * as $$$27 from "./loaders/product/extensions/detailsPage.ts"; +import * as $$$28 from "./loaders/product/extensions/list.ts"; +import * as $$$29 from "./loaders/product/extensions/listingPage.ts"; +import * as $$$30 from "./loaders/product/extensions/suggestions.ts"; +import * as $$$31 from "./loaders/product/wishlist.ts"; +import * as $$$32 from "./loaders/proxy.ts"; +import * as $$$33 from "./loaders/user.ts"; +import * as $$$34 from "./loaders/wishlist.ts"; +import * as $$$35 from "./loaders/workflow/product.ts"; +import * as $$$36 from "./loaders/workflow/products.ts"; import * as $$$$$$0 from "./sections/Analytics/Vtex.tsx"; import * as $$$$$$$$$$0 from "./workflows/events.ts"; import * as $$$$$$$$$$1 from "./workflows/product/index.ts"; @@ -88,23 +89,24 @@ const manifest = { "vtex/loaders/legacy/suggestions.ts": $$$16, "vtex/loaders/logistics/listPickupPoints.ts": $$$17, "vtex/loaders/logistics/listPickupPointsByLocation.ts": $$$18, - "vtex/loaders/masterdata/searchDocuments.ts": $$$19, - "vtex/loaders/navbar.ts": $$$20, - "vtex/loaders/options/productIdByTerm.ts": $$$21, - "vtex/loaders/orders/list.ts": $$$22, - "vtex/loaders/paths/PDPDefaultPath.ts": $$$23, - "vtex/loaders/paths/PLPDefaultPath.ts": $$$24, - "vtex/loaders/product/extend.ts": $$$25, - "vtex/loaders/product/extensions/detailsPage.ts": $$$26, - "vtex/loaders/product/extensions/list.ts": $$$27, - "vtex/loaders/product/extensions/listingPage.ts": $$$28, - "vtex/loaders/product/extensions/suggestions.ts": $$$29, - "vtex/loaders/product/wishlist.ts": $$$30, - "vtex/loaders/proxy.ts": $$$31, - "vtex/loaders/user.ts": $$$32, - "vtex/loaders/wishlist.ts": $$$33, - "vtex/loaders/workflow/product.ts": $$$34, - "vtex/loaders/workflow/products.ts": $$$35, + "vtex/loaders/logistics/listStockByStore.ts": $$$19, + "vtex/loaders/masterdata/searchDocuments.ts": $$$20, + "vtex/loaders/navbar.ts": $$$21, + "vtex/loaders/options/productIdByTerm.ts": $$$22, + "vtex/loaders/orders/list.ts": $$$23, + "vtex/loaders/paths/PDPDefaultPath.ts": $$$24, + "vtex/loaders/paths/PLPDefaultPath.ts": $$$25, + "vtex/loaders/product/extend.ts": $$$26, + "vtex/loaders/product/extensions/detailsPage.ts": $$$27, + "vtex/loaders/product/extensions/list.ts": $$$28, + "vtex/loaders/product/extensions/listingPage.ts": $$$29, + "vtex/loaders/product/extensions/suggestions.ts": $$$30, + "vtex/loaders/product/wishlist.ts": $$$31, + "vtex/loaders/proxy.ts": $$$32, + "vtex/loaders/user.ts": $$$33, + "vtex/loaders/wishlist.ts": $$$34, + "vtex/loaders/workflow/product.ts": $$$35, + "vtex/loaders/workflow/products.ts": $$$36, }, "handlers": { "vtex/handlers/sitemap.ts": $$$$0,