@springmicro/cart 0.3.0 → 0.3.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.
@@ -1,67 +1,67 @@
1
- .product-card {
2
- width: 500px;
3
- /* display: flex;
4
- flex-direction: row;
5
- justify-content: space-between; */
6
- display: grid;
7
- grid-template-columns: 1fr 40px;
8
- gap: 0.5rem;
9
- border-radius: 8px;
10
- padding: 1rem;
11
- box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
12
- transition: all 0.3s 0.1s;
13
- cursor: pointer;
14
- min-height: 48px;
15
- flex-shrink: 0;
16
- }
17
-
18
- .product-card:hover {
19
- box-shadow: 0px 2px 5px 2px #dfdfdfff;
20
- transition: all 0.3s 0s;
21
- }
22
-
23
- .left-section {
24
- display: flex;
25
- flex-direction: row;
26
- gap: 1rem;
27
- flex-grow: 1;
28
- }
29
-
30
- .left-section > img,
31
- .missing-image {
32
- min-height: 100%;
33
- max-height: 100px;
34
- aspect-ratio: 1;
35
- border-radius: 6px;
36
- overflow: hidden;
37
- }
38
-
39
- .missing-image {
40
- background-color: rgb(222, 222, 222);
41
- }
42
-
43
- .two-row {
44
- display: flex;
45
- flex-direction: column;
46
- }
47
-
48
- .two-row :nth-child(1) {
49
- font-size: 20px;
50
- }
51
-
52
- .two-row :nth-child(2) {
53
- font-size: 14px;
54
- }
55
-
56
- .two-row > * {
57
- margin: 0;
58
- }
59
-
60
- .remove-button {
61
- color: transparent !important;
62
- transition: all 0.2s !important;
63
- }
64
-
65
- .product-card:hover .remove-button {
66
- color: red !important;
67
- }
1
+ .product-card {
2
+ width: 500px;
3
+ /* display: flex;
4
+ flex-direction: row;
5
+ justify-content: space-between; */
6
+ display: grid;
7
+ grid-template-columns: 1fr 40px;
8
+ gap: 0.5rem;
9
+ border-radius: 8px;
10
+ padding: 1rem;
11
+ box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
12
+ transition: all 0.3s 0.1s;
13
+ cursor: pointer;
14
+ min-height: 48px;
15
+ flex-shrink: 0;
16
+ }
17
+
18
+ .product-card:hover {
19
+ box-shadow: 0px 2px 5px 2px #dfdfdfff;
20
+ transition: all 0.3s 0s;
21
+ }
22
+
23
+ .left-section {
24
+ display: flex;
25
+ flex-direction: row;
26
+ gap: 1rem;
27
+ flex-grow: 1;
28
+ }
29
+
30
+ .left-section > img,
31
+ .missing-image {
32
+ min-height: 100%;
33
+ max-height: 100px;
34
+ aspect-ratio: 1;
35
+ border-radius: 6px;
36
+ overflow: hidden;
37
+ }
38
+
39
+ .missing-image {
40
+ background-color: rgb(222, 222, 222);
41
+ }
42
+
43
+ .two-row {
44
+ display: flex;
45
+ flex-direction: column;
46
+ }
47
+
48
+ .two-row :nth-child(1) {
49
+ font-size: 20px;
50
+ }
51
+
52
+ .two-row :nth-child(2) {
53
+ font-size: 14px;
54
+ }
55
+
56
+ .two-row > * {
57
+ margin: 0;
58
+ }
59
+
60
+ .remove-button {
61
+ color: transparent !important;
62
+ transition: all 0.2s !important;
63
+ }
64
+
65
+ .product-card:hover .remove-button {
66
+ color: red !important;
67
+ }
@@ -1,80 +1,80 @@
1
- import "./CartProductCard.css";
2
- import { Tooltip, IconButton, Typography } from "@mui/material";
3
- import CloseIcon from "@mui/icons-material/Close";
4
- import React from "react";
5
- import { CartProduct } from "../../types";
6
- import { removeFromCart } from "../../utils/storage";
7
-
8
- export function CartProductCard({
9
- product,
10
- i,
11
- price,
12
- disableProductLink = false,
13
- }: {
14
- product: CartProduct;
15
- i: number;
16
- price: any;
17
- disableProductLink?: boolean;
18
- }) {
19
- const [hoverDelete, setHoverDelete] = React.useState(false);
20
- console.log(product);
21
- return (
22
- <a
23
- className="product-card"
24
- href={
25
- disableProductLink || hoverDelete
26
- ? undefined
27
- : `/product/${product.product_id}`
28
- }
29
- >
30
- <div className="left-section">
31
- {product.image ? <img /> : <div className="missing-image"></div>}
32
- <div className="two-row">
33
- <Typography>{product.name}</Typography>
34
- <Typography>
35
- {price
36
- ? `$${(price.unit_amount / 100).toFixed(2)}${
37
- price.recurring
38
- ? `/${
39
- price.recurring.interval_count > 1
40
- ? `${price.recurring.interval_count} `
41
- : ""
42
- }${price.recurring.interval}${
43
- price.recurring.interval_count > 1 ? "s" : ""
44
- }`
45
- : ""
46
- }`
47
- : "Loading price..."}
48
- </Typography>
49
- </div>
50
- </div>
51
- <div
52
- style={{
53
- display: "flex",
54
- flexGrow: 1,
55
- justifyContent: "center",
56
- alignItems: "center",
57
- }}
58
- >
59
- <Tooltip
60
- title="Remove from cart"
61
- onMouseEnter={() => {
62
- setHoverDelete(true);
63
- }}
64
- onMouseLeave={() => {
65
- setHoverDelete(false);
66
- }}
67
- >
68
- <IconButton
69
- className="remove-button"
70
- onClick={() => {
71
- removeFromCart(i);
72
- }}
73
- >
74
- <CloseIcon />
75
- </IconButton>
76
- </Tooltip>
77
- </div>
78
- </a>
79
- );
80
- }
1
+ import "./CartProductCard.css";
2
+ import { Tooltip, IconButton, Typography } from "@mui/material";
3
+ import CloseIcon from "@mui/icons-material/Close";
4
+ import React from "react";
5
+ import { CartProduct } from "../../types";
6
+ import { removeFromCart } from "../../utils/storage";
7
+
8
+ export function CartProductCard({
9
+ product,
10
+ i,
11
+ price,
12
+ disableProductLink = false,
13
+ }: {
14
+ product: CartProduct;
15
+ i: number;
16
+ price: any;
17
+ disableProductLink?: boolean;
18
+ }) {
19
+ const [hoverDelete, setHoverDelete] = React.useState(false);
20
+ console.log(product);
21
+ return (
22
+ <a
23
+ className="product-card"
24
+ href={
25
+ disableProductLink || hoverDelete
26
+ ? undefined
27
+ : `/product/${product.product_id}`
28
+ }
29
+ >
30
+ <div className="left-section">
31
+ {product.image ? <img /> : <div className="missing-image"></div>}
32
+ <div className="two-row">
33
+ <Typography>{product.name}</Typography>
34
+ <Typography>
35
+ {price
36
+ ? `$${(price.unit_amount / 100).toFixed(2)}${
37
+ price.recurring
38
+ ? `/${
39
+ price.recurring.interval_count > 1
40
+ ? `${price.recurring.interval_count} `
41
+ : ""
42
+ }${price.recurring.interval}${
43
+ price.recurring.interval_count > 1 ? "s" : ""
44
+ }`
45
+ : ""
46
+ }`
47
+ : "Loading price..."}
48
+ </Typography>
49
+ </div>
50
+ </div>
51
+ <div
52
+ style={{
53
+ display: "flex",
54
+ flexGrow: 1,
55
+ justifyContent: "center",
56
+ alignItems: "center",
57
+ }}
58
+ >
59
+ <Tooltip
60
+ title="Remove from cart"
61
+ onMouseEnter={() => {
62
+ setHoverDelete(true);
63
+ }}
64
+ onMouseLeave={() => {
65
+ setHoverDelete(false);
66
+ }}
67
+ >
68
+ <IconButton
69
+ className="remove-button"
70
+ onClick={() => {
71
+ removeFromCart(i);
72
+ }}
73
+ >
74
+ <CloseIcon />
75
+ </IconButton>
76
+ </Tooltip>
77
+ </div>
78
+ </a>
79
+ );
80
+ }
@@ -1,93 +1,95 @@
1
- import React from "react";
2
- import {
3
- Container,
4
- Typography,
5
- Table,
6
- TableBody,
7
- TableCell,
8
- TableContainer,
9
- TableHead,
10
- TableRow,
11
- Paper,
12
- } from "@mui/material";
13
-
14
- const Order = ({ order, invoiceId }) => {
15
- // Formatter for currency in USD
16
- const formatter = new Intl.NumberFormat("en-US", {
17
- style: "currency",
18
- currency: "USD",
19
- });
20
-
21
- return (
22
- <Container>
23
- <Typography variant="h4" gutterBottom>
24
- {invoiceId ? `Invoice #${invoiceId}` : "Order"}
25
- </Typography>
26
- <Typography variant="subtitle1">Reference: {order.reference}</Typography>
27
- <Typography variant="subtitle1">
28
- Date: {new Date(order.date).toLocaleDateString()}
29
- </Typography>
30
- <Typography variant="subtitle1">Status: {order.status}</Typography>
31
- {order.customer ? (
32
- <Typography variant="subtitle1">
33
- {order.customer.first_name} {order.customer.last_name}
34
- </Typography>
35
- ) : (
36
- <Typography variant="subtitle1">
37
- Customer ID: {order.customer_id}
38
- </Typography>
39
- )}
40
-
41
- <TableContainer component={Paper} sx={{ my: 2 }}>
42
- <Table>
43
- <TableHead>
44
- <TableRow>
45
- <TableCell>Item ID</TableCell>
46
- <TableCell>Name</TableCell>
47
- <TableCell>Description</TableCell>
48
- <TableCell>Quantity</TableCell>
49
- <TableCell>Unit Price</TableCell>
50
- <TableCell>Total Price</TableCell>
51
- </TableRow>
52
- </TableHead>
53
- <TableBody>
54
- {order.basket.map((item) => (
55
- <TableRow key={item.item_id}>
56
- <TableCell>{item.item_id}</TableCell>
57
- <TableCell>{item.name}</TableCell>
58
- <TableCell>{item.description || "-"}</TableCell>
59
- <TableCell>{item.quantity}</TableCell>
60
- <TableCell>
61
- {formatter.format(item.unit_price_cents / 100)}
62
- </TableCell>
63
- <TableCell>
64
- {formatter.format(
65
- (item.quantity * item.unit_price_cents) / 100
66
- )}
67
- </TableCell>
68
- </TableRow>
69
- ))}
70
- </TableBody>
71
- </Table>
72
- </TableContainer>
73
-
74
- <Typography variant="h6" gutterBottom>
75
- Subtotal (excl. taxes): {formatter.format(order.total_ex_taxes / 100)}
76
- </Typography>
77
- <Typography variant="h6" gutterBottom>
78
- Taxes: {formatter.format(order.taxes / 100)}
79
- </Typography>
80
- <Typography variant="h6" gutterBottom>
81
- Delivery Fees:{" "}
82
- {formatter.format(
83
- order.delivery_fees ? order.delivery_fees / 100 : 0.0
84
- )}
85
- </Typography>
86
- <Typography variant="h5" gutterBottom sx={{ mb: 4 }}>
87
- Total: {formatter.format(order.total / 100)}
88
- </Typography>
89
- </Container>
90
- );
91
- };
92
-
93
- export default Order;
1
+ import React from "react";
2
+ import {
3
+ Container,
4
+ Typography,
5
+ Table,
6
+ TableBody,
7
+ TableCell,
8
+ TableContainer,
9
+ TableHead,
10
+ TableRow,
11
+ Paper,
12
+ } from "@mui/material";
13
+
14
+ const Order = ({ order, invoiceId }) => {
15
+ // Formatter for currency in USD
16
+ const formatter = new Intl.NumberFormat("en-US", {
17
+ style: "currency",
18
+ currency: "USD",
19
+ });
20
+
21
+ console.log("ORDER", order);
22
+
23
+ return (
24
+ <Container>
25
+ <Typography variant="h4" gutterBottom>
26
+ {invoiceId ? `Invoice #${invoiceId}` : "Order"}
27
+ </Typography>
28
+ <Typography variant="subtitle1">Reference: {order.reference}</Typography>
29
+ <Typography variant="subtitle1">
30
+ Date: {new Date(order.date).toLocaleDateString()}
31
+ </Typography>
32
+ <Typography variant="subtitle1">Status: {order.status}</Typography>
33
+ {order.customer ? (
34
+ <Typography variant="subtitle1">
35
+ {order.customer.first_name} {order.customer.last_name}
36
+ </Typography>
37
+ ) : (
38
+ <Typography variant="subtitle1">
39
+ Customer ID: {order.customer_id}
40
+ </Typography>
41
+ )}
42
+
43
+ <TableContainer component={Paper} sx={{ my: 2 }}>
44
+ <Table>
45
+ <TableHead>
46
+ <TableRow>
47
+ <TableCell>Item ID</TableCell>
48
+ <TableCell>Name</TableCell>
49
+ <TableCell>Description</TableCell>
50
+ <TableCell>Quantity</TableCell>
51
+ <TableCell>Unit Price</TableCell>
52
+ <TableCell>Total Price</TableCell>
53
+ </TableRow>
54
+ </TableHead>
55
+ <TableBody>
56
+ {order.basket.map((item) => (
57
+ <TableRow key={item.item_id}>
58
+ <TableCell>{item.item_id}</TableCell>
59
+ <TableCell>{item.name}</TableCell>
60
+ <TableCell>{item.description || "-"}</TableCell>
61
+ <TableCell>{item.quantity}</TableCell>
62
+ <TableCell>
63
+ {formatter.format(item.unit_price_cents / 100)}
64
+ </TableCell>
65
+ <TableCell>
66
+ {formatter.format(
67
+ (item.quantity * item.unit_price_cents) / 100
68
+ )}
69
+ </TableCell>
70
+ </TableRow>
71
+ ))}
72
+ </TableBody>
73
+ </Table>
74
+ </TableContainer>
75
+
76
+ <Typography variant="h6" gutterBottom>
77
+ Subtotal (excl. taxes): {formatter.format(order.subtotal / 100)}
78
+ </Typography>
79
+ <Typography variant="h6" gutterBottom>
80
+ Taxes: {formatter.format(order.taxes / 100)}
81
+ </Typography>
82
+ <Typography variant="h6" gutterBottom>
83
+ Delivery Fees:{" "}
84
+ {formatter.format(
85
+ order.delivery_fees ? order.delivery_fees / 100 : 0.0
86
+ )}
87
+ </Typography>
88
+ <Typography variant="h5" gutterBottom sx={{ mb: 4 }}>
89
+ Total: {formatter.format(order.total / 100)}
90
+ </Typography>
91
+ </Container>
92
+ );
93
+ };
94
+
95
+ export default Order;