From e020a970cd4fdac9c404fffff1cdfac4be02dcb7 Mon Sep 17 00:00:00 2001 From: guitavano Date: Tue, 12 Nov 2024 17:07:10 -0300 Subject: [PATCH] create sales channel loaders --- vtex/loaders/logistics/getSalesChannelById.ts | 22 +++++ .../loaders/logistics/listSalesChannelById.ts | 22 +++++ vtex/manifest.gen.ts | 84 ++++++++++--------- vtex/utils/types.ts | 24 ++++++ 4 files changed, 112 insertions(+), 40 deletions(-) create mode 100644 vtex/loaders/logistics/getSalesChannelById.ts create mode 100644 vtex/loaders/logistics/listSalesChannelById.ts diff --git a/vtex/loaders/logistics/getSalesChannelById.ts b/vtex/loaders/logistics/getSalesChannelById.ts new file mode 100644 index 000000000..a4141c5f1 --- /dev/null +++ b/vtex/loaders/logistics/getSalesChannelById.ts @@ -0,0 +1,22 @@ +import type { AppContext } from "../../mod.ts"; +import { SalesChannel } from "../../utils/types.ts"; + +interface Props { + id: string; +} + +export default async function loader( + props: Props, + _req: Request, + ctx: AppContext, +): Promise { + const { vcs } = ctx; + + const salesChannel = await vcs + ["GET /api/catalog_system/pub/saleschannel/:salesChannelId"]({ + salesChannelId: props.id, + }) + .then((r) => r.json()); + + return salesChannel; +} diff --git a/vtex/loaders/logistics/listSalesChannelById.ts b/vtex/loaders/logistics/listSalesChannelById.ts new file mode 100644 index 000000000..cccb48e60 --- /dev/null +++ b/vtex/loaders/logistics/listSalesChannelById.ts @@ -0,0 +1,22 @@ +import type { AppContext } from "../../mod.ts"; +import { SalesChannel } from "../../utils/types.ts"; + +interface Props { + id: string; +} + +export default async function loader( + props: Props, + _req: Request, + ctx: AppContext, +): Promise { + const { vcs } = ctx; + + const salesChannel = await vcs + ["GET /api/catalog_system/pvt/saleschannel/list"]({ + salesChannelId: props.id, + }) + .then((r) => r.json()); + + return salesChannel; +} diff --git a/vtex/manifest.gen.ts b/vtex/manifest.gen.ts index b8863a721..d05f2f2fa 100644 --- a/vtex/manifest.gen.ts +++ b/vtex/manifest.gen.ts @@ -44,26 +44,28 @@ import * as $$$13 from "./loaders/legacy/productList.ts"; import * as $$$14 from "./loaders/legacy/productListingPage.ts"; 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/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 $$$17 from "./loaders/logistics/getSalesChannelById.ts"; +import * as $$$18 from "./loaders/logistics/listPickupPoints.ts"; +import * as $$$19 from "./loaders/logistics/listPickupPointsByLocation.ts"; +import * as $$$20 from "./loaders/logistics/listSalesChannelById.ts"; +import * as $$$21 from "./loaders/logistics/listStockByStore.ts"; +import * as $$$22 from "./loaders/masterdata/searchDocuments.ts"; +import * as $$$23 from "./loaders/navbar.ts"; +import * as $$$24 from "./loaders/options/productIdByTerm.ts"; +import * as $$$25 from "./loaders/orders/list.ts"; +import * as $$$26 from "./loaders/paths/PDPDefaultPath.ts"; +import * as $$$27 from "./loaders/paths/PLPDefaultPath.ts"; +import * as $$$28 from "./loaders/product/extend.ts"; +import * as $$$29 from "./loaders/product/extensions/detailsPage.ts"; +import * as $$$30 from "./loaders/product/extensions/list.ts"; +import * as $$$31 from "./loaders/product/extensions/listingPage.ts"; +import * as $$$32 from "./loaders/product/extensions/suggestions.ts"; +import * as $$$33 from "./loaders/product/wishlist.ts"; +import * as $$$34 from "./loaders/proxy.ts"; +import * as $$$35 from "./loaders/user.ts"; +import * as $$$36 from "./loaders/wishlist.ts"; +import * as $$$37 from "./loaders/workflow/product.ts"; +import * as $$$38 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"; @@ -87,26 +89,28 @@ const manifest = { "vtex/loaders/legacy/productListingPage.ts": $$$14, "vtex/loaders/legacy/relatedProductsLoader.ts": $$$15, "vtex/loaders/legacy/suggestions.ts": $$$16, - "vtex/loaders/logistics/listPickupPoints.ts": $$$17, - "vtex/loaders/logistics/listPickupPointsByLocation.ts": $$$18, - "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, + "vtex/loaders/logistics/getSalesChannelById.ts": $$$17, + "vtex/loaders/logistics/listPickupPoints.ts": $$$18, + "vtex/loaders/logistics/listPickupPointsByLocation.ts": $$$19, + "vtex/loaders/logistics/listSalesChannelById.ts": $$$20, + "vtex/loaders/logistics/listStockByStore.ts": $$$21, + "vtex/loaders/masterdata/searchDocuments.ts": $$$22, + "vtex/loaders/navbar.ts": $$$23, + "vtex/loaders/options/productIdByTerm.ts": $$$24, + "vtex/loaders/orders/list.ts": $$$25, + "vtex/loaders/paths/PDPDefaultPath.ts": $$$26, + "vtex/loaders/paths/PLPDefaultPath.ts": $$$27, + "vtex/loaders/product/extend.ts": $$$28, + "vtex/loaders/product/extensions/detailsPage.ts": $$$29, + "vtex/loaders/product/extensions/list.ts": $$$30, + "vtex/loaders/product/extensions/listingPage.ts": $$$31, + "vtex/loaders/product/extensions/suggestions.ts": $$$32, + "vtex/loaders/product/wishlist.ts": $$$33, + "vtex/loaders/proxy.ts": $$$34, + "vtex/loaders/user.ts": $$$35, + "vtex/loaders/wishlist.ts": $$$36, + "vtex/loaders/workflow/product.ts": $$$37, + "vtex/loaders/workflow/products.ts": $$$38, }, "handlers": { "vtex/handlers/sitemap.ts": $$$$0, diff --git a/vtex/utils/types.ts b/vtex/utils/types.ts index 0fedd1893..0aafb0740 100644 --- a/vtex/utils/types.ts +++ b/vtex/utils/types.ts @@ -1339,3 +1339,27 @@ export interface Orders { }; }; } + +export interface SalesChannel { + Id?: number; + Name?: string; + IsActive?: boolean; + ProductClusterId?: number | null; + CountryCode?: string; + CultureInfo?: string; + TimeZone?: string; + CurrencyCode?: string; + CurrencySymbol?: string; + CurrencyLocale?: number; + CurrencyFormatInfo?: { + CurrencyDecimalDigits?: number; + CurrencyDecimalSeparator?: string; + CurrencyGroupSeparator?: string; + CurrencyGroupSize?: number; + StartsWithCurrencySymbol?: boolean; + }; + Origin?: string | null; + Position?: number | null; + ConditionRule?: string | null; + CurrencyDecimalDigits?: number; +}