@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.
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
+ ```