Skip to content

Commit

Permalink
[WIP]: loader stock by store (#911)
Browse files Browse the repository at this point in the history
* feat: loader to pick up stock by store

* deno check
  • Loading branch information
soutofernando authored Oct 22, 2024
1 parent f640cf7 commit 4176a56
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 34 deletions.
32 changes: 32 additions & 0 deletions vtex/loaders/logistics/listStockByStore.ts
Original file line number Diff line number Diff line change
@@ -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<ProductBalance[]> {
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 [];
}
}
70 changes: 36 additions & 34 deletions vtex/manifest.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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,
Expand Down

0 comments on commit 4176a56

Please sign in to comment.