@springmicro/cart 0.7.12 → 0.7.14
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/index.js +4646 -4618
- package/dist/index.umd.cjs +59 -59
- package/package.json +3 -3
- package/src/checkout/index.tsx +15 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springmicro/cart",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.14",
|
|
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.7.
|
|
27
|
+
"@springmicro/utils": "^0.7.14",
|
|
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": "71215f52efddd68fcc712810efb23a942fba2569"
|
|
53
53
|
}
|
package/src/checkout/index.tsx
CHANGED
|
@@ -27,6 +27,8 @@ export default function Checkout({
|
|
|
27
27
|
hideFields = [],
|
|
28
28
|
disableFields = [],
|
|
29
29
|
dev,
|
|
30
|
+
invoiceId,
|
|
31
|
+
order: _order,
|
|
30
32
|
}: {
|
|
31
33
|
apiBaseUrl: string;
|
|
32
34
|
taxProvider: string;
|
|
@@ -38,10 +40,13 @@ export default function Checkout({
|
|
|
38
40
|
hideFields?: string[];
|
|
39
41
|
disableFields?: string[];
|
|
40
42
|
dev?: boolean;
|
|
43
|
+
invoiceId?;
|
|
44
|
+
order?;
|
|
41
45
|
}) {
|
|
42
46
|
const store = useStore(cartStore);
|
|
43
|
-
const
|
|
44
|
-
|
|
47
|
+
const localCart = useMemo(() => JSON.parse(store), [store]);
|
|
48
|
+
|
|
49
|
+
const cart = invoiceId ? { items: _order.basket } : localCart; // todo fix calculation
|
|
45
50
|
|
|
46
51
|
const [products, setProducts] = useState({});
|
|
47
52
|
const [prices, setPrices] = useState({});
|
|
@@ -51,7 +56,7 @@ export default function Checkout({
|
|
|
51
56
|
const discount = 0;
|
|
52
57
|
|
|
53
58
|
const [status, setStatus] = useState(0);
|
|
54
|
-
const [order, setOrder] = useState(
|
|
59
|
+
const [order, setOrder] = useState(_order); // starts undefined on a typical checkout. If an order is provided, it's likely an invoice.
|
|
55
60
|
const [successData, setSuccessData] = useState(null);
|
|
56
61
|
|
|
57
62
|
useEffect(() => {
|
|
@@ -204,7 +209,7 @@ export default function Checkout({
|
|
|
204
209
|
* Review taxes and shipping
|
|
205
210
|
*
|
|
206
211
|
* status === 2
|
|
207
|
-
* Order has been
|
|
212
|
+
* Order has been placed. Invoice for printing.
|
|
208
213
|
*
|
|
209
214
|
*/}
|
|
210
215
|
|
|
@@ -233,10 +238,15 @@ export default function Checkout({
|
|
|
233
238
|
dev={dev}
|
|
234
239
|
hideFields={hideFields}
|
|
235
240
|
disableFields={disableFields}
|
|
241
|
+
invoiceId={invoiceId}
|
|
236
242
|
/>
|
|
237
243
|
)}
|
|
238
244
|
{status === 2 && order !== undefined && (
|
|
239
|
-
<Invoice
|
|
245
|
+
<Invoice
|
|
246
|
+
order={order}
|
|
247
|
+
successData={successData}
|
|
248
|
+
invoiceId={invoiceId}
|
|
249
|
+
/>
|
|
240
250
|
)}
|
|
241
251
|
</div>
|
|
242
252
|
</div>
|