@plurix/ecom-components 1.6.0-commerce.4 → 1.6.0-commerce.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { jsx as n, jsxs as j, Fragment as q } from "react/jsx-runtime";
2
- import { useState as c, useEffect as w } from "react";
1
+ import { jsx as a, jsxs as j, Fragment as q } from "react/jsx-runtime";
2
+ import { useState as u, useEffect as w } from "react";
3
3
  import { Modal as M } from "../Modal/Modal.js";
4
4
  import { ProductSelected as k } from "./components/ProductSelected.js";
5
5
  import { SimilarProducts as v } from "./components/SimilarProducts.js";
@@ -8,78 +8,79 @@ import { ModalFooter as A } from "./components/ModalFooter.js";
8
8
  import { getProductsSimilars as N } from "./api/getProductsSimilars.js";
9
9
  import _ from "../../hooks/useAnalitcsEvents.js";
10
10
  import { getOrderForm as J } from "./api/getOrderForm.js";
11
- const Y = ({
11
+ import { postChangeOrder as L } from "./api/postChangeOrder.js";
12
+ const D = ({
12
13
  selectedItem: o,
13
- postalCode: p,
14
- orderFormId: g,
14
+ postalCode: g,
15
+ orderFormId: c,
15
16
  isClubClient: S,
16
17
  isOpen: h,
17
18
  environment: y,
18
- setIsOpen: m,
19
- saveSelectedSimilarProduct: s
19
+ setIsOpen: e,
20
+ saveSelectedSimilarProduct: d
20
21
  }) => {
21
- const [b, F] = c(), [O, a] = c(!1), d = y === "io", { genericTaggingEvent: P } = _(), [r, e] = c({ productId: "" });
22
+ const [b, O] = u(), [C, s] = u(!1), n = y === "io", { genericTaggingEvent: F } = _(), [r, f] = u({ itemId: "" });
22
23
  return w(() => {
23
24
  (async () => {
24
- a(!0);
25
+ s(!0);
25
26
  try {
26
- const t = await N({
27
- postalCode: p,
27
+ const i = await N({
28
+ postalCode: g,
28
29
  selectedItem: o,
29
- isIO: d
30
+ isIO: n
30
31
  });
31
- F(t == null ? void 0 : t.products);
32
+ O(i == null ? void 0 : i.products);
32
33
  } finally {
33
- a(!1);
34
+ s(!1);
34
35
  }
35
36
  })(), (async () => {
36
- var t, l;
37
- a(!0);
37
+ var i, l;
38
+ s(!0);
38
39
  try {
39
- const u = await J(g), i = ((l = (t = u == null ? void 0 : u.customData) == null ? void 0 : t.customApps) == null ? void 0 : l.find((C) => C.id === "janis")) || null;
40
- let f = {};
41
- i != null && i.fields.idSubstitutionCriterias && (f = JSON.parse(i == null ? void 0 : i.fields.idSubstitutionCriterias));
42
- const x = o == null ? void 0 : o.productOriginId;
43
- e({ productId: `${f[x]}` });
40
+ const m = await J(c, n), t = ((l = (i = m == null ? void 0 : m.customData) == null ? void 0 : i.customApps) == null ? void 0 : l.find((x) => x.id === "janis")) || null;
41
+ let p = {};
42
+ t != null && t.fields.idSubstitutionCriterias && (p = JSON.parse(t == null ? void 0 : t.fields.idSubstitutionCriterias));
43
+ const P = o == null ? void 0 : o.productOriginId;
44
+ f({ itemId: `${p[P]}` });
44
45
  } finally {
45
- a(!1);
46
+ s(!1);
46
47
  }
47
48
  })();
48
- }, []), /* @__PURE__ */ n(
49
+ }, []), /* @__PURE__ */ a(
49
50
  M,
50
51
  {
51
52
  isOpen: h,
52
- setIsOpen: m,
53
+ setIsOpen: e,
53
54
  className: "change-order-modal",
54
55
  title: "Produto com estoque baixo",
55
- Footer: /* @__PURE__ */ n(
56
+ Footer: /* @__PURE__ */ a(
56
57
  A,
57
58
  {
58
59
  saveSelectedSimilarProduct: () => {
59
- r && (s == null || s(r), P("salvar_substituto", {
60
+ L(c, n, o.id, r.itemId), r && (d == null || d(r), F("salvar_substituto", {
60
61
  name: o.name,
61
62
  replacement_item: r == null ? void 0 : r.name
62
- })), m(!1);
63
+ })), e(!1);
63
64
  }
64
65
  }
65
66
  ),
66
- children: O ? /* @__PURE__ */ n(
67
+ children: C ? /* @__PURE__ */ a(
67
68
  E,
68
69
  {
69
- width: d ? "100%" : "90%",
70
- height: d ? 600 : 425,
70
+ width: n ? "100%" : "90%",
71
+ height: n ? 600 : 425,
71
72
  backgroundColor: "var(--color-grayScale-faded)",
72
73
  margin: "auto",
73
74
  animation: !0
74
75
  }
75
76
  ) : /* @__PURE__ */ j(q, { children: [
76
- o && /* @__PURE__ */ n(k, { selectedItem: o }),
77
- /* @__PURE__ */ n(
77
+ o && /* @__PURE__ */ a(k, { selectedItem: o }),
78
+ /* @__PURE__ */ a(
78
79
  v,
79
80
  {
80
81
  isClubClient: S,
81
82
  similarProductSelect: r,
82
- setSimilarProductSelect: e,
83
+ setSimilarProductSelect: f,
83
84
  products: b
84
85
  }
85
86
  )
@@ -88,5 +89,5 @@ const Y = ({
88
89
  );
89
90
  };
90
91
  export {
91
- Y as ChangeOrderModal
92
+ D as ChangeOrderModal
92
93
  };
@@ -1 +1 @@
1
- export declare const getOrderForm: (orderFormId: string) => Promise<any>;
1
+ export declare const getOrderForm: (orderFormId: string, isIO: boolean) => Promise<any>;
@@ -1,8 +1,14 @@
1
- import t from "axios";
2
- const e = async (o) => {
1
+ import o from "axios";
2
+ const c = async (t, a) => {
3
3
  try {
4
- const { data: r } = await t.post("http://localhost:8000/api/proxy", {
5
- targetUrl: `/api/checkout/pub/orderForm/${o}`,
4
+ if (a) {
5
+ const { data: e } = await o.post(
6
+ `/api/checkout/pub/orderForm/${t}`
7
+ );
8
+ return e;
9
+ }
10
+ const { data: r } = await o.post("/api/proxy", {
11
+ targetUrl: `/api/checkout/pub/orderForm/${t}`,
6
12
  method: "GET",
7
13
  headers: {
8
14
  "Content-Type": "application/json",
@@ -15,5 +21,5 @@ const e = async (o) => {
15
21
  }
16
22
  };
17
23
  export {
18
- e as getOrderForm
24
+ c as getOrderForm
19
25
  };
@@ -0,0 +1 @@
1
+ export declare const postChangeOrder: (orderFormId: string, isIO: boolean, skuId: string, substitutionId: string) => Promise<any>;
@@ -0,0 +1,32 @@
1
+ import o from "axios";
2
+ const s = async (e, t, a, n) => {
3
+ try {
4
+ const r = {
5
+ orderFormId: e,
6
+ skuId: a,
7
+ substitutionId: n
8
+ };
9
+ if (t) {
10
+ const { data: d } = await o.post(
11
+ "/_v/commerce/orderform/changeOrder",
12
+ r
13
+ );
14
+ return d;
15
+ }
16
+ const { data: c } = await o.post("/api/proxy", {
17
+ targetUrl: "/_v/commerce/orderform/changeOrder",
18
+ method: "POST",
19
+ headers: {
20
+ "Content-Type": "application/json",
21
+ Accept: "application/json"
22
+ },
23
+ body: r
24
+ });
25
+ return c;
26
+ } catch (r) {
27
+ console.error("Error in Change Order Modal", r);
28
+ }
29
+ };
30
+ export {
31
+ s as postChangeOrder
32
+ };
@@ -1,4 +1,5 @@
1
1
  export interface SelectedItemProps {
2
+ id: string;
2
3
  imageUrl: string;
3
4
  name: string;
4
5
  quantity: number;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
2
  import { useMemo as l } from "react";
3
- import { formatEspecifications as U, formatBrazilianPrice as f, formatedMultiply as w } from "../../../utils/changerOrderModal.js";
3
+ import { formatEspecifications as U, formatBrazilianPrice as u, formatedMultiply as w } from "../../../utils/changerOrderModal.js";
4
4
  import { Icons as z } from "../assets/icons.js";
5
5
  import { isMobile as S } from "../../../constants/index.js";
6
6
  const H = ({
@@ -11,65 +11,65 @@ const H = ({
11
11
  }) => {
12
12
  const {
13
13
  images: t,
14
- name: h,
15
- productId: m,
16
- sellingPrice: o,
14
+ name: m,
15
+ itemId: h,
16
+ sellingPrice: n,
17
17
  measurementUnit: y,
18
18
  unitMultiplier: b,
19
19
  hasDiscount: C,
20
- listPrice: n,
20
+ listPrice: i,
21
21
  isClub: I,
22
22
  skuSpecifications: p
23
- } = d, M = t == null ? void 0 : t[0].imageUrl, i = l(() => 58, []), g = l(
24
- () => m === (r == null ? void 0 : r.productId),
23
+ } = d, M = t == null ? void 0 : t[0].imageUrl, o = l(() => 58, []), g = l(
24
+ () => h === (r == null ? void 0 : r.itemId),
25
25
  [r]
26
26
  ), c = l(() => U(p || []), [p]), {
27
27
  discountPorcent: k,
28
28
  frontLstPrice: L,
29
29
  frontSellingPrice: P,
30
30
  frontPriceMultiply: j
31
- } = l(() => !o || !n ? {} : {
32
- discountPorcent: Math.round((n - o) / n * 100) * -1,
33
- frontLstPrice: f(n || 0),
34
- frontSellingPrice: f(o || 0),
31
+ } = l(() => !n || !i ? {} : {
32
+ discountPorcent: Math.round((i - n) / i * 100) * -1,
33
+ frontLstPrice: u(i || 0),
34
+ frontSellingPrice: u(n || 0),
35
35
  frontPriceMultiply: w(y || "", b || 0)
36
- }, [o, n]), x = {
36
+ }, [n, i]), x = {
37
37
  Vegano: "var(--color-seals-veg)",
38
38
  Orgânico: "var(--color-seals-org)",
39
39
  "Sem Glúten": "var(--color-seals-gluten-free)",
40
40
  "Sem Lactose": "var(--color-seals-lactose-free)",
41
41
  "Sem Açúcar": "var(--color-seals-sugar-free)"
42
- }, u = g ? "var(--color-main)" : "var(--color-grayScale-lightest)";
42
+ }, f = g ? "var(--color-main)" : "var(--color-grayScale-lightest)";
43
43
  return /* @__PURE__ */ s(
44
44
  "div",
45
45
  {
46
46
  className: "similar-product-list-item",
47
47
  onClick: () => {
48
- m !== (r == null ? void 0 : r.productId) && v(d);
48
+ h !== (r == null ? void 0 : r.itemId) && v(d);
49
49
  },
50
50
  style: {
51
- borderColor: u
51
+ borderColor: f
52
52
  },
53
53
  children: [
54
- /* @__PURE__ */ e("div", { style: { width: i, height: i }, children: /* @__PURE__ */ e(
54
+ /* @__PURE__ */ e("div", { style: { width: o, height: o }, children: /* @__PURE__ */ e(
55
55
  "img",
56
56
  {
57
- height: i,
58
- width: i,
57
+ height: o,
58
+ width: o,
59
59
  src: M,
60
- alt: h,
60
+ alt: m,
61
61
  style: { objectFit: "contain" }
62
62
  }
63
63
  ) }),
64
64
  /* @__PURE__ */ s("div", { className: "infos", children: [
65
65
  /* @__PURE__ */ s("div", { className: "description", children: [
66
- /* @__PURE__ */ e("h4", { className: "product-name", children: h }),
66
+ /* @__PURE__ */ e("h4", { className: "product-name", children: m }),
67
67
  /* @__PURE__ */ e(
68
68
  "span",
69
69
  {
70
70
  className: "choose-icon",
71
71
  style: {
72
- backgroundColor: u
72
+ backgroundColor: f
73
73
  },
74
74
  children: g && /* @__PURE__ */ e(z, { iconId: "Check" })
75
75
  }
@@ -1,30 +1,30 @@
1
- import { jsxs as i, jsx as o } from "react/jsx-runtime";
1
+ import { jsxs as r, jsx as i } from "react/jsx-runtime";
2
2
  import { Icons as h } from "../assets/icons.js";
3
3
  import { SimilarProductItem as t } from "./SimilarProductList.js";
4
4
  const I = ({
5
- products: n,
5
+ products: m,
6
6
  isClubClient: s,
7
- similarProductSelect: r,
8
- setSimilarProductSelect: m
9
- }) => n != null && n.length ? /* @__PURE__ */ i("section", { className: "change-order-similar-products", children: [
10
- /* @__PURE__ */ o("h3", { className: "title", children: "Na falta substitua por:" }),
11
- /* @__PURE__ */ o("div", { className: "similar-product-list", children: n.map((a) => /* @__PURE__ */ o(
7
+ similarProductSelect: a,
8
+ setSimilarProductSelect: n
9
+ }) => m != null && m.length ? /* @__PURE__ */ r("section", { className: "change-order-similar-products", children: [
10
+ /* @__PURE__ */ i("h3", { className: "title", children: "Na falta substitua por:" }),
11
+ /* @__PURE__ */ i("div", { className: "similar-product-list", children: m.map((o) => /* @__PURE__ */ i(
12
12
  t,
13
13
  {
14
14
  isClubClient: s,
15
- similarProductSelect: r,
16
- setSimilarProductSelect: m,
17
- similarProduct: a
15
+ similarProductSelect: a,
16
+ setSimilarProductSelect: n,
17
+ similarProduct: o
18
18
  },
19
- a.itemId
19
+ o.itemId
20
20
  )) }),
21
- r && /* @__PURE__ */ i(
21
+ a && /* @__PURE__ */ r(
22
22
  "button",
23
23
  {
24
- onClick: () => m == null ? void 0 : m({ productId: "" }),
24
+ onClick: () => n == null ? void 0 : n({ itemId: "" }),
25
25
  className: "remove-buttom",
26
26
  children: [
27
- /* @__PURE__ */ o(h, { iconId: "Trash" }),
27
+ /* @__PURE__ */ i(h, { iconId: "Trash" }),
28
28
  " Remover substituto"
29
29
  ]
30
30
  }
@@ -17,8 +17,8 @@ export interface SKUSpecification {
17
17
  }[];
18
18
  }
19
19
  export interface SimilarProducts {
20
- productId: string;
21
- itemId?: string;
20
+ productId?: string;
21
+ itemId: string;
22
22
  name?: string;
23
23
  images?: SKUImages[] | undefined;
24
24
  measurementUnit?: string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@plurix/ecom-components",
3
3
  "author": "Plurix",
4
4
  "private": false,
5
- "version": "1.6.0-commerce.4",
5
+ "version": "1.6.0-commerce.6",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",