Skip to content

Commit

Permalink
notify-me (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes authored May 16, 2023
1 parent 981ef79 commit 4996498
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 34 deletions.
1 change: 1 addition & 0 deletions actions/vtex/notifyme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "deco-sites/std/packs/vtex/actions/notifyme.ts";
2 changes: 1 addition & 1 deletion import_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"@preact/signals-core": "https://esm.sh/*@preact/[email protected]",
"std/": "https://deno.land/[email protected]/"
}
}
}
62 changes: 32 additions & 30 deletions live.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,22 @@ import * as $$$$$$$$6 from "./sections/configShopify.global.tsx";
import * as $$$$$$$$7 from "./sections/configVNDA.global.tsx";
import * as $$$$$$$$8 from "./sections/configVTEX.global.tsx";
import * as $$$$$$$$9 from "./sections/SEOPDP.tsx";
import * as $$$$$$$$$$$0 from "./actions/vtex/cart/updateCoupons.ts";
import * as $$$$$$$$$$$1 from "./actions/vtex/cart/updateAttachment.ts";
import * as $$$$$$$$$$$2 from "./actions/vtex/cart/updateItems.ts";
import * as $$$$$$$$$$$3 from "./actions/vtex/cart/updateItemAttachment.ts";
import * as $$$$$$$$$$$4 from "./actions/vtex/cart/updateUser.ts";
import * as $$$$$$$$$$$5 from "./actions/vtex/cart/addItems.ts";
import * as $$$$$$$$$$$6 from "./actions/vtex/cart/removeItems.ts";
import * as $$$$$$$$$$$7 from "./actions/vtex/cart/getInstallment.ts";
import * as $$$$$$$$$$$8 from "./actions/vtex/cart/updateItemPrice.ts";
import * as $$$$$$$$$$$9 from "./actions/vtex/cart/updateProfile.ts";
import * as $$$$$$$$$$$10 from "./actions/vtex/cart/simulation.ts";
import * as $$$$$$$$$$$11 from "./actions/vtex/cart/removeItemAttachment.ts";
import * as $$$$$$$$$$$12 from "./actions/vtex/newsletter/subscribe.ts";
import * as $$$$$$$$$$$13 from "./actions/vtex/wishlist/removeItem.ts";
import * as $$$$$$$$$$$14 from "./actions/vtex/wishlist/addItem.ts";
import * as $$$$$$$$$$$0 from "./actions/vtex/notifyme.ts";
import * as $$$$$$$$$$$1 from "./actions/vtex/cart/updateCoupons.ts";
import * as $$$$$$$$$$$2 from "./actions/vtex/cart/updateAttachment.ts";
import * as $$$$$$$$$$$3 from "./actions/vtex/cart/updateItems.ts";
import * as $$$$$$$$$$$4 from "./actions/vtex/cart/updateItemAttachment.ts";
import * as $$$$$$$$$$$5 from "./actions/vtex/cart/updateUser.ts";
import * as $$$$$$$$$$$6 from "./actions/vtex/cart/addItems.ts";
import * as $$$$$$$$$$$7 from "./actions/vtex/cart/removeItems.ts";
import * as $$$$$$$$$$$8 from "./actions/vtex/cart/getInstallment.ts";
import * as $$$$$$$$$$$9 from "./actions/vtex/cart/updateItemPrice.ts";
import * as $$$$$$$$$$$10 from "./actions/vtex/cart/updateProfile.ts";
import * as $$$$$$$$$$$11 from "./actions/vtex/cart/simulation.ts";
import * as $$$$$$$$$$$12 from "./actions/vtex/cart/removeItemAttachment.ts";
import * as $$$$$$$$$$$13 from "./actions/vtex/newsletter/subscribe.ts";
import * as $$$$$$$$$$$14 from "./actions/vtex/wishlist/removeItem.ts";
import * as $$$$$$$$$$$15 from "./actions/vtex/wishlist/addItem.ts";
import * as $live_middleware from "$live/routes/_middleware.ts";
import * as $live_workbench from "$live/routes/live/workbench.ts";
import * as $live_invoke from "$live/routes/live/invoke/index.ts";
Expand Down Expand Up @@ -199,21 +200,22 @@ const manifest = {
"$live/actions/workflows/run.ts": i1$$$$$$$1,
"$live/actions/workflows/signal.ts": i1$$$$$$$2,
"$live/actions/workflows/start.ts": i1$$$$$$$3,
"deco-sites/std/actions/vtex/cart/addItems.ts": $$$$$$$$$$$5,
"deco-sites/std/actions/vtex/cart/getInstallment.ts": $$$$$$$$$$$7,
"deco-sites/std/actions/vtex/cart/removeItemAttachment.ts": $$$$$$$$$$$11,
"deco-sites/std/actions/vtex/cart/removeItems.ts": $$$$$$$$$$$6,
"deco-sites/std/actions/vtex/cart/simulation.ts": $$$$$$$$$$$10,
"deco-sites/std/actions/vtex/cart/updateAttachment.ts": $$$$$$$$$$$1,
"deco-sites/std/actions/vtex/cart/updateCoupons.ts": $$$$$$$$$$$0,
"deco-sites/std/actions/vtex/cart/updateItemAttachment.ts": $$$$$$$$$$$3,
"deco-sites/std/actions/vtex/cart/updateItemPrice.ts": $$$$$$$$$$$8,
"deco-sites/std/actions/vtex/cart/updateItems.ts": $$$$$$$$$$$2,
"deco-sites/std/actions/vtex/cart/updateProfile.ts": $$$$$$$$$$$9,
"deco-sites/std/actions/vtex/cart/updateUser.ts": $$$$$$$$$$$4,
"deco-sites/std/actions/vtex/newsletter/subscribe.ts": $$$$$$$$$$$12,
"deco-sites/std/actions/vtex/wishlist/addItem.ts": $$$$$$$$$$$14,
"deco-sites/std/actions/vtex/wishlist/removeItem.ts": $$$$$$$$$$$13,
"deco-sites/std/actions/vtex/cart/addItems.ts": $$$$$$$$$$$6,
"deco-sites/std/actions/vtex/cart/getInstallment.ts": $$$$$$$$$$$8,
"deco-sites/std/actions/vtex/cart/removeItemAttachment.ts": $$$$$$$$$$$12,
"deco-sites/std/actions/vtex/cart/removeItems.ts": $$$$$$$$$$$7,
"deco-sites/std/actions/vtex/cart/simulation.ts": $$$$$$$$$$$11,
"deco-sites/std/actions/vtex/cart/updateAttachment.ts": $$$$$$$$$$$2,
"deco-sites/std/actions/vtex/cart/updateCoupons.ts": $$$$$$$$$$$1,
"deco-sites/std/actions/vtex/cart/updateItemAttachment.ts": $$$$$$$$$$$4,
"deco-sites/std/actions/vtex/cart/updateItemPrice.ts": $$$$$$$$$$$9,
"deco-sites/std/actions/vtex/cart/updateItems.ts": $$$$$$$$$$$3,
"deco-sites/std/actions/vtex/cart/updateProfile.ts": $$$$$$$$$$$10,
"deco-sites/std/actions/vtex/cart/updateUser.ts": $$$$$$$$$$$5,
"deco-sites/std/actions/vtex/newsletter/subscribe.ts": $$$$$$$$$$$13,
"deco-sites/std/actions/vtex/notifyme.ts": $$$$$$$$$$$0,
"deco-sites/std/actions/vtex/wishlist/addItem.ts": $$$$$$$$$$$15,
"deco-sites/std/actions/vtex/wishlist/removeItem.ts": $$$$$$$$$$$14,
},
"handlers": {
"$live/handlers/devPage.ts": i1$$0,
Expand Down
37 changes: 37 additions & 0 deletions packs/vtex/actions/notifyme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { paths } from "../utils/paths.ts";
import { fetchSafe } from "deco-sites/std/utils/fetch.ts";
import type { Context } from "deco-sites/std/packs/vtex/accounts/vtex.ts";
import type { OrderForm } from "deco-sites/std/packs/vtex/types.ts";

export interface Props {
email: string;
skuId: string;
name?: string;
}

/**
* @docs https://developers.vtex.com/docs/api-reference/checkout-api#post-/api/checkout/pub/orderForm/-orderFormId-/items
*/
const action = async (
props: Props,
_req: Request,
ctx: Context,
): Promise<OrderForm> => {
const { configVTEX: config } = ctx;
const url = new URL(`${paths(config!)["no-cache"]["AviseMe.aspx"]}`);
const form = new FormData();
const { email, skuId, name = "" } = props;

form.append("notifymeClientName", name);
form.append("notifymeClientEmail", email);
form.append("notifymeIdSku", skuId);

const response = await fetchSafe(url, {
method: "POST",
body: form,
});

return response.json();
};

export default action;
1 change: 1 addition & 0 deletions packs/vtex/utils/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const paths = ({ account }: Account) => {
return {
"no-cache": {
"Newsletter.aspx": `${href(`/no-cache/Newsletter.aspx`)}`,
"AviseMe.aspx": `${href("/no-cache/AviseMe.aspx")}`,
},
api: {
catalog_system: {
Expand Down
66 changes: 63 additions & 3 deletions schemas.gen.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"deco-sites/std/actions/vtex/cart/updateProfile.ts",
"deco-sites/std/actions/vtex/cart/updateUser.ts",
"deco-sites/std/actions/vtex/newsletter/subscribe.ts",
"deco-sites/std/actions/vtex/notifyme.ts",
"deco-sites/std/actions/vtex/wishlist/addItem.ts",
"deco-sites/std/actions/vtex/wishlist/removeItem.ts"
]
Expand Down Expand Up @@ -7751,8 +7752,18 @@
"type": "string",
"title": "Email"
},
"name": {
"type": [
"string",
"null"
],
"title": "Name"
},
"page": {
"type": "string",
"type": [
"string",
"null"
],
"title": "Page"
},
"part": {
Expand All @@ -7771,11 +7782,35 @@
}
},
"required": [
"email",
"page"
"email"
],
"title": "deco-sites/std/packs/vtex/actions/newletter/subscribe.ts@Props"
},
"ZGVjby1zaXRlcy9zdGQvcGFja3MvdnRleC9hY3Rpb25zL25vdGlmeW1lLnRz@Props": {
"type": "object",
"properties": {
"email": {
"type": "string",
"title": "Email"
},
"skuId": {
"type": "string",
"title": "Sku Id"
},
"name": {
"type": [
"string",
"null"
],
"title": "Name"
}
},
"required": [
"email",
"skuId"
],
"title": "deco-sites/std/packs/vtex/actions/notifyme.ts@Props"
},
"ZGVjby1zaXRlcy9zdGQvcGFja3MvdnRleC9hY3Rpb25zL3dpc2hsaXN0L2FkZEl0ZW0udHM=@Props": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -9761,6 +9796,28 @@
}
}
},
"ZGVjby1zaXRlcy9zdGQvYWN0aW9ucy92dGV4L25vdGlmeW1lLnRz": {
"title": "deco-sites/std/actions/vtex/notifyme.ts",
"docs": "https://developers.vtex.com/docs/api-reference/checkout-api#post-/api/checkout/pub/orderForm/-orderFormId-/items",
"type": "object",
"allOf": [
{
"$ref": "#/definitions/ZGVjby1zaXRlcy9zdGQvcGFja3MvdnRleC9hY3Rpb25zL25vdGlmeW1lLnRz@Props"
}
],
"required": [
"__resolveType"
],
"properties": {
"__resolveType": {
"type": "string",
"enum": [
"deco-sites/std/actions/vtex/notifyme.ts"
],
"default": "deco-sites/std/actions/vtex/notifyme.ts"
}
}
},
"ZGVjby1zaXRlcy9zdGQvYWN0aW9ucy92dGV4L3dpc2hsaXN0L2FkZEl0ZW0udHM=": {
"title": "deco-sites/std/actions/vtex/wishlist/addItem.ts",
"type": "object",
Expand Down Expand Up @@ -10190,6 +10247,9 @@
{
"$ref": "#/definitions/ZGVjby1zaXRlcy9zdGQvYWN0aW9ucy92dGV4L25ld3NsZXR0ZXIvc3Vic2NyaWJlLnRz"
},
{
"$ref": "#/definitions/ZGVjby1zaXRlcy9zdGQvYWN0aW9ucy92dGV4L25vdGlmeW1lLnRz"
},
{
"$ref": "#/definitions/ZGVjby1zaXRlcy9zdGQvYWN0aW9ucy92dGV4L3dpc2hsaXN0L2FkZEl0ZW0udHM="
},
Expand Down

0 comments on commit 4996498

Please sign in to comment.