@springmicro/cart 0.6.3 → 0.7.0
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/.eslintrc.cjs +21 -21
- package/README.md +64 -64
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +3 -3
- package/src/AddToCartForm.tsx +16 -16
- package/src/CartButton.tsx +0 -0
- package/src/ProductCard.css +106 -106
- package/src/ProductCard.tsx +0 -0
- package/src/checkout/ReviewCartAndCalculateTaxes.css +93 -93
- package/src/checkout/ReviewCartAndCalculateTaxes.tsx +0 -0
- package/src/checkout/components/AddCard.tsx +1 -1
- package/src/checkout/components/Address.tsx +0 -0
- package/src/checkout/components/CartList.tsx +0 -0
- package/src/checkout/components/CartProductCard.css +67 -67
- package/src/checkout/components/CartProductCard.tsx +0 -0
- package/src/checkout/components/Invoice.tsx +145 -145
- package/src/checkout/components/ProviderLogos.tsx +93 -93
- package/src/checkout/components/StatusBar.tsx +0 -0
- package/src/checkout/index.tsx +0 -0
- package/src/index.css +5 -5
- package/src/index.ts +0 -0
- package/src/types.d.ts +56 -56
- package/src/utils/api.ts +67 -67
- package/src/utils/cartAuthHandler.ts +50 -50
- package/src/utils/index.ts +0 -0
- package/src/utils/storage.ts +0 -0
- package/tsconfig.json +24 -24
- package/tsconfig.node.json +11 -11
- package/vite.config.ts +25 -25
- package/springmicro-cart-0.6.1.tgz +0 -0
- package/springmicro-cart-0.6.2.tgz +0 -0
package/.eslintrc.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: { browser: true, es2020: true },
|
|
4
|
-
extends: [
|
|
5
|
-
"eslint:recommended",
|
|
6
|
-
"plugin:@typescript-eslint/recommended",
|
|
7
|
-
"plugin:react-hooks/recommended",
|
|
8
|
-
],
|
|
9
|
-
ignorePatterns: ["dist", ".eslintrc.cjs"],
|
|
10
|
-
parser: "@typescript-eslint/parser",
|
|
11
|
-
plugins: ["react-refresh"],
|
|
12
|
-
rules: {
|
|
13
|
-
"react-refresh/only-export-components": [
|
|
14
|
-
"warn",
|
|
15
|
-
{ allowConstantExport: true },
|
|
16
|
-
],
|
|
17
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
18
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
19
|
-
"react-hooks/exhaustive-deps": "off",
|
|
20
|
-
},
|
|
21
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: [
|
|
5
|
+
"eslint:recommended",
|
|
6
|
+
"plugin:@typescript-eslint/recommended",
|
|
7
|
+
"plugin:react-hooks/recommended",
|
|
8
|
+
],
|
|
9
|
+
ignorePatterns: ["dist", ".eslintrc.cjs"],
|
|
10
|
+
parser: "@typescript-eslint/parser",
|
|
11
|
+
plugins: ["react-refresh"],
|
|
12
|
+
rules: {
|
|
13
|
+
"react-refresh/only-export-components": [
|
|
14
|
+
"warn",
|
|
15
|
+
{ allowConstantExport: true },
|
|
16
|
+
],
|
|
17
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
18
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
19
|
+
"react-hooks/exhaustive-deps": "off",
|
|
20
|
+
},
|
|
21
|
+
};
|
package/README.md
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
# @springmicro/cart
|
|
2
|
-
|
|
3
|
-
A package for eCommerce sites that provides shopping cart functionality.
|
|
4
|
-
|
|
5
|
-
# Exports
|
|
6
|
-
|
|
7
|
-
## Components
|
|
8
|
-
|
|
9
|
-
### CartProvider
|
|
10
|
-
|
|
11
|
-
Provides and handles all the data for the cart.
|
|
12
|
-
Requires a ReactNode child. `apiUrl` will be modified to end with `/api/ecommerce/cart`. If the user object changes, the provider automatically logs in and out of the cart.
|
|
13
|
-
|
|
14
|
-
#### Required props:
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
user={({ id: number | string } & any) | undefined}
|
|
18
|
-
apiUrl={string}
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### CartContext
|
|
22
|
-
|
|
23
|
-
Allows all scopes under the `CartProvider` to read from the cart data and the functions to modify the cart.
|
|
24
|
-
|
|
25
|
-
#### Provisions:
|
|
26
|
-
|
|
27
|
-
- `cart`: `Cart`
|
|
28
|
-
- - Provides cart and authentication data.
|
|
29
|
-
- `addToCart`: `(product: CartProduct) => void`
|
|
30
|
-
- - Adds a product to the cart.
|
|
31
|
-
- `removeFromCart`: `(i: number) => void`
|
|
32
|
-
- - Removes an item from the cart at the given index.
|
|
33
|
-
- `clearCart`: `() => void`
|
|
34
|
-
- - Clears the cart.
|
|
35
|
-
|
|
36
|
-
### CartButton
|
|
37
|
-
|
|
38
|
-
A frontend-facing component to display the cart contents in a Modal. This component is designed to go in a top navbar, ideally on the right-hand side.
|
|
39
|
-
This component is required to be in a `CartProvider` scope.
|
|
40
|
-
|
|
41
|
-
## Types
|
|
42
|
-
|
|
43
|
-
### Cart
|
|
44
|
-
|
|
45
|
-
The type of the `cart` in `CartContext.cart`.
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
{
|
|
49
|
-
cart: CartProducts[],
|
|
50
|
-
authentication: {loggedIn: boolean, user_id: string | number}
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### CartProduct
|
|
55
|
-
|
|
56
|
-
The type of the products listed in `Cart.cart`.
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
{
|
|
60
|
-
id: number | string,
|
|
61
|
-
name: string,
|
|
62
|
-
quantity: number | undefined
|
|
63
|
-
}
|
|
64
|
-
```
|
|
1
|
+
# @springmicro/cart
|
|
2
|
+
|
|
3
|
+
A package for eCommerce sites that provides shopping cart functionality.
|
|
4
|
+
|
|
5
|
+
# Exports
|
|
6
|
+
|
|
7
|
+
## Components
|
|
8
|
+
|
|
9
|
+
### CartProvider
|
|
10
|
+
|
|
11
|
+
Provides and handles all the data for the cart.
|
|
12
|
+
Requires a ReactNode child. `apiUrl` will be modified to end with `/api/ecommerce/cart`. If the user object changes, the provider automatically logs in and out of the cart.
|
|
13
|
+
|
|
14
|
+
#### Required props:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
user={({ id: number | string } & any) | undefined}
|
|
18
|
+
apiUrl={string}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### CartContext
|
|
22
|
+
|
|
23
|
+
Allows all scopes under the `CartProvider` to read from the cart data and the functions to modify the cart.
|
|
24
|
+
|
|
25
|
+
#### Provisions:
|
|
26
|
+
|
|
27
|
+
- `cart`: `Cart`
|
|
28
|
+
- - Provides cart and authentication data.
|
|
29
|
+
- `addToCart`: `(product: CartProduct) => void`
|
|
30
|
+
- - Adds a product to the cart.
|
|
31
|
+
- `removeFromCart`: `(i: number) => void`
|
|
32
|
+
- - Removes an item from the cart at the given index.
|
|
33
|
+
- `clearCart`: `() => void`
|
|
34
|
+
- - Clears the cart.
|
|
35
|
+
|
|
36
|
+
### CartButton
|
|
37
|
+
|
|
38
|
+
A frontend-facing component to display the cart contents in a Modal. This component is designed to go in a top navbar, ideally on the right-hand side.
|
|
39
|
+
This component is required to be in a `CartProvider` scope.
|
|
40
|
+
|
|
41
|
+
## Types
|
|
42
|
+
|
|
43
|
+
### Cart
|
|
44
|
+
|
|
45
|
+
The type of the `cart` in `CartContext.cart`.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
{
|
|
49
|
+
cart: CartProducts[],
|
|
50
|
+
authentication: {loggedIn: boolean, user_id: string | number}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### CartProduct
|
|
55
|
+
|
|
56
|
+
The type of the products listed in `Cart.cart`.
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
{
|
|
60
|
+
id: number | string,
|
|
61
|
+
name: string,
|
|
62
|
+
quantity: number | undefined
|
|
63
|
+
}
|
|
64
|
+
```
|
package/dist/index.js
CHANGED
|
@@ -29364,7 +29364,7 @@ const oC = _n(
|
|
|
29364
29364
|
type: "submit",
|
|
29365
29365
|
disabled: u,
|
|
29366
29366
|
color: d ? "error" : void 0,
|
|
29367
|
-
children: "
|
|
29367
|
+
children: "Review"
|
|
29368
29368
|
}
|
|
29369
29369
|
),
|
|
29370
29370
|
/* @__PURE__ */ m.jsx(qe, { sx: { mt: 1 }, children: /* @__PURE__ */ m.jsx(aC, {}) })
|