@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.
- package/dist/packages/ChangeOrderModal/ChangeOrderModal.d.ts +6 -1
- package/dist/packages/ChangeOrderModal/ChangeOrderModal.js +40 -42
- package/dist/packages/ChangeOrderModal/api/getProductsSimilars.d.ts +6 -1
- package/dist/packages/ChangeOrderModal/api/getProductsSimilars.js +16 -15
- package/package.json +1 -1
|
@@ -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?:
|
|
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
|
|
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
|
|
6
|
-
import { ModalFooter as
|
|
7
|
-
/* empty css */import { getProductsSimilars as
|
|
8
|
-
import
|
|
9
|
-
import { NoSimilarProduct as
|
|
10
|
-
import { getOrderForm as
|
|
11
|
-
import { postChangeOrder as
|
|
12
|
-
import { Skeleton as
|
|
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:
|
|
15
|
+
postalCode: O,
|
|
16
16
|
orderFormId: d,
|
|
17
|
-
isClubClient:
|
|
18
|
-
isOpen:
|
|
19
|
-
environment:
|
|
20
|
-
setIsOpen:
|
|
17
|
+
isClubClient: y,
|
|
18
|
+
isOpen: b,
|
|
19
|
+
environment: C,
|
|
20
|
+
setIsOpen: p,
|
|
21
21
|
saveSelectedSimilarProduct: c,
|
|
22
22
|
getOrderFormMutation: l,
|
|
23
|
-
getProductsSimilarsMutation:
|
|
24
|
-
postChangeOrderMutation:
|
|
23
|
+
getProductsSimilarsMutation: F,
|
|
24
|
+
postChangeOrderMutation: P
|
|
25
25
|
}) => {
|
|
26
|
-
const [s,
|
|
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:
|
|
31
|
+
const i = await z({
|
|
32
|
+
postalCode: O,
|
|
33
33
|
selectedItem: o,
|
|
34
34
|
isIO: r,
|
|
35
|
-
getProductsSimilarsMutation:
|
|
35
|
+
getProductsSimilarsMutation: F
|
|
36
36
|
}), u = (i == null ? void 0 : i.products) || [];
|
|
37
|
-
|
|
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
|
|
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
|
|
55
|
-
n != null && n.fields.idSubstitutionCriterias && (
|
|
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: `${
|
|
58
|
+
itemId: `${S[A]}`
|
|
61
59
|
});
|
|
62
60
|
} finally {
|
|
63
61
|
m(!1);
|
|
64
62
|
}
|
|
65
63
|
})();
|
|
66
64
|
}, []);
|
|
67
|
-
const
|
|
68
|
-
|
|
65
|
+
const q = () => {
|
|
66
|
+
K(
|
|
69
67
|
d,
|
|
70
68
|
r,
|
|
71
69
|
o.productOriginId,
|
|
72
70
|
t.itemId,
|
|
73
|
-
|
|
74
|
-
), t && (c == null || c(t),
|
|
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
|
-
})),
|
|
75
|
+
})), p(!1);
|
|
78
76
|
};
|
|
79
77
|
return /* @__PURE__ */ a(
|
|
80
78
|
v,
|
|
81
79
|
{
|
|
82
|
-
isOpen:
|
|
83
|
-
setIsOpen:
|
|
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
|
-
|
|
85
|
+
$,
|
|
88
86
|
{
|
|
89
|
-
saveSelectedSimilarProduct:
|
|
87
|
+
saveSelectedSimilarProduct: q
|
|
90
88
|
}
|
|
91
89
|
),
|
|
92
|
-
children:
|
|
93
|
-
|
|
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
|
-
|
|
102
|
+
T,
|
|
105
103
|
{
|
|
106
|
-
isClubClient:
|
|
104
|
+
isClubClient: y,
|
|
107
105
|
similarProductSelect: t,
|
|
108
106
|
setSimilarProductSelect: g,
|
|
109
107
|
products: s
|
|
110
108
|
}
|
|
111
|
-
) : /* @__PURE__ */ a(
|
|
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?:
|
|
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
|
|
2
|
-
const
|
|
3
|
-
postalCode:
|
|
4
|
-
isIO:
|
|
1
|
+
import g from "axios";
|
|
2
|
+
const S = async ({
|
|
3
|
+
postalCode: a,
|
|
4
|
+
isIO: u,
|
|
5
5
|
selectedItem: r,
|
|
6
|
-
getProductsSimilarsMutation:
|
|
6
|
+
getProductsSimilarsMutation: n
|
|
7
7
|
}) => {
|
|
8
|
+
var p;
|
|
8
9
|
try {
|
|
9
|
-
if (
|
|
10
|
-
const { data: o } = await
|
|
11
|
-
`/_v/commerce/products/productsSimilar?postalCode=${
|
|
12
|
-
), { similarProducts:
|
|
13
|
-
return
|
|
14
|
-
(
|
|
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
|
|
18
|
+
const i = n && await n({
|
|
18
19
|
input: {
|
|
19
|
-
postalCode:
|
|
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
|
-
|
|
34
|
+
S as getProductsSimilars
|
|
34
35
|
};
|