@springmicro/cart 0.6.2 → 0.6.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springmicro/cart",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@nanostores/persistent": "^0.10.1",
|
|
25
25
|
"@nanostores/query": "^0.3.3",
|
|
26
26
|
"@nanostores/react": "^0.7.2",
|
|
27
|
-
"@springmicro/utils": "0.6.
|
|
27
|
+
"@springmicro/utils": "0.6.4",
|
|
28
28
|
"dotenv": "^16.4.5",
|
|
29
29
|
"nanostores": "^0.10.3",
|
|
30
30
|
"react": "^18.2.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"vite-plugin-css-injected-by-js": "^3.5.1",
|
|
50
50
|
"yup": "^1.4.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "231b7271a35509c623b20df1ab7c9d386a9a0cf7"
|
|
53
53
|
}
|
|
Binary file
|
|
@@ -73,9 +73,15 @@ async function createOrder(cart, apiBaseUrl, dev) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
async function getTax(apiBaseUrl, taxProvider, items, v, products, dev) {
|
|
76
|
-
dev && console.log("Getting tax");
|
|
76
|
+
dev && console.log("Getting tax", items);
|
|
77
|
+
dev &&
|
|
78
|
+
console.log(
|
|
79
|
+
"Getting product data",
|
|
80
|
+
products,
|
|
81
|
+
products[items[0].product_id]
|
|
82
|
+
);
|
|
77
83
|
const taxable_items = items.filter(
|
|
78
|
-
(i) => i.unit_amount > 0 && products[i.product_id].type
|
|
84
|
+
(i) => i.unit_amount > 0 && products[i.product_id].type != "DONATION"
|
|
79
85
|
);
|
|
80
86
|
dev && console.log("Taxable items", taxable_items);
|
|
81
87
|
if (taxable_items.length === 0) return { tax_amount: 0 };
|
|
@@ -85,7 +91,10 @@ async function getTax(apiBaseUrl, taxProvider, items, v, products, dev) {
|
|
|
85
91
|
{
|
|
86
92
|
method: "POST",
|
|
87
93
|
body: JSON.stringify({
|
|
88
|
-
cart_data: taxable_items
|
|
94
|
+
cart_data: taxable_items.map((i) => ({
|
|
95
|
+
amount: i.unit_amount,
|
|
96
|
+
reference: i.reference,
|
|
97
|
+
})),
|
|
89
98
|
address: {
|
|
90
99
|
country: v.country,
|
|
91
100
|
city: v.locality,
|
|
@@ -138,14 +147,16 @@ export default function ReviewAndCalculateTaxes({
|
|
|
138
147
|
setFormDisabled(true);
|
|
139
148
|
// status === 0 when this is clicked.
|
|
140
149
|
// Creates an order and calculates tax.
|
|
150
|
+
dev && console.log("Cart items", cart.items);
|
|
141
151
|
Promise.all([
|
|
142
152
|
createOrder(cart, apiBaseUrl, dev),
|
|
143
153
|
getTax(
|
|
144
154
|
apiBaseUrl,
|
|
145
155
|
taxProvider,
|
|
146
156
|
cart.items.map((i) => ({
|
|
147
|
-
|
|
157
|
+
unit_amount: prices[i.price_id].unit_amount,
|
|
148
158
|
reference: i.name,
|
|
159
|
+
product_id: i.product_id,
|
|
149
160
|
})),
|
|
150
161
|
values,
|
|
151
162
|
products,
|
|
@@ -158,7 +169,8 @@ export default function ReviewAndCalculateTaxes({
|
|
|
158
169
|
setStatus(1);
|
|
159
170
|
setFormDisabled(false);
|
|
160
171
|
})
|
|
161
|
-
.catch(() => {
|
|
172
|
+
.catch((e) => {
|
|
173
|
+
dev && console.log("Submit error", e);
|
|
162
174
|
setFormError(true);
|
|
163
175
|
setFormDisabled(false);
|
|
164
176
|
});
|