@vtex/faststore-plugin-buyer-portal 2.0.2 → 2.0.4
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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.4] - 2026-06-17
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Add handler for message that sends buyer to checkout and sets orderForm cookie
|
|
15
|
+
|
|
16
|
+
## [2.0.3] - 2026-06-04
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Turn filterByUnit flag to false on create an accounting field value to search for all all units in a contract.
|
|
21
|
+
|
|
10
22
|
## [2.0.2] - 2026-06-03
|
|
11
23
|
|
|
12
24
|
### Fixed
|
|
@@ -684,7 +696,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
684
696
|
- Add CHANGELOG file
|
|
685
697
|
- Add README file
|
|
686
698
|
|
|
687
|
-
[unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v2.0.
|
|
699
|
+
[unreleased]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v2.0.4...HEAD
|
|
688
700
|
[1.3.55]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.54...v1.3.55
|
|
689
701
|
[1.3.54]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.53...v1.3.54
|
|
690
702
|
[1.3.53]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.52...v1.3.53
|
|
@@ -770,6 +782,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
770
782
|
[1.3.85]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.85
|
|
771
783
|
[1.3.87]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v1.3.86...v1.3.87
|
|
772
784
|
[1.3.86]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/1.3.86
|
|
773
|
-
|
|
785
|
+
[2.0.4]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v2.0.3...v2.0.4
|
|
786
|
+
[2.0.3]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v2.0.2...v2.0.3
|
|
774
787
|
[2.0.2]: https://github.com/vtex/faststore-plugin-buyer-portal/compare/v2.0.1...v2.0.2
|
|
775
788
|
[2.0.1]: https://github.com/vtex/faststore-plugin-buyer-portal/releases/tag/2.0.1
|
package/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef } from "react";
|
|
2
2
|
|
|
3
|
+
import storeConfig from "discovery.config";
|
|
4
|
+
|
|
3
5
|
import { isDevelopment } from "../../shared/utils/environment";
|
|
4
6
|
|
|
5
7
|
const B2B_AGENT_URL = isDevelopment()
|
|
@@ -68,6 +70,24 @@ export const OrderEntryLayout = ({
|
|
|
68
70
|
);
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
function primeOrderFormCookie(orderFormId: string) {
|
|
74
|
+
const secureSubdomain = storeConfig?.secureSubdomain;
|
|
75
|
+
if (!secureSubdomain) return Promise.resolve(false);
|
|
76
|
+
|
|
77
|
+
const url = new URL(
|
|
78
|
+
`/api/checkout/pub/orderForm/${encodeURIComponent(
|
|
79
|
+
orderFormId
|
|
80
|
+
)}?refreshOutdatedData=true`,
|
|
81
|
+
secureSubdomain
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return fetch(url.toString(), {
|
|
85
|
+
method: "GET",
|
|
86
|
+
credentials: "include",
|
|
87
|
+
cache: "no-store",
|
|
88
|
+
}).then((res) => res.ok);
|
|
89
|
+
}
|
|
90
|
+
|
|
71
91
|
function onMessage(event: MessageEvent) {
|
|
72
92
|
// Only accept messages coming from the iframe's origin.
|
|
73
93
|
if (event.origin !== agentOrigin) return;
|
|
@@ -79,6 +99,29 @@ export const OrderEntryLayout = ({
|
|
|
79
99
|
if (event.data?.type === "B2B_AGENT_READY") {
|
|
80
100
|
postAuthToIframe();
|
|
81
101
|
}
|
|
102
|
+
|
|
103
|
+
if (event.data?.type === "B2B_GO_TO_CHECKOUT") {
|
|
104
|
+
const orderFormId = event.data?.orderFormId;
|
|
105
|
+
const secureSubdomain = storeConfig?.secureSubdomain;
|
|
106
|
+
if (
|
|
107
|
+
!secureSubdomain ||
|
|
108
|
+
typeof orderFormId !== "string" ||
|
|
109
|
+
!orderFormId
|
|
110
|
+
) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
primeOrderFormCookie(orderFormId)
|
|
114
|
+
.then((ok) => {
|
|
115
|
+
if (!ok) return;
|
|
116
|
+
window.location.assign(`${secureSubdomain}/checkout/payment`);
|
|
117
|
+
})
|
|
118
|
+
.catch((error) => {
|
|
119
|
+
console.warn(
|
|
120
|
+
"Failed to prime orderForm cookie before checkout",
|
|
121
|
+
error
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
82
125
|
}
|
|
83
126
|
|
|
84
127
|
window.addEventListener("message", onMessage);
|