@plurix/ecom-components 1.14.1-eng-task-1249.0 → 1.14.1-eng-task-1249.2

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.
@@ -11,9 +11,10 @@ export interface ChangeOrderModalProps {
11
11
  isClubClient?: boolean;
12
12
  orderFormId: string;
13
13
  saveSelectedSimilarProduct?: (similarProduct: SimilarProductsProps | undefined) => void;
14
- getOrderFormMutation: any;
14
+ getOrderFormMutation?: any;
15
+ getProductsSimilarsMutation?: any;
15
16
  }
16
17
  export interface idSubstitutionCriteriasProps {
17
18
  [key: string]: string;
18
19
  }
19
- export declare const ChangeOrderModal: ({ selectedItem, postalCode, orderFormId, isClubClient, isOpen, environment, setIsOpen, saveSelectedSimilarProduct, getOrderFormMutation }: ChangeOrderModalProps) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const ChangeOrderModal: ({ selectedItem, postalCode, orderFormId, isClubClient, isOpen, environment, setIsOpen, saveSelectedSimilarProduct, getOrderFormMutation, getProductsSimilarsMutation }: ChangeOrderModalProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,90 +1,94 @@
1
- import { jsx as a, jsxs as M, Fragment as N } from "react/jsx-runtime";
2
- import { useState as e, useEffect as k } from "react";
1
+ import { jsx as a, jsxs as w, Fragment as M } from "react/jsx-runtime";
2
+ import { useState as f, useEffect as k } from "react";
3
3
  import { Modal as v } from "../Modal/Modal.js";
4
4
  import { ProductSelected as A } from "./components/ProductSelected.js";
5
5
  import { SimilarProducts as E } from "./components/SimilarProducts.js";
6
- import { ModalFooter as _ } from "./components/ModalFooter.js";
7
- /* empty css */import { getProductsSimilars as J } from "./api/getProductsSimilars.js";
6
+ import { ModalFooter as J } from "./components/ModalFooter.js";
7
+ /* empty css */import { getProductsSimilars as _ } from "./api/getProductsSimilars.js";
8
8
  import L from "../../hooks/useAnalitcsEvents.js";
9
9
  import { NoSimilarProduct as T } from "./components/NoSimilarProduct.js";
10
- import { getOrderForm as S } from "./api/getOrderForm.js";
11
- import { postChangeOrder as $ } from "./api/postChangeOrder.js";
12
- import { Skeleton as z } from "../Skeleton/index.js";
13
- const to = ({
10
+ import { getOrderForm as $ } from "./api/getOrderForm.js";
11
+ import { postChangeOrder as z } from "./api/postChangeOrder.js";
12
+ import { Skeleton as B } from "../Skeleton/index.js";
13
+ const io = ({
14
14
  selectedItem: o,
15
15
  postalCode: h,
16
- orderFormId: s,
17
- isClubClient: y,
18
- isOpen: O,
16
+ orderFormId: d,
17
+ isClubClient: O,
18
+ isOpen: y,
19
19
  environment: b,
20
- setIsOpen: f,
21
- saveSelectedSimilarProduct: c,
22
- getOrderFormMutation: P
20
+ setIsOpen: p,
21
+ saveSelectedSimilarProduct: u,
22
+ getOrderFormMutation: P,
23
+ getProductsSimilarsMutation: C
23
24
  }) => {
24
- const [d, C] = e(), [w, u] = e(!1), r = b === "io", { genericTaggingEvent: x } = L(), [t, p] = e({ itemId: "" });
25
+ const [c, F] = f(), [x, s] = f(!1), r = b === "io", { genericTaggingEvent: N } = L(), [t, g] = f({ itemId: "" });
25
26
  return k(() => {
26
27
  (async () => {
27
- u(!0);
28
+ s(!0);
28
29
  try {
29
- const i = await J({
30
+ const i = await _({
30
31
  postalCode: h,
31
32
  selectedItem: o,
32
- isIO: r
33
- }), m = (i == null ? void 0 : i.products) || [];
34
- C(m);
33
+ isIO: r,
34
+ getProductsSimilarsMutation: C
35
+ });
36
+ console.log("similar", i);
37
+ const m = (i == null ? void 0 : i.products) || [];
38
+ F(m);
35
39
  } finally {
36
- u(!1);
40
+ s(!1);
37
41
  }
38
42
  })(), (async () => {
39
43
  var i, m;
40
- u(!0);
44
+ s(!0);
41
45
  try {
42
- const l = await S(s, r), j = r ? S(s, r) : await P({
46
+ const e = r ? $(d, r) : await P({
43
47
  input: {
44
- orderFormId: s
48
+ orderFormId: d
45
49
  }
46
50
  });
47
- console.log("rest", j);
48
- const n = ((m = (i = l == null ? void 0 : l.customData) == null ? void 0 : i.customApps) == null ? void 0 : m.find(
49
- (F) => F.id === "janis"
51
+ console.log("rest", e);
52
+ const l = r ? e : JSON.parse(e.getOrderForm.data), n = ((m = (i = l == null ? void 0 : l.customData) == null ? void 0 : i.customApps) == null ? void 0 : m.find(
53
+ (q) => q.id === "janis"
50
54
  )) || null;
51
- let g = {};
52
- n != null && n.fields.idSubstitutionCriterias && (g = JSON.parse(
55
+ let S = {};
56
+ n != null && n.fields.idSubstitutionCriterias && (S = JSON.parse(
53
57
  n == null ? void 0 : n.fields.idSubstitutionCriterias
54
58
  ));
55
- const q = o == null ? void 0 : o.productOriginId;
56
- p({
57
- itemId: `${g[q]}`
59
+ const j = o == null ? void 0 : o.productOriginId;
60
+ g({
61
+ itemId: `${S[j]}`
58
62
  });
59
63
  } finally {
60
- u(!1);
64
+ s(!1);
61
65
  }
62
66
  })();
63
67
  }, []), /* @__PURE__ */ a(
64
68
  v,
65
69
  {
66
- isOpen: O,
67
- setIsOpen: f,
70
+ isOpen: y,
71
+ setIsOpen: p,
68
72
  className: "change-order-modal",
69
73
  title: "Produto com estoque baixo",
70
74
  Footer: /* @__PURE__ */ a(
71
- _,
75
+ J,
72
76
  {
73
77
  saveSelectedSimilarProduct: () => {
74
- $(
75
- s,
78
+ z(
79
+ d,
76
80
  r,
77
81
  o.productOriginId,
78
82
  t.itemId
79
- ), t && (c == null || c(t), x("salvar_substituto", {
83
+ ), t && (u == null || u(t), N("salvar_substituto", {
80
84
  name: o.name,
81
85
  replacement_item: t == null ? void 0 : t.name
82
- })), f(!1);
86
+ })), p(!1);
83
87
  }
84
88
  }
85
89
  ),
86
- children: w ? /* @__PURE__ */ a(
87
- z,
90
+ children: x ? /* @__PURE__ */ a(
91
+ B,
88
92
  {
89
93
  width: r ? "100%" : "90%",
90
94
  height: r ? 600 : 425,
@@ -92,15 +96,15 @@ const to = ({
92
96
  margin: "auto",
93
97
  animation: !0
94
98
  }
95
- ) : /* @__PURE__ */ M(N, { children: [
99
+ ) : /* @__PURE__ */ w(M, { children: [
96
100
  o && /* @__PURE__ */ a(A, { selectedItem: o }),
97
- d && d.length > 0 ? /* @__PURE__ */ a(
101
+ c && c.length > 0 ? /* @__PURE__ */ a(
98
102
  E,
99
103
  {
100
- isClubClient: y,
104
+ isClubClient: O,
101
105
  similarProductSelect: t,
102
- setSimilarProductSelect: p,
103
- products: d
106
+ setSimilarProductSelect: g,
107
+ products: c
104
108
  }
105
109
  ) : /* @__PURE__ */ a(T, {})
106
110
  ] })
@@ -108,5 +112,5 @@ const to = ({
108
112
  );
109
113
  };
110
114
  export {
111
- to as ChangeOrderModal
115
+ io as ChangeOrderModal
112
116
  };
@@ -1,21 +1,12 @@
1
- import o from "axios";
2
- const c = async (t, a) => {
1
+ import e from "axios";
2
+ const c = async (o, t) => {
3
3
  try {
4
- if (a) {
5
- const { data: e } = await o.post(
6
- `/api/checkout/pub/orderForm/${t}`
4
+ if (t) {
5
+ const { data: r } = await e.post(
6
+ `/api/checkout/pub/orderForm/${o}`
7
7
  );
8
- return e;
8
+ return r;
9
9
  }
10
- const { data: r } = await o.post("/api/proxy", {
11
- targetUrl: `/api/checkout/pub/orderForm/${t}`,
12
- method: "GET",
13
- headers: {
14
- "Content-Type": "application/json",
15
- Accept: "application/json"
16
- }
17
- });
18
- return r;
19
10
  } catch (r) {
20
11
  console.error("Error in Change Order Modal", r);
21
12
  }
@@ -4,9 +4,7 @@ interface GetProductsSimilarsProps {
4
4
  postalCode: string;
5
5
  isIO: boolean;
6
6
  selectedItem: SelectedItemProps;
7
+ getProductsSimilarsMutation?: any;
7
8
  }
8
- export declare const getProductsSimilars: ({ postalCode, isIO, selectedItem }: GetProductsSimilarsProps) => Promise<{
9
- productOrigin: string;
10
- products: import('../../../main').SimilarProducts[];
11
- } | undefined>;
9
+ export declare const getProductsSimilars: ({ postalCode, isIO, selectedItem, getProductsSimilarsMutation }: GetProductsSimilarsProps) => Promise<any>;
12
10
  export {};
@@ -1,27 +1,26 @@
1
- import n from "axios";
2
- const O = async ({
3
- postalCode: a,
4
- isIO: p,
5
- selectedItem: r
1
+ import g from "axios";
2
+ const S = async ({
3
+ postalCode: n,
4
+ isIO: a,
5
+ selectedItem: r,
6
+ getProductsSimilarsMutation: s
6
7
  }) => {
7
8
  try {
8
- if (p) {
9
- const { data: o } = await n.get(
10
- `/_v/commerce/products/productsSimilar?postalCode=${a}&skus=${r == null ? void 0 : r.productOriginId}&field=sku`
11
- ), { similarProducts: u } = o;
12
- return u.find(
13
- (c) => c.productOrigin === (r == null ? void 0 : r.productOriginId)
9
+ if (a) {
10
+ const { data: o } = await g.get(
11
+ `/_v/commerce/products/productsSimilar?postalCode=${n}&skus=${r == null ? void 0 : r.productOriginId}&field=sku`
12
+ ), { similarProducts: p } = o;
13
+ return p.find(
14
+ (u) => u.productOrigin === (r == null ? void 0 : r.productOriginId)
14
15
  );
15
16
  }
16
- const { data: i } = await n.post("/api/proxy", {
17
- targetUrl: `/_v/commerce/products/productsSimilar?postalCode=${a}&skus=${r == null ? void 0 : r.productOriginId}&field=sku`,
18
- method: "GET",
19
- headers: {
20
- "Content-Type": "application/json",
21
- Accept: "application/json"
17
+ const i = s({
18
+ input: {
19
+ postalCode: n,
20
+ productOriginId: r == null ? void 0 : r.productOriginId
22
21
  }
23
- }), { similarProducts: s } = i;
24
- return s.find(
22
+ });
23
+ return JSON.parse(i.getProductsSimilars.data).find(
25
24
  (o) => o.productOrigin === r.productOriginId
26
25
  );
27
26
  } catch (i) {
@@ -29,5 +28,5 @@ const O = async ({
29
28
  }
30
29
  };
31
30
  export {
32
- O as getProductsSimilars
31
+ S as getProductsSimilars
33
32
  };
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.14.1-eng-task-1249.0",
5
+ "version": "1.14.1-eng-task-1249.2",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",