@springmicro/cart 0.6.1 → 0.6.3

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.1",
4
+ "version": "0.6.3",
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.1",
27
+ "@springmicro/utils": "0.6.3",
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": "232d9b1996bd1dbd66a020beee58eeefca8a40a2"
52
+ "gitHead": "019c24a20cf964d4987dd3bcc8672047a0001313"
53
53
  }
Binary file
Binary file
@@ -73,10 +73,17 @@ 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 !== "DONATION"
84
+ (i) => i.unit_amount > 0 && products[i.product_id].type != "DONATION"
79
85
  );
86
+ dev && console.log("Taxable items", taxable_items);
80
87
  if (taxable_items.length === 0) return { tax_amount: 0 };
81
88
 
82
89
  const res = await fetch(
@@ -84,7 +91,10 @@ async function getTax(apiBaseUrl, taxProvider, items, v, products, dev) {
84
91
  {
85
92
  method: "POST",
86
93
  body: JSON.stringify({
87
- cart_data: taxable_items,
94
+ cart_data: taxable_items.map((i) => ({
95
+ amount: i.unit_amount,
96
+ reference: i.reference,
97
+ })),
88
98
  address: {
89
99
  country: v.country,
90
100
  city: v.locality,
@@ -122,7 +132,7 @@ export default function ReviewAndCalculateTaxes({
122
132
  defaultValues = {},
123
133
  dev,
124
134
  }) {
125
- console.log({ products, prices });
135
+ dev && console.log({ products, prices });
126
136
  const [formDisabled, setFormDisabled] = useState(true);
127
137
  const [formError, setFormError] = useState(undefined);
128
138
  const theme = useTheme();
@@ -137,14 +147,16 @@ export default function ReviewAndCalculateTaxes({
137
147
  setFormDisabled(true);
138
148
  // status === 0 when this is clicked.
139
149
  // Creates an order and calculates tax.
150
+ dev && console.log("Cart items", cart.items);
140
151
  Promise.all([
141
152
  createOrder(cart, apiBaseUrl, dev),
142
153
  getTax(
143
154
  apiBaseUrl,
144
155
  taxProvider,
145
156
  cart.items.map((i) => ({
146
- amount: prices[i.price_id].unit_amount,
157
+ unit_amount: prices[i.price_id].unit_amount,
147
158
  reference: i.name,
159
+ product_id: i.product_id,
148
160
  })),
149
161
  values,
150
162
  products,
@@ -157,7 +169,8 @@ export default function ReviewAndCalculateTaxes({
157
169
  setStatus(1);
158
170
  setFormDisabled(false);
159
171
  })
160
- .catch(() => {
172
+ .catch((e) => {
173
+ dev && console.log("Submit error", e);
161
174
  setFormError(true);
162
175
  setFormDisabled(false);
163
176
  });
@@ -420,7 +433,7 @@ function CheckoutActionFields({ formik, products, prices }) {
420
433
  // Overwrites the checkout field to use the last one provided. This allows prices to overwrite product checkout fields if necessary.
421
434
  ].reduce((old, field) => ({ ...old, [field.name]: field }), {});
422
435
 
423
- console.log("Checkout fields", checkoutFields);
436
+ // console.log("Checkout fields", checkoutFields);
424
437
  const handleInputFocus = (e) => {
425
438
  const focusedEl = (e.target as HTMLElement).getAttribute("name");
426
439
  if (focusedEl) {
@@ -21,7 +21,6 @@ export function CartList({
21
21
  formDisabled,
22
22
  formErrorState,
23
23
  }) {
24
- console.log("DISABLED", formDisabled);
25
24
  const [status, setStatus] = statusState;
26
25
  const [formError, setFormError] = formErrorState;
27
26
  return (