@plurix/ecom-components 1.14.1-eng-task-1249.14 → 1.14.1-eng-task-1249.16

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