@plurix/ecom-components 1.6.0-commerce.5 → 1.6.0-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.js +40 -39
- package/dist/packages/ChangeOrderModal/api/postChangeOrder.d.ts +1 -0
- package/dist/packages/ChangeOrderModal/api/postChangeOrder.js +32 -0
- package/dist/packages/ChangeOrderModal/components/ProductSelected.d.ts +1 -0
- package/dist/packages/ChangeOrderModal/components/SimilarProductList.js +21 -21
- package/dist/packages/ChangeOrderModal/components/SimilarProducts.js +14 -14
- package/dist/types/ChangeOrderModal.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsx as a, jsxs as j, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useEffect as w } from "react";
|
|
3
3
|
import { Modal as M } from "../Modal/Modal.js";
|
|
4
4
|
import { ProductSelected as k } from "./components/ProductSelected.js";
|
|
5
5
|
import { SimilarProducts as v } from "./components/SimilarProducts.js";
|
|
@@ -8,79 +8,80 @@ import { ModalFooter as A } from "./components/ModalFooter.js";
|
|
|
8
8
|
import { getProductsSimilars as N } from "./api/getProductsSimilars.js";
|
|
9
9
|
import _ from "../../hooks/useAnalitcsEvents.js";
|
|
10
10
|
import { getOrderForm as J } from "./api/getOrderForm.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
import { postChangeOrder as L } from "./api/postChangeOrder.js";
|
|
12
|
+
const D = ({
|
|
13
|
+
selectedItem: r,
|
|
14
|
+
postalCode: g,
|
|
15
|
+
orderFormId: c,
|
|
15
16
|
isClubClient: S,
|
|
16
17
|
isOpen: h,
|
|
17
18
|
environment: y,
|
|
18
|
-
setIsOpen:
|
|
19
|
+
setIsOpen: e,
|
|
19
20
|
saveSelectedSimilarProduct: d
|
|
20
21
|
}) => {
|
|
21
|
-
const [
|
|
22
|
+
const [O, b] = u(), [C, s] = u(!1), n = y === "io", { genericTaggingEvent: F } = _(), [o, f] = u({ itemId: "" });
|
|
22
23
|
return w(() => {
|
|
23
24
|
(async () => {
|
|
24
|
-
|
|
25
|
+
s(!0);
|
|
25
26
|
try {
|
|
26
|
-
const
|
|
27
|
-
postalCode:
|
|
28
|
-
selectedItem:
|
|
29
|
-
isIO:
|
|
27
|
+
const i = await N({
|
|
28
|
+
postalCode: g,
|
|
29
|
+
selectedItem: r,
|
|
30
|
+
isIO: n
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
+
b(i == null ? void 0 : i.products);
|
|
32
33
|
} finally {
|
|
33
|
-
|
|
34
|
+
s(!1);
|
|
34
35
|
}
|
|
35
36
|
})(), (async () => {
|
|
36
|
-
var
|
|
37
|
-
|
|
37
|
+
var i, l;
|
|
38
|
+
s(!0);
|
|
38
39
|
try {
|
|
39
|
-
const
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
40
|
+
const m = await J(c, n), t = ((l = (i = m == null ? void 0 : m.customData) == null ? void 0 : i.customApps) == null ? void 0 : l.find((x) => x.id === "janis")) || null;
|
|
41
|
+
let p = {};
|
|
42
|
+
t != null && t.fields.idSubstitutionCriterias && (p = JSON.parse(t == null ? void 0 : t.fields.idSubstitutionCriterias));
|
|
43
|
+
const P = r == null ? void 0 : r.productOriginId;
|
|
44
|
+
f({ itemId: `${p[P]}` });
|
|
44
45
|
} finally {
|
|
45
|
-
|
|
46
|
+
s(!1);
|
|
46
47
|
}
|
|
47
48
|
})();
|
|
48
|
-
}, []), /* @__PURE__ */
|
|
49
|
+
}, []), /* @__PURE__ */ a(
|
|
49
50
|
M,
|
|
50
51
|
{
|
|
51
52
|
isOpen: h,
|
|
52
|
-
setIsOpen:
|
|
53
|
+
setIsOpen: e,
|
|
53
54
|
className: "change-order-modal",
|
|
54
55
|
title: "Produto com estoque baixo",
|
|
55
|
-
Footer: /* @__PURE__ */
|
|
56
|
+
Footer: /* @__PURE__ */ a(
|
|
56
57
|
A,
|
|
57
58
|
{
|
|
58
59
|
saveSelectedSimilarProduct: () => {
|
|
59
|
-
r && (d == null || d(
|
|
60
|
-
name:
|
|
61
|
-
replacement_item:
|
|
62
|
-
})),
|
|
60
|
+
L(c, n, r.productOriginId, o.itemId), o && (d == null || d(o), F("salvar_substituto", {
|
|
61
|
+
name: r.name,
|
|
62
|
+
replacement_item: o == null ? void 0 : o.name
|
|
63
|
+
})), e(!1);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
),
|
|
66
|
-
children:
|
|
67
|
+
children: C ? /* @__PURE__ */ a(
|
|
67
68
|
E,
|
|
68
69
|
{
|
|
69
|
-
width:
|
|
70
|
-
height:
|
|
70
|
+
width: n ? "100%" : "90%",
|
|
71
|
+
height: n ? 600 : 425,
|
|
71
72
|
backgroundColor: "var(--color-grayScale-faded)",
|
|
72
73
|
margin: "auto",
|
|
73
74
|
animation: !0
|
|
74
75
|
}
|
|
75
76
|
) : /* @__PURE__ */ j(q, { children: [
|
|
76
|
-
|
|
77
|
-
/* @__PURE__ */
|
|
77
|
+
r && /* @__PURE__ */ a(k, { selectedItem: r }),
|
|
78
|
+
/* @__PURE__ */ a(
|
|
78
79
|
v,
|
|
79
80
|
{
|
|
80
81
|
isClubClient: S,
|
|
81
|
-
similarProductSelect:
|
|
82
|
-
setSimilarProductSelect:
|
|
83
|
-
products:
|
|
82
|
+
similarProductSelect: o,
|
|
83
|
+
setSimilarProductSelect: f,
|
|
84
|
+
products: O
|
|
84
85
|
}
|
|
85
86
|
)
|
|
86
87
|
] })
|
|
@@ -88,5 +89,5 @@ const Y = ({
|
|
|
88
89
|
);
|
|
89
90
|
};
|
|
90
91
|
export {
|
|
91
|
-
|
|
92
|
+
D as ChangeOrderModal
|
|
92
93
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const postChangeOrder: (orderFormId: string, isIO: boolean, skuId: string, substitutionId: string) => Promise<any>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import o from "axios";
|
|
2
|
+
const s = async (e, t, a, n) => {
|
|
3
|
+
try {
|
|
4
|
+
const r = {
|
|
5
|
+
orderFormId: e,
|
|
6
|
+
skuId: a,
|
|
7
|
+
substitutionId: n
|
|
8
|
+
};
|
|
9
|
+
if (t) {
|
|
10
|
+
const { data: d } = await o.post(
|
|
11
|
+
"/_v/commerce/orderform/changeOrder",
|
|
12
|
+
r
|
|
13
|
+
);
|
|
14
|
+
return d;
|
|
15
|
+
}
|
|
16
|
+
const { data: c } = await o.post("/api/proxy", {
|
|
17
|
+
targetUrl: "/_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 c;
|
|
26
|
+
} catch (r) {
|
|
27
|
+
console.error("Error in Change Order Modal", r);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
s as postChangeOrder
|
|
32
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as l } from "react";
|
|
3
|
-
import { formatEspecifications as U, formatBrazilianPrice as
|
|
3
|
+
import { formatEspecifications as U, formatBrazilianPrice as u, formatedMultiply as w } from "../../../utils/changerOrderModal.js";
|
|
4
4
|
import { Icons as z } from "../assets/icons.js";
|
|
5
5
|
import { isMobile as S } from "../../../constants/index.js";
|
|
6
6
|
const H = ({
|
|
@@ -11,65 +11,65 @@ const H = ({
|
|
|
11
11
|
}) => {
|
|
12
12
|
const {
|
|
13
13
|
images: t,
|
|
14
|
-
name:
|
|
15
|
-
|
|
16
|
-
sellingPrice:
|
|
14
|
+
name: m,
|
|
15
|
+
itemId: h,
|
|
16
|
+
sellingPrice: n,
|
|
17
17
|
measurementUnit: y,
|
|
18
18
|
unitMultiplier: b,
|
|
19
19
|
hasDiscount: C,
|
|
20
|
-
listPrice:
|
|
20
|
+
listPrice: i,
|
|
21
21
|
isClub: I,
|
|
22
22
|
skuSpecifications: p
|
|
23
|
-
} = d, M = t == null ? void 0 : t[0].imageUrl,
|
|
24
|
-
() =>
|
|
23
|
+
} = d, M = t == null ? void 0 : t[0].imageUrl, o = l(() => 58, []), g = l(
|
|
24
|
+
() => h === (r == null ? void 0 : r.itemId),
|
|
25
25
|
[r]
|
|
26
26
|
), c = l(() => U(p || []), [p]), {
|
|
27
27
|
discountPorcent: k,
|
|
28
28
|
frontLstPrice: L,
|
|
29
29
|
frontSellingPrice: P,
|
|
30
30
|
frontPriceMultiply: j
|
|
31
|
-
} = l(() => !
|
|
32
|
-
discountPorcent: Math.round((
|
|
33
|
-
frontLstPrice:
|
|
34
|
-
frontSellingPrice:
|
|
31
|
+
} = l(() => !n || !i ? {} : {
|
|
32
|
+
discountPorcent: Math.round((i - n) / i * 100) * -1,
|
|
33
|
+
frontLstPrice: u(i || 0),
|
|
34
|
+
frontSellingPrice: u(n || 0),
|
|
35
35
|
frontPriceMultiply: w(y || "", b || 0)
|
|
36
|
-
}, [
|
|
36
|
+
}, [n, i]), x = {
|
|
37
37
|
Vegano: "var(--color-seals-veg)",
|
|
38
38
|
Orgânico: "var(--color-seals-org)",
|
|
39
39
|
"Sem Glúten": "var(--color-seals-gluten-free)",
|
|
40
40
|
"Sem Lactose": "var(--color-seals-lactose-free)",
|
|
41
41
|
"Sem Açúcar": "var(--color-seals-sugar-free)"
|
|
42
|
-
},
|
|
42
|
+
}, f = g ? "var(--color-main)" : "var(--color-grayScale-lightest)";
|
|
43
43
|
return /* @__PURE__ */ s(
|
|
44
44
|
"div",
|
|
45
45
|
{
|
|
46
46
|
className: "similar-product-list-item",
|
|
47
47
|
onClick: () => {
|
|
48
|
-
|
|
48
|
+
h !== (r == null ? void 0 : r.itemId) && v(d);
|
|
49
49
|
},
|
|
50
50
|
style: {
|
|
51
|
-
borderColor:
|
|
51
|
+
borderColor: f
|
|
52
52
|
},
|
|
53
53
|
children: [
|
|
54
|
-
/* @__PURE__ */ e("div", { style: { width:
|
|
54
|
+
/* @__PURE__ */ e("div", { style: { width: o, height: o }, children: /* @__PURE__ */ e(
|
|
55
55
|
"img",
|
|
56
56
|
{
|
|
57
|
-
height:
|
|
58
|
-
width:
|
|
57
|
+
height: o,
|
|
58
|
+
width: o,
|
|
59
59
|
src: M,
|
|
60
|
-
alt:
|
|
60
|
+
alt: m,
|
|
61
61
|
style: { objectFit: "contain" }
|
|
62
62
|
}
|
|
63
63
|
) }),
|
|
64
64
|
/* @__PURE__ */ s("div", { className: "infos", children: [
|
|
65
65
|
/* @__PURE__ */ s("div", { className: "description", children: [
|
|
66
|
-
/* @__PURE__ */ e("h4", { className: "product-name", children:
|
|
66
|
+
/* @__PURE__ */ e("h4", { className: "product-name", children: m }),
|
|
67
67
|
/* @__PURE__ */ e(
|
|
68
68
|
"span",
|
|
69
69
|
{
|
|
70
70
|
className: "choose-icon",
|
|
71
71
|
style: {
|
|
72
|
-
backgroundColor:
|
|
72
|
+
backgroundColor: f
|
|
73
73
|
},
|
|
74
74
|
children: g && /* @__PURE__ */ e(z, { iconId: "Check" })
|
|
75
75
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as r, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { Icons as h } from "../assets/icons.js";
|
|
3
3
|
import { SimilarProductItem as t } from "./SimilarProductList.js";
|
|
4
4
|
const I = ({
|
|
5
|
-
products:
|
|
5
|
+
products: m,
|
|
6
6
|
isClubClient: s,
|
|
7
|
-
similarProductSelect:
|
|
8
|
-
setSimilarProductSelect:
|
|
9
|
-
}) =>
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
/* @__PURE__ */
|
|
7
|
+
similarProductSelect: a,
|
|
8
|
+
setSimilarProductSelect: n
|
|
9
|
+
}) => m != null && m.length ? /* @__PURE__ */ r("section", { className: "change-order-similar-products", children: [
|
|
10
|
+
/* @__PURE__ */ i("h3", { className: "title", children: "Na falta substitua por:" }),
|
|
11
|
+
/* @__PURE__ */ i("div", { className: "similar-product-list", children: m.map((o) => /* @__PURE__ */ i(
|
|
12
12
|
t,
|
|
13
13
|
{
|
|
14
14
|
isClubClient: s,
|
|
15
|
-
similarProductSelect:
|
|
16
|
-
setSimilarProductSelect:
|
|
17
|
-
similarProduct:
|
|
15
|
+
similarProductSelect: a,
|
|
16
|
+
setSimilarProductSelect: n,
|
|
17
|
+
similarProduct: o
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
o.itemId
|
|
20
20
|
)) }),
|
|
21
|
-
|
|
21
|
+
a && /* @__PURE__ */ r(
|
|
22
22
|
"button",
|
|
23
23
|
{
|
|
24
|
-
onClick: () =>
|
|
24
|
+
onClick: () => n == null ? void 0 : n({ itemId: "" }),
|
|
25
25
|
className: "remove-buttom",
|
|
26
26
|
children: [
|
|
27
|
-
/* @__PURE__ */
|
|
27
|
+
/* @__PURE__ */ i(h, { iconId: "Trash" }),
|
|
28
28
|
" Remover substituto"
|
|
29
29
|
]
|
|
30
30
|
}
|