@plurix/ecom-components 1.14.2-commerce.6 → 1.14.2-commerce.7
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 +2 -1
- package/dist/packages/ChangeOrderModal/ChangeOrderModal.js +72 -67
- package/dist/packages/ChangeOrderModal/api/getOrderForm.d.ts +1 -1
- package/dist/packages/ChangeOrderModal/api/getOrderForm.js +10 -6
- package/dist/packages/ChangeOrderModal/api/getProductsSimilars.d.ts +3 -1
- package/dist/packages/ChangeOrderModal/api/getProductsSimilars.js +27 -12
- package/dist/packages/ChangeOrderModal/api/postChangeOrder.d.ts +1 -1
- package/dist/packages/ChangeOrderModal/api/postChangeOrder.js +24 -11
- package/package.json +1 -1
|
@@ -11,8 +11,9 @@ export interface ChangeOrderModalProps {
|
|
|
11
11
|
isClubClient?: boolean;
|
|
12
12
|
orderFormId: string;
|
|
13
13
|
saveSelectedSimilarProduct?: (similarProduct: SimilarProductsProps | undefined) => void;
|
|
14
|
+
account: string;
|
|
14
15
|
}
|
|
15
16
|
export interface idSubstitutionCriteriasProps {
|
|
16
17
|
[key: string]: string;
|
|
17
18
|
}
|
|
18
|
-
export declare const ChangeOrderModal: ({ selectedItem, postalCode, orderFormId, isClubClient, isOpen, environment, setIsOpen, saveSelectedSimilarProduct }: ChangeOrderModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare const ChangeOrderModal: ({ selectedItem, postalCode, orderFormId, isClubClient, isOpen, environment, setIsOpen, saveSelectedSimilarProduct, account }: ChangeOrderModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,103 +1,108 @@
|
|
|
1
|
-
import { jsx as n, 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
|
|
14
|
-
selectedItem:
|
|
15
|
-
postalCode:
|
|
16
|
-
orderFormId:
|
|
17
|
-
isClubClient:
|
|
18
|
-
isOpen:
|
|
19
|
-
environment:
|
|
20
|
-
setIsOpen:
|
|
21
|
-
saveSelectedSimilarProduct:
|
|
1
|
+
import { jsx as n, jsxs as q, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { useState as l, useEffect as M } from "react";
|
|
3
|
+
import { Modal as N } from "../Modal/Modal.js";
|
|
4
|
+
import { ProductSelected as k } from "./components/ProductSelected.js";
|
|
5
|
+
import { SimilarProducts as v } from "./components/SimilarProducts.js";
|
|
6
|
+
import { ModalFooter as A } from "./components/ModalFooter.js";
|
|
7
|
+
/* empty css */import { getProductsSimilars as E } from "./api/getProductsSimilars.js";
|
|
8
|
+
import _ from "../../hooks/useAnalitcsEvents.js";
|
|
9
|
+
import { NoSimilarProduct as J } from "./components/NoSimilarProduct.js";
|
|
10
|
+
import { getOrderForm as L } from "./api/getOrderForm.js";
|
|
11
|
+
import { postChangeOrder as T } from "./api/postChangeOrder.js";
|
|
12
|
+
import { Skeleton as $ } from "../Skeleton/index.js";
|
|
13
|
+
const or = ({
|
|
14
|
+
selectedItem: r,
|
|
15
|
+
postalCode: h,
|
|
16
|
+
orderFormId: c,
|
|
17
|
+
isClubClient: y,
|
|
18
|
+
isOpen: O,
|
|
19
|
+
environment: b,
|
|
20
|
+
setIsOpen: p,
|
|
21
|
+
saveSelectedSimilarProduct: m,
|
|
22
|
+
account: u
|
|
22
23
|
}) => {
|
|
23
|
-
const [
|
|
24
|
-
return
|
|
24
|
+
const [e, P] = l(), [C, s] = l(!1), a = b === "io", { genericTaggingEvent: F } = _(), [o, g] = l({ itemId: "" });
|
|
25
|
+
return M(() => {
|
|
25
26
|
(async () => {
|
|
26
|
-
|
|
27
|
+
s(!0);
|
|
27
28
|
try {
|
|
28
|
-
const
|
|
29
|
-
postalCode:
|
|
30
|
-
selectedItem:
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const i = await E({
|
|
30
|
+
postalCode: h,
|
|
31
|
+
selectedItem: r,
|
|
32
|
+
isIO: a,
|
|
33
|
+
account: u
|
|
34
|
+
}), d = (i == null ? void 0 : i.products) || [];
|
|
35
|
+
P(d);
|
|
33
36
|
} finally {
|
|
34
|
-
|
|
37
|
+
s(!1);
|
|
35
38
|
}
|
|
36
39
|
})(), (async () => {
|
|
37
|
-
var
|
|
38
|
-
|
|
40
|
+
var i, d;
|
|
41
|
+
s(!0);
|
|
39
42
|
try {
|
|
40
|
-
const
|
|
41
|
-
(
|
|
43
|
+
const f = await L(c, a, u), t = ((d = (i = f == null ? void 0 : f.customData) == null ? void 0 : i.customApps) == null ? void 0 : d.find(
|
|
44
|
+
(j) => j.id === "janis"
|
|
42
45
|
)) || null;
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
let S = {};
|
|
47
|
+
t != null && t.fields.idSubstitutionCriterias && (S = JSON.parse(
|
|
48
|
+
t == null ? void 0 : t.fields.idSubstitutionCriterias
|
|
46
49
|
));
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
itemId: `${
|
|
50
|
+
const x = r == null ? void 0 : r.productOriginId;
|
|
51
|
+
g({
|
|
52
|
+
itemId: `${S[x]}`
|
|
50
53
|
});
|
|
51
54
|
} finally {
|
|
52
|
-
|
|
55
|
+
s(!1);
|
|
53
56
|
}
|
|
54
57
|
})();
|
|
55
58
|
}, []), /* @__PURE__ */ n(
|
|
56
|
-
|
|
59
|
+
N,
|
|
57
60
|
{
|
|
58
|
-
isOpen:
|
|
59
|
-
setIsOpen:
|
|
61
|
+
isOpen: O,
|
|
62
|
+
setIsOpen: p,
|
|
60
63
|
className: "change-order-modal",
|
|
61
64
|
title: "Produto com estoque baixo",
|
|
62
65
|
Footer: /* @__PURE__ */ n(
|
|
63
|
-
|
|
66
|
+
A,
|
|
64
67
|
{
|
|
65
68
|
saveSelectedSimilarProduct: () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
r.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
T(
|
|
70
|
+
c,
|
|
71
|
+
a,
|
|
72
|
+
r.productOriginId,
|
|
73
|
+
o.itemId,
|
|
74
|
+
u
|
|
75
|
+
), o && (m == null || m(o), F("salvar_substituto", {
|
|
76
|
+
name: r.name,
|
|
77
|
+
replacement_item: o == null ? void 0 : o.name
|
|
78
|
+
})), p(!1);
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
),
|
|
77
|
-
children:
|
|
78
|
-
|
|
82
|
+
children: C ? /* @__PURE__ */ n(
|
|
83
|
+
$,
|
|
79
84
|
{
|
|
80
|
-
width:
|
|
81
|
-
height:
|
|
85
|
+
width: a ? "100%" : "90%",
|
|
86
|
+
height: a ? 600 : 425,
|
|
82
87
|
backgroundColor: "var(--color-grayScale-faded)",
|
|
83
88
|
margin: "auto",
|
|
84
89
|
animation: !0
|
|
85
90
|
}
|
|
86
|
-
) : /* @__PURE__ */
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
) : /* @__PURE__ */ q(w, { children: [
|
|
92
|
+
r && /* @__PURE__ */ n(k, { selectedItem: r }),
|
|
93
|
+
e && e.length > 0 ? /* @__PURE__ */ n(
|
|
94
|
+
v,
|
|
90
95
|
{
|
|
91
|
-
isClubClient:
|
|
92
|
-
similarProductSelect:
|
|
93
|
-
setSimilarProductSelect:
|
|
94
|
-
products:
|
|
96
|
+
isClubClient: y,
|
|
97
|
+
similarProductSelect: o,
|
|
98
|
+
setSimilarProductSelect: g,
|
|
99
|
+
products: e
|
|
95
100
|
}
|
|
96
|
-
) : /* @__PURE__ */ n(
|
|
101
|
+
) : /* @__PURE__ */ n(J, {})
|
|
97
102
|
] })
|
|
98
103
|
}
|
|
99
104
|
);
|
|
100
105
|
};
|
|
101
106
|
export {
|
|
102
|
-
|
|
107
|
+
or as ChangeOrderModal
|
|
103
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getOrderForm: (orderFormId: string) => Promise<any>;
|
|
1
|
+
export declare const getOrderForm: (orderFormId: string, isIO: boolean, account: string) => Promise<any>;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import o from "axios";
|
|
2
|
+
const n = async (t, a, e) => {
|
|
3
3
|
try {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
if (a) {
|
|
5
|
+
const { data: c } = await o.post(
|
|
6
|
+
`/api/checkout/pub/orderForm/${t}`
|
|
7
|
+
);
|
|
8
|
+
return c;
|
|
9
|
+
}
|
|
10
|
+
const { data: r } = await o.get(`https://${e}.myvtex.com/_v/faststoreapi/checkout/pub/orderForm/${t}`);
|
|
7
11
|
return r;
|
|
8
12
|
} catch (r) {
|
|
9
13
|
console.error("Error in Change Order Modal", r);
|
|
10
14
|
}
|
|
11
15
|
};
|
|
12
16
|
export {
|
|
13
|
-
|
|
17
|
+
n as getOrderForm
|
|
14
18
|
};
|
|
@@ -2,9 +2,11 @@ import { SelectedItemProps } from '../components/ProductSelected';
|
|
|
2
2
|
|
|
3
3
|
interface GetProductsSimilarsProps {
|
|
4
4
|
postalCode: string;
|
|
5
|
+
isIO: boolean;
|
|
5
6
|
selectedItem: SelectedItemProps;
|
|
7
|
+
account: string;
|
|
6
8
|
}
|
|
7
|
-
export declare const getProductsSimilars: ({ postalCode, selectedItem }: GetProductsSimilarsProps) => Promise<{
|
|
9
|
+
export declare const getProductsSimilars: ({ postalCode, isIO, selectedItem, account }: GetProductsSimilarsProps) => Promise<{
|
|
8
10
|
productOrigin: string;
|
|
9
11
|
products: import('../../../main').SimilarProducts[];
|
|
10
12
|
} | undefined>;
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
postalCode:
|
|
4
|
-
|
|
1
|
+
import n from "axios";
|
|
2
|
+
const f = async ({
|
|
3
|
+
postalCode: a,
|
|
4
|
+
isIO: p,
|
|
5
|
+
selectedItem: r,
|
|
6
|
+
account: s
|
|
5
7
|
}) => {
|
|
6
8
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (p) {
|
|
10
|
+
const { data: o } = await n.get(
|
|
11
|
+
`/_v/commerce/products/productsSimilar?postalCode=${a}&skus=${r == null ? void 0 : r.productOriginId}&field=sku`
|
|
12
|
+
), { similarProducts: c } = o;
|
|
13
|
+
return c.find(
|
|
14
|
+
(t) => t.productOrigin === (r == null ? void 0 : r.productOriginId)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
const { data: i } = await n.post("/api/proxy", {
|
|
18
|
+
targetUrl: `https://${s}.myvtex.com/_v/commerce/products/productsSimilar?postalCode=${a}&skus=${r == null ? void 0 : r.productOriginId}&field=sku`,
|
|
19
|
+
method: "GET",
|
|
20
|
+
headers: {
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
Accept: "application/json"
|
|
23
|
+
}
|
|
24
|
+
}), { similarProducts: u } = i;
|
|
25
|
+
return u.find(
|
|
26
|
+
(o) => o.productOrigin === r.productOriginId
|
|
12
27
|
);
|
|
13
|
-
} catch (
|
|
14
|
-
console.error("Error in Change Order Modal",
|
|
28
|
+
} catch (i) {
|
|
29
|
+
console.error("Error in Change Order Modal", i);
|
|
15
30
|
}
|
|
16
31
|
};
|
|
17
32
|
export {
|
|
18
|
-
|
|
33
|
+
f as getProductsSimilars
|
|
19
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const postChangeOrder: (orderFormId: string, skuId: string, substitutionId: string) => Promise<any>;
|
|
1
|
+
export declare const postChangeOrder: (orderFormId: string, isIO: boolean, skuId: string, substitutionId: string, account: string) => Promise<any>;
|
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import o from "axios";
|
|
2
|
+
const i = async (t, e, a, c, n) => {
|
|
3
3
|
try {
|
|
4
4
|
const r = {
|
|
5
|
-
orderFormId:
|
|
6
|
-
skuId:
|
|
7
|
-
substitutionId:
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
orderFormId: t,
|
|
6
|
+
skuId: a,
|
|
7
|
+
substitutionId: c
|
|
8
|
+
};
|
|
9
|
+
if (e) {
|
|
10
|
+
const { data: s } = await o.post(
|
|
11
|
+
"/_v/commerce/orderform/changeOrder",
|
|
12
|
+
r
|
|
13
|
+
);
|
|
14
|
+
return s;
|
|
15
|
+
}
|
|
16
|
+
const { data: p } = await o.post("/api/proxy", {
|
|
17
|
+
targetUrl: `https://${n}.myvtex.com/_v/commerce/orderform/changeOrder`,
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
Accept: "application/json"
|
|
22
|
+
},
|
|
23
|
+
body: r
|
|
24
|
+
});
|
|
25
|
+
return p;
|
|
13
26
|
} catch (r) {
|
|
14
27
|
console.error("Error in Change Order Modal", r);
|
|
15
28
|
}
|
|
16
29
|
};
|
|
17
30
|
export {
|
|
18
|
-
|
|
31
|
+
i as postChangeOrder
|
|
19
32
|
};
|