@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.
- package/dist/packages/ChangeOrderModal/ChangeOrderModal.d.ts +3 -2
- package/dist/packages/ChangeOrderModal/ChangeOrderModal.js +52 -48
- package/dist/packages/ChangeOrderModal/api/getOrderForm.js +6 -15
- package/dist/packages/ChangeOrderModal/api/getProductsSimilars.d.ts +2 -4
- package/dist/packages/ChangeOrderModal/api/getProductsSimilars.js +19 -20
- package/package.json +1 -1
|
@@ -11,9 +11,10 @@ export interface ChangeOrderModalProps {
|
|
|
11
11
|
isClubClient?: boolean;
|
|
12
12
|
orderFormId: string;
|
|
13
13
|
saveSelectedSimilarProduct?: (similarProduct: SimilarProductsProps | undefined) => void;
|
|
14
|
-
getOrderFormMutation
|
|
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
|
|
2
|
-
import { useState as
|
|
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
|
|
7
|
-
/* empty css */import { getProductsSimilars as
|
|
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
|
|
11
|
-
import { postChangeOrder as
|
|
12
|
-
import { Skeleton as
|
|
13
|
-
const
|
|
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:
|
|
17
|
-
isClubClient:
|
|
18
|
-
isOpen:
|
|
16
|
+
orderFormId: d,
|
|
17
|
+
isClubClient: O,
|
|
18
|
+
isOpen: y,
|
|
19
19
|
environment: b,
|
|
20
|
-
setIsOpen:
|
|
21
|
-
saveSelectedSimilarProduct:
|
|
22
|
-
getOrderFormMutation: P
|
|
20
|
+
setIsOpen: p,
|
|
21
|
+
saveSelectedSimilarProduct: u,
|
|
22
|
+
getOrderFormMutation: P,
|
|
23
|
+
getProductsSimilarsMutation: C
|
|
23
24
|
}) => {
|
|
24
|
-
const [
|
|
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
|
-
|
|
28
|
+
s(!0);
|
|
28
29
|
try {
|
|
29
|
-
const i = await
|
|
30
|
+
const i = await _({
|
|
30
31
|
postalCode: h,
|
|
31
32
|
selectedItem: o,
|
|
32
|
-
isIO: r
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
40
|
+
s(!1);
|
|
37
41
|
}
|
|
38
42
|
})(), (async () => {
|
|
39
43
|
var i, m;
|
|
40
|
-
|
|
44
|
+
s(!0);
|
|
41
45
|
try {
|
|
42
|
-
const
|
|
46
|
+
const e = r ? $(d, r) : await P({
|
|
43
47
|
input: {
|
|
44
|
-
orderFormId:
|
|
48
|
+
orderFormId: d
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
|
-
console.log("rest",
|
|
48
|
-
const n = ((m = (i = l == null ? void 0 : l.customData) == null ? void 0 : i.customApps) == null ? void 0 : m.find(
|
|
49
|
-
(
|
|
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
|
|
52
|
-
n != null && n.fields.idSubstitutionCriterias && (
|
|
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
|
|
56
|
-
|
|
57
|
-
itemId: `${
|
|
59
|
+
const j = o == null ? void 0 : o.productOriginId;
|
|
60
|
+
g({
|
|
61
|
+
itemId: `${S[j]}`
|
|
58
62
|
});
|
|
59
63
|
} finally {
|
|
60
|
-
|
|
64
|
+
s(!1);
|
|
61
65
|
}
|
|
62
66
|
})();
|
|
63
67
|
}, []), /* @__PURE__ */ a(
|
|
64
68
|
v,
|
|
65
69
|
{
|
|
66
|
-
isOpen:
|
|
67
|
-
setIsOpen:
|
|
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
|
-
|
|
78
|
+
z(
|
|
79
|
+
d,
|
|
76
80
|
r,
|
|
77
81
|
o.productOriginId,
|
|
78
82
|
t.itemId
|
|
79
|
-
), t && (
|
|
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
|
-
})),
|
|
86
|
+
})), p(!1);
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
),
|
|
86
|
-
children:
|
|
87
|
-
|
|
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
|
|
99
|
+
) : /* @__PURE__ */ w(M, { children: [
|
|
96
100
|
o && /* @__PURE__ */ a(A, { selectedItem: o }),
|
|
97
|
-
|
|
101
|
+
c && c.length > 0 ? /* @__PURE__ */ a(
|
|
98
102
|
E,
|
|
99
103
|
{
|
|
100
|
-
isClubClient:
|
|
104
|
+
isClubClient: O,
|
|
101
105
|
similarProductSelect: t,
|
|
102
|
-
setSimilarProductSelect:
|
|
103
|
-
products:
|
|
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
|
-
|
|
115
|
+
io as ChangeOrderModal
|
|
112
116
|
};
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
const c = async (
|
|
1
|
+
import e from "axios";
|
|
2
|
+
const c = async (o, t) => {
|
|
3
3
|
try {
|
|
4
|
-
if (
|
|
5
|
-
const { data:
|
|
6
|
-
`/api/checkout/pub/orderForm/${
|
|
4
|
+
if (t) {
|
|
5
|
+
const { data: r } = await e.post(
|
|
6
|
+
`/api/checkout/pub/orderForm/${o}`
|
|
7
7
|
);
|
|
8
|
-
return
|
|
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
|
|
2
|
-
const
|
|
3
|
-
postalCode:
|
|
4
|
-
isIO:
|
|
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 (
|
|
9
|
-
const { data: o } = await
|
|
10
|
-
`/_v/commerce/products/productsSimilar?postalCode=${
|
|
11
|
-
), { similarProducts:
|
|
12
|
-
return
|
|
13
|
-
(
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
})
|
|
24
|
-
return
|
|
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
|
-
|
|
31
|
+
S as getProductsSimilars
|
|
33
32
|
};
|