@plurix/ecom-components 1.14.1-eng-task-1249.15 → 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,7 +12,7 @@ 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 {
@@ -20,6 +20,11 @@ interface CustomDataMutationResponse {
20
20
  data: string;
21
21
  };
22
22
  }
23
+ interface GetProductsSimilarsResponse {
24
+ getProductsSimilars: {
25
+ data: string;
26
+ };
27
+ }
23
28
  export interface idSubstitutionCriteriasProps {
24
29
  [key: string]: string;
25
30
  }
@@ -1,40 +1,40 @@
1
1
  import { jsx as a, jsxs as J, Fragment as M } from "react/jsx-runtime";
2
- import { useState as p, useEffect as _ } from "react";
2
+ import { useState as f, useEffect as _ } from "react";
3
3
  import { Modal as v } from "../Modal/Modal.js";
4
4
  import { ProductSelected as L } from "./components/ProductSelected.js";
5
- import { SimilarProducts as R } 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";
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
13
  const so = ({
14
14
  selectedItem: o,
15
- postalCode: y,
15
+ postalCode: O,
16
16
  orderFormId: d,
17
- isClubClient: b,
18
- isOpen: C,
19
- environment: F,
20
- setIsOpen: f,
17
+ isClubClient: y,
18
+ isOpen: b,
19
+ environment: C,
20
+ setIsOpen: p,
21
21
  saveSelectedSimilarProduct: c,
22
22
  getOrderFormMutation: l,
23
- getProductsSimilarsMutation: P,
24
- postChangeOrderMutation: x
23
+ getProductsSimilarsMutation: F,
24
+ postChangeOrderMutation: P
25
25
  }) => {
26
- const [s, N] = p(), [j, m] = p(!1), r = F === "io", { genericTaggingEvent: q } = z(), [t, g] = p({ itemId: "" });
26
+ const [s, x] = f(), [N, m] = f(!1), r = C === "io", { genericTaggingEvent: j } = B(), [t, g] = f({ itemId: "" });
27
27
  _(() => {
28
28
  (async () => {
29
29
  m(!0);
30
30
  try {
31
- const i = await $({
32
- postalCode: y,
31
+ const i = await z({
32
+ postalCode: O,
33
33
  selectedItem: o,
34
34
  isIO: r,
35
- getProductsSimilarsMutation: P
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
  }
@@ -42,55 +42,53 @@ const so = ({
42
42
  var i, u, h;
43
43
  m(!0);
44
44
  try {
45
- const k = r && G(d, r), S = l && await l({
45
+ const w = r && H(d, r), k = l && await l({
46
46
  input: {
47
47
  orderFormId: d
48
48
  }
49
- }) || { getOrderForm: { data: "" } };
50
- console.log("mutationResponse", S);
51
- const e = r ? k : JSON.parse((i = S.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(
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(
52
50
  (E) => E.id === "janis"
53
51
  )) || null;
54
- let O = {};
55
- n != null && n.fields.idSubstitutionCriterias && (O = JSON.parse(
52
+ let S = {};
53
+ n != null && n.fields.idSubstitutionCriterias && (S = JSON.parse(
56
54
  n == null ? void 0 : n.fields.idSubstitutionCriterias
57
55
  ));
58
56
  const A = o == null ? void 0 : o.productOriginId;
59
57
  g({
60
- itemId: `${O[A]}`
58
+ itemId: `${S[A]}`
61
59
  });
62
60
  } finally {
63
61
  m(!1);
64
62
  }
65
63
  })();
66
64
  }, []);
67
- const w = () => {
68
- H(
65
+ const q = () => {
66
+ K(
69
67
  d,
70
68
  r,
71
69
  o.productOriginId,
72
70
  t.itemId,
73
- x
74
- ), t && (c == null || c(t), q("salvar_substituto", {
71
+ P
72
+ ), t && (c == null || c(t), j("salvar_substituto", {
75
73
  name: o.name,
76
74
  replacement_item: t == null ? void 0 : t.name
77
- })), f(!1);
75
+ })), p(!1);
78
76
  };
79
77
  return /* @__PURE__ */ a(
80
78
  v,
81
79
  {
82
- isOpen: C,
83
- setIsOpen: f,
80
+ isOpen: b,
81
+ setIsOpen: p,
84
82
  className: "change-order-modal",
85
83
  title: "Produto com estoque baixo",
86
84
  Footer: s && s.length > 0 && /* @__PURE__ */ a(
87
- T,
85
+ $,
88
86
  {
89
- saveSelectedSimilarProduct: w
87
+ saveSelectedSimilarProduct: q
90
88
  }
91
89
  ),
92
- children: j ? /* @__PURE__ */ a(
93
- K,
90
+ children: N ? /* @__PURE__ */ a(
91
+ Q,
94
92
  {
95
93
  width: r ? "100%" : "90%",
96
94
  height: r ? 600 : 425,
@@ -101,14 +99,14 @@ const so = ({
101
99
  ) : /* @__PURE__ */ J(M, { children: [
102
100
  o && /* @__PURE__ */ a(L, { selectedItem: o }),
103
101
  s && s.length > 0 ? /* @__PURE__ */ a(
104
- R,
102
+ T,
105
103
  {
106
- isClubClient: b,
104
+ isClubClient: y,
107
105
  similarProductSelect: t,
108
106
  setSimilarProductSelect: g,
109
107
  products: s
110
108
  }
111
- ) : /* @__PURE__ */ a(B, {})
109
+ ) : /* @__PURE__ */ a(G, {})
112
110
  ] })
113
111
  }
114
112
  );
@@ -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.15",
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",