@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.
- package/dist/packages/ChangeOrderModal/ChangeOrderModal.d.ts +8 -5
- package/dist/packages/ChangeOrderModal/ChangeOrderModal.js +51 -54
- 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,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?:
|
|
15
|
+
getProductsSimilarsMutation?: (variables: {}) => Promise<GetProductsSimilarsResponse>;
|
|
16
16
|
postChangeOrderMutation?: any;
|
|
17
17
|
}
|
|
18
18
|
interface CustomDataMutationResponse {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Modal as
|
|
4
|
-
import { ProductSelected as
|
|
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
|
|
13
|
-
const
|
|
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:
|
|
18
|
-
isOpen:
|
|
19
|
-
environment:
|
|
17
|
+
isClubClient: y,
|
|
18
|
+
isOpen: b,
|
|
19
|
+
environment: C,
|
|
20
20
|
setIsOpen: p,
|
|
21
|
-
saveSelectedSimilarProduct:
|
|
22
|
-
getOrderFormMutation:
|
|
23
|
-
getProductsSimilarsMutation:
|
|
24
|
-
postChangeOrderMutation:
|
|
21
|
+
saveSelectedSimilarProduct: c,
|
|
22
|
+
getOrderFormMutation: l,
|
|
23
|
+
getProductsSimilarsMutation: F,
|
|
24
|
+
postChangeOrderMutation: P
|
|
25
25
|
}) => {
|
|
26
|
-
const [s,
|
|
27
|
-
|
|
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:
|
|
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
|
}
|
|
41
41
|
})(), (async () => {
|
|
42
|
-
var i, u;
|
|
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
|
-
})
|
|
50
|
-
|
|
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
|
|
56
|
-
n != null && n.fields.idSubstitutionCriterias && (
|
|
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
|
|
60
|
-
|
|
61
|
-
itemId: `${
|
|
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
|
|
69
|
-
|
|
65
|
+
const q = () => {
|
|
66
|
+
K(
|
|
70
67
|
d,
|
|
71
68
|
r,
|
|
72
69
|
o.productOriginId,
|
|
73
70
|
t.itemId,
|
|
74
|
-
|
|
75
|
-
), t && (
|
|
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:
|
|
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
|
-
|
|
85
|
+
$,
|
|
89
86
|
{
|
|
90
|
-
saveSelectedSimilarProduct:
|
|
87
|
+
saveSelectedSimilarProduct: q
|
|
91
88
|
}
|
|
92
89
|
),
|
|
93
|
-
children:
|
|
94
|
-
|
|
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__ */
|
|
103
|
-
o && /* @__PURE__ */ a(
|
|
99
|
+
) : /* @__PURE__ */ J(M, { children: [
|
|
100
|
+
o && /* @__PURE__ */ a(L, { selectedItem: o }),
|
|
104
101
|
s && s.length > 0 ? /* @__PURE__ */ a(
|
|
105
|
-
|
|
102
|
+
T,
|
|
106
103
|
{
|
|
107
|
-
isClubClient:
|
|
104
|
+
isClubClient: y,
|
|
108
105
|
similarProductSelect: t,
|
|
109
|
-
setSimilarProductSelect:
|
|
106
|
+
setSimilarProductSelect: g,
|
|
110
107
|
products: s
|
|
111
108
|
}
|
|
112
|
-
) : /* @__PURE__ */ a(
|
|
109
|
+
) : /* @__PURE__ */ a(G, {})
|
|
113
110
|
] })
|
|
114
111
|
}
|
|
115
112
|
);
|
|
116
113
|
};
|
|
117
114
|
export {
|
|
118
|
-
|
|
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?:
|
|
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
|
};
|