Skip to content

Commit

Permalink
feat: implement loader promotion VTEX (#988)
Browse files Browse the repository at this point in the history
* feat: implement loader promotion VTEX

* fix: remove blog and konfidency from PR

* fix: konfidency and blog

* fix: space

* Update vtex/loaders/promotion/getPromotionById.ts

Co-authored-by: Luis Sousa <lv-ss@hotmail.com>

---------

Co-authored-by: Luis Sousa <lv-ss@hotmail.com>
  • Loading branch information
gabriel-kerchner and IncognitaDev authored Jan 21, 2025
1 parent c0dc1d9 commit 30d1d4e
Show file tree
Hide file tree
Showing 5 changed files with 1,679 additions and 10 deletions.
35 changes: 35 additions & 0 deletions vtex/loaders/promotion/getPromotionById.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { AppContext } from "../../mod.ts";
import type { Document } from "../../utils/types.ts";
import { parseCookie } from "../../utils/vtexId.ts";

interface Props {
/**
* @description Promotion ID.
*/
idCalculatorConfiguration: string;
}

export const defaultVisibility = 'private'

export default async function loader(
props: Props,
req: Request,
ctx: AppContext,
): Promise<Document[]> {
const { vcs } = ctx;
const { idCalculatorConfiguration } = props;
const { cookie } = parseCookie(req.headers, ctx.account);

const promotionById = await vcs
["GET /api/rnb/pvt/calculatorconfiguration/:idCalculatorConfiguration"]({
idCalculatorConfiguration,
}, {
headers: {
accept: "application/json",
"content-type": "application/json",
cookie,
},
}).then((response: Response) => response.json());

return promotionById;
}
22 changes: 12 additions & 10 deletions vtex/manifest.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ 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 $$$34 from "./loaders/promotion/getPromotionById.ts";
import * as $$$35 from "./loaders/proxy.ts";
import * as $$$36 from "./loaders/user.ts";
import * as $$$37 from "./loaders/wishlist.ts";
import * as $$$38 from "./loaders/workflow/product.ts";
import * as $$$39 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 Down Expand Up @@ -106,11 +107,12 @@ const manifest = {
"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,
"vtex/loaders/promotion/getPromotionById.ts": $$$34,
"vtex/loaders/proxy.ts": $$$35,
"vtex/loaders/user.ts": $$$36,
"vtex/loaders/wishlist.ts": $$$37,
"vtex/loaders/workflow/product.ts": $$$38,
"vtex/loaders/workflow/products.ts": $$$39,
},
"handlers": {
"vtex/handlers/sitemap.ts": $$$$0,
Expand Down
Loading

0 comments on commit 30d1d4e

Please sign in to comment.