@springmicro/cart 0.7.0 → 0.7.1
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 +2041 -2035
- package/dist/index.umd.cjs +50 -50
- package/package.json +3 -3
- package/springmicro-cart-0.6.1.tgz +0 -0
- package/springmicro-cart-0.6.2.tgz +0 -0
- package/springmicro-cart-0.6.4.tgz +0 -0
- 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 +33 -27
- package/src/checkout/components/AddCard.tsx +9 -5
- package/src/checkout/components/Address.tsx +1 -1
- 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 +4 -1
- 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/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.1",
|
|
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.1",
|
|
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": "3fba722cf2e25b298d1b774c2b39ae8ac5743076"
|
|
53
53
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/AddToCartForm.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { CartProduct } from "./types";
|
|
2
|
-
import { addToCart } from "./utils/storage";
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
item: CartProduct;
|
|
6
|
-
children: any;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default function AddToCartForm({ item, children }: Props) {
|
|
10
|
-
function addItemToCart(e: any) {
|
|
11
|
-
e.preventDefault();
|
|
12
|
-
addToCart(item);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return <form onSubmit={addItemToCart}>{children}</form>;
|
|
16
|
-
}
|
|
1
|
+
import { CartProduct } from "./types";
|
|
2
|
+
import { addToCart } from "./utils/storage";
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
item: CartProduct;
|
|
6
|
+
children: any;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function AddToCartForm({ item, children }: Props) {
|
|
10
|
+
function addItemToCart(e: any) {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
addToCart(item);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return <form onSubmit={addItemToCart}>{children}</form>;
|
|
16
|
+
}
|
package/src/CartButton.tsx
CHANGED
|
File without changes
|
package/src/ProductCard.css
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
.card {
|
|
2
|
-
display: flex;
|
|
3
|
-
gap: 0.5rem;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
border-radius: 8px;
|
|
6
|
-
padding: 1rem;
|
|
7
|
-
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
|
|
8
|
-
transition: all 0.3s 0.1s;
|
|
9
|
-
cursor: pointer;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.card:hover {
|
|
13
|
-
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
14
|
-
transition: all 0.3s 0s;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.card-section {
|
|
18
|
-
display: flex;
|
|
19
|
-
gap: 8px;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
align-items: center;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.image-container {
|
|
25
|
-
width: 100%;
|
|
26
|
-
background-color: #ccc;
|
|
27
|
-
border-radius: 4px;
|
|
28
|
-
aspect-ratio: 1.5;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.button-section {
|
|
32
|
-
display: flex;
|
|
33
|
-
justify-content: space-around;
|
|
34
|
-
flex-direction: row;
|
|
35
|
-
flex-wrap: wrap;
|
|
36
|
-
margin: 4px 2rem 0px;
|
|
37
|
-
gap: 0.5rem;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.addtocartbutton {
|
|
41
|
-
color: white;
|
|
42
|
-
background-color: rgb(39, 138, 230);
|
|
43
|
-
padding: 4px 16px 6px;
|
|
44
|
-
border-radius: 8px;
|
|
45
|
-
outline: none;
|
|
46
|
-
transition: all 0.3s;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.addtocartbutton.red {
|
|
50
|
-
background-color: rgb(230, 39, 39);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.addtocartbutton.disabled {
|
|
54
|
-
background-color: rgb(170, 170, 170);
|
|
55
|
-
cursor: not-allowed;
|
|
56
|
-
}
|
|
57
|
-
.addtocartbutton.disabled:hover {
|
|
58
|
-
background-color: rgb(170, 170, 170);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.addtocartbutton:hover {
|
|
62
|
-
background-color: rgb(36, 124, 207);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.hover-button > .hover-section {
|
|
66
|
-
display: none;
|
|
67
|
-
position: absolute;
|
|
68
|
-
width: 325px;
|
|
69
|
-
margin-left: calc(-113.75px);
|
|
70
|
-
padding: 1rem;
|
|
71
|
-
color: black;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.hover-button:hover > .hover-section {
|
|
75
|
-
display: flex;
|
|
76
|
-
justify-content: center;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.hover-data {
|
|
80
|
-
border-radius: 8px;
|
|
81
|
-
padding: 1rem;
|
|
82
|
-
box-shadow: 0px 2px 5px 2px rgb(173, 173, 173);
|
|
83
|
-
background-color: white;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.hover-data > div {
|
|
87
|
-
display: flex;
|
|
88
|
-
flex-direction: column;
|
|
89
|
-
background-color: rgb(203, 203, 203);
|
|
90
|
-
gap: 1px;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.tieredpricingbutton {
|
|
94
|
-
display: flex;
|
|
95
|
-
flex-direction: column;
|
|
96
|
-
justify-content: flex-start;
|
|
97
|
-
align-items: flex-start;
|
|
98
|
-
text-align: left;
|
|
99
|
-
padding: 4px 0.5rem 8px;
|
|
100
|
-
background-color: white;
|
|
101
|
-
transition: all 0.3s;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.tieredpricingbutton:hover {
|
|
105
|
-
background-color: rgb(233, 233, 233);
|
|
106
|
-
}
|
|
1
|
+
.card {
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: 0.5rem;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
padding: 1rem;
|
|
7
|
+
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0);
|
|
8
|
+
transition: all 0.3s 0.1s;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.card:hover {
|
|
13
|
+
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
14
|
+
transition: all 0.3s 0s;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.card-section {
|
|
18
|
+
display: flex;
|
|
19
|
+
gap: 8px;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.image-container {
|
|
25
|
+
width: 100%;
|
|
26
|
+
background-color: #ccc;
|
|
27
|
+
border-radius: 4px;
|
|
28
|
+
aspect-ratio: 1.5;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.button-section {
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: space-around;
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
flex-wrap: wrap;
|
|
36
|
+
margin: 4px 2rem 0px;
|
|
37
|
+
gap: 0.5rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.addtocartbutton {
|
|
41
|
+
color: white;
|
|
42
|
+
background-color: rgb(39, 138, 230);
|
|
43
|
+
padding: 4px 16px 6px;
|
|
44
|
+
border-radius: 8px;
|
|
45
|
+
outline: none;
|
|
46
|
+
transition: all 0.3s;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.addtocartbutton.red {
|
|
50
|
+
background-color: rgb(230, 39, 39);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.addtocartbutton.disabled {
|
|
54
|
+
background-color: rgb(170, 170, 170);
|
|
55
|
+
cursor: not-allowed;
|
|
56
|
+
}
|
|
57
|
+
.addtocartbutton.disabled:hover {
|
|
58
|
+
background-color: rgb(170, 170, 170);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.addtocartbutton:hover {
|
|
62
|
+
background-color: rgb(36, 124, 207);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.hover-button > .hover-section {
|
|
66
|
+
display: none;
|
|
67
|
+
position: absolute;
|
|
68
|
+
width: 325px;
|
|
69
|
+
margin-left: calc(-113.75px);
|
|
70
|
+
padding: 1rem;
|
|
71
|
+
color: black;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.hover-button:hover > .hover-section {
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.hover-data {
|
|
80
|
+
border-radius: 8px;
|
|
81
|
+
padding: 1rem;
|
|
82
|
+
box-shadow: 0px 2px 5px 2px rgb(173, 173, 173);
|
|
83
|
+
background-color: white;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.hover-data > div {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
background-color: rgb(203, 203, 203);
|
|
90
|
+
gap: 1px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.tieredpricingbutton {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
justify-content: flex-start;
|
|
97
|
+
align-items: flex-start;
|
|
98
|
+
text-align: left;
|
|
99
|
+
padding: 4px 0.5rem 8px;
|
|
100
|
+
background-color: white;
|
|
101
|
+
transition: all 0.3s;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.tieredpricingbutton:hover {
|
|
105
|
+
background-color: rgb(233, 233, 233);
|
|
106
|
+
}
|
package/src/ProductCard.tsx
CHANGED
|
File without changes
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
.two-col {
|
|
2
|
-
display: flex;
|
|
3
|
-
/* grid-template-columns: 1fr 1fr; */
|
|
4
|
-
margin-top: 2rem;
|
|
5
|
-
align-items: flex-start;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.two-col > * {
|
|
9
|
-
width: 50%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.checkout-list {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
align-items: center;
|
|
16
|
-
gap: 1rem;
|
|
17
|
-
padding: 8px 4px;
|
|
18
|
-
margin-top: 1rem;
|
|
19
|
-
max-height: 50vh;
|
|
20
|
-
overflow: auto;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@keyframes cardanimate {
|
|
24
|
-
0% {
|
|
25
|
-
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
26
|
-
}
|
|
27
|
-
50% {
|
|
28
|
-
box-shadow: 0px 0px 0px 0px #ffffff00;
|
|
29
|
-
}
|
|
30
|
-
100% {
|
|
31
|
-
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.skeleton-card {
|
|
36
|
-
min-height: 318px;
|
|
37
|
-
border-radius: 8px;
|
|
38
|
-
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
39
|
-
animation: cardanimate 1.25s linear infinite;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
#status-bar {
|
|
43
|
-
display: flex;
|
|
44
|
-
flex-direction: row;
|
|
45
|
-
gap: 1rem;
|
|
46
|
-
align-items: center;
|
|
47
|
-
margin-left: -29px;
|
|
48
|
-
margin-bottom: 1rem;
|
|
49
|
-
margin-top: 2rem;
|
|
50
|
-
font-size: 18px;
|
|
51
|
-
font-weight: 600;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.status-bar {
|
|
55
|
-
width: 200px;
|
|
56
|
-
height: 6px;
|
|
57
|
-
background: linear-gradient(
|
|
58
|
-
90deg,
|
|
59
|
-
rgb(40, 130, 213) 0%,
|
|
60
|
-
rgb(40, 130, 213) 50%,
|
|
61
|
-
lightgrey 50%,
|
|
62
|
-
lightgrey 100%
|
|
63
|
-
);
|
|
64
|
-
background-position: 100% 0;
|
|
65
|
-
transition: color 0.3s 0s; /* active -> inactive */
|
|
66
|
-
background-size: 200% 100%;
|
|
67
|
-
border-radius: 16px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.status-bar.active {
|
|
71
|
-
background-position: 0 0;
|
|
72
|
-
transition: background-position 0.75s; /* inactive -> active */
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.status-text {
|
|
76
|
-
color: lightgrey;
|
|
77
|
-
transition: color 0.3s 0s; /* active -> inactive */
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.status-text.active {
|
|
81
|
-
color: rgb(40, 130, 213);
|
|
82
|
-
transition: color 0.5s 0.65s; /* inactive -> active */
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.shopping-button {
|
|
86
|
-
color: white;
|
|
87
|
-
background-color: rgb(39, 138, 230);
|
|
88
|
-
padding: 4px 16px 6px;
|
|
89
|
-
border-radius: 8px;
|
|
90
|
-
outline: none;
|
|
91
|
-
transition: all 0.3s;
|
|
92
|
-
text-decoration: none;
|
|
93
|
-
}
|
|
1
|
+
.two-col {
|
|
2
|
+
display: flex;
|
|
3
|
+
/* grid-template-columns: 1fr 1fr; */
|
|
4
|
+
margin-top: 2rem;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.two-col > * {
|
|
9
|
+
width: 50%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.checkout-list {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 1rem;
|
|
17
|
+
padding: 8px 4px;
|
|
18
|
+
margin-top: 1rem;
|
|
19
|
+
max-height: 50vh;
|
|
20
|
+
overflow: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@keyframes cardanimate {
|
|
24
|
+
0% {
|
|
25
|
+
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
26
|
+
}
|
|
27
|
+
50% {
|
|
28
|
+
box-shadow: 0px 0px 0px 0px #ffffff00;
|
|
29
|
+
}
|
|
30
|
+
100% {
|
|
31
|
+
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.skeleton-card {
|
|
36
|
+
min-height: 318px;
|
|
37
|
+
border-radius: 8px;
|
|
38
|
+
box-shadow: 0px 2px 5px 2px #dfdfdfff;
|
|
39
|
+
animation: cardanimate 1.25s linear infinite;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#status-bar {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: row;
|
|
45
|
+
gap: 1rem;
|
|
46
|
+
align-items: center;
|
|
47
|
+
margin-left: -29px;
|
|
48
|
+
margin-bottom: 1rem;
|
|
49
|
+
margin-top: 2rem;
|
|
50
|
+
font-size: 18px;
|
|
51
|
+
font-weight: 600;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.status-bar {
|
|
55
|
+
width: 200px;
|
|
56
|
+
height: 6px;
|
|
57
|
+
background: linear-gradient(
|
|
58
|
+
90deg,
|
|
59
|
+
rgb(40, 130, 213) 0%,
|
|
60
|
+
rgb(40, 130, 213) 50%,
|
|
61
|
+
lightgrey 50%,
|
|
62
|
+
lightgrey 100%
|
|
63
|
+
);
|
|
64
|
+
background-position: 100% 0;
|
|
65
|
+
transition: color 0.3s 0s; /* active -> inactive */
|
|
66
|
+
background-size: 200% 100%;
|
|
67
|
+
border-radius: 16px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.status-bar.active {
|
|
71
|
+
background-position: 0 0;
|
|
72
|
+
transition: background-position 0.75s; /* inactive -> active */
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.status-text {
|
|
76
|
+
color: lightgrey;
|
|
77
|
+
transition: color 0.3s 0s; /* active -> inactive */
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.status-text.active {
|
|
81
|
+
color: rgb(40, 130, 213);
|
|
82
|
+
transition: color 0.5s 0.65s; /* inactive -> active */
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.shopping-button {
|
|
86
|
+
color: white;
|
|
87
|
+
background-color: rgb(39, 138, 230);
|
|
88
|
+
padding: 4px 16px 6px;
|
|
89
|
+
border-radius: 8px;
|
|
90
|
+
outline: none;
|
|
91
|
+
transition: all 0.3s;
|
|
92
|
+
text-decoration: none;
|
|
93
|
+
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import { AddressValues } from "./components/Address";
|
|
26
26
|
import { useFormik } from "formik";
|
|
27
27
|
import { postCheckout } from "../utils/api";
|
|
28
|
+
import { CheckoutFieldsType } from ".";
|
|
28
29
|
|
|
29
30
|
async function createOrder(cart, apiBaseUrl, dev) {
|
|
30
31
|
dev && console.log("Creating order");
|
|
@@ -131,6 +132,7 @@ export default function ReviewAndCalculateTaxes({
|
|
|
131
132
|
CollectExtraInfo = undefined,
|
|
132
133
|
defaultValues = {},
|
|
133
134
|
dev,
|
|
135
|
+
hideFields = [],
|
|
134
136
|
}) {
|
|
135
137
|
dev && console.log({ products, prices });
|
|
136
138
|
const [formDisabled, setFormDisabled] = useState(true);
|
|
@@ -397,6 +399,7 @@ export default function ReviewAndCalculateTaxes({
|
|
|
397
399
|
formik={formik}
|
|
398
400
|
prices={prices}
|
|
399
401
|
products={products}
|
|
402
|
+
hideFields={hideFields}
|
|
400
403
|
/>
|
|
401
404
|
<AddCard
|
|
402
405
|
cardRequired={cardRequired}
|
|
@@ -409,6 +412,7 @@ export default function ReviewAndCalculateTaxes({
|
|
|
409
412
|
formDisabled,
|
|
410
413
|
formError,
|
|
411
414
|
}}
|
|
415
|
+
hideFields={hideFields}
|
|
412
416
|
/>
|
|
413
417
|
</Box>
|
|
414
418
|
)}
|
|
@@ -416,8 +420,8 @@ export default function ReviewAndCalculateTaxes({
|
|
|
416
420
|
);
|
|
417
421
|
}
|
|
418
422
|
|
|
419
|
-
function CheckoutActionFields({ formik, products, prices }) {
|
|
420
|
-
const checkoutFields = [
|
|
423
|
+
function CheckoutActionFields({ formik, products, prices, hideFields = [] }) {
|
|
424
|
+
const checkoutFields: Record<string, CheckoutFieldsType> = [
|
|
421
425
|
...Object.keys(products).flatMap((productKey) =>
|
|
422
426
|
(products[productKey].actions ?? []).flatMap(
|
|
423
427
|
(action) => action.checkout_fields ?? []
|
|
@@ -447,33 +451,35 @@ function CheckoutActionFields({ formik, products, prices }) {
|
|
|
447
451
|
const handleInputChange = (e) => {
|
|
448
452
|
formik.handleChange(e);
|
|
449
453
|
};
|
|
450
|
-
|
|
454
|
+
// console.log({ checkoutFields });
|
|
451
455
|
return (
|
|
452
456
|
<Box sx={{ display: "flex", flexDirection: "column", mx: 3, gap: 2 }}>
|
|
453
|
-
{Object.keys(checkoutFields)
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
457
|
+
{Object.keys(checkoutFields)
|
|
458
|
+
.filter((key) => !["email", ...hideFields].includes(key))
|
|
459
|
+
.map((key) => {
|
|
460
|
+
const {
|
|
461
|
+
name,
|
|
462
|
+
label,
|
|
463
|
+
type = "string", // todo
|
|
464
|
+
required = true, // can be a string
|
|
465
|
+
} = checkoutFields[key];
|
|
466
|
+
|
|
467
|
+
return (
|
|
468
|
+
<TextField
|
|
469
|
+
fullWidth
|
|
470
|
+
name={name}
|
|
471
|
+
label={label}
|
|
472
|
+
required={required === true || required === "true"}
|
|
473
|
+
onBlur={formik.handleBlur}
|
|
474
|
+
onChange={handleInputChange}
|
|
475
|
+
onFocus={handleInputFocus}
|
|
476
|
+
variant="outlined"
|
|
477
|
+
value={formik.values[name]}
|
|
478
|
+
error={Boolean(formik.touched[name] && formik.errors[name])}
|
|
479
|
+
helperText={formik.touched[name] && formik.errors[name]}
|
|
480
|
+
/>
|
|
481
|
+
);
|
|
482
|
+
})}
|
|
477
483
|
</Box>
|
|
478
484
|
);
|
|
479
485
|
}
|
|
@@ -68,6 +68,7 @@ export type AddCardProps = {
|
|
|
68
68
|
formDisabled;
|
|
69
69
|
formError;
|
|
70
70
|
};
|
|
71
|
+
hideFields?: string[];
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
export const AddCard = ({
|
|
@@ -84,6 +85,7 @@ export const AddCard = ({
|
|
|
84
85
|
formDisabled,
|
|
85
86
|
formError,
|
|
86
87
|
},
|
|
88
|
+
hideFields = [],
|
|
87
89
|
}: AddCardProps) => {
|
|
88
90
|
return (
|
|
89
91
|
<Container id="paymentMethodForm">
|
|
@@ -203,11 +205,13 @@ export const AddCard = ({
|
|
|
203
205
|
Billing Address
|
|
204
206
|
</Typography>
|
|
205
207
|
<AddressCountryField formik={formik} name="country" />
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
{!hideFields.includes("email") && (
|
|
209
|
+
<AddressEmailField
|
|
210
|
+
formik={formik}
|
|
211
|
+
name="email"
|
|
212
|
+
sx={{ mt: 2 }}
|
|
213
|
+
/>
|
|
214
|
+
)}
|
|
211
215
|
<AddressOrganizationNameField
|
|
212
216
|
sx={{ mt: 2 }}
|
|
213
217
|
formik={formik}
|
|
@@ -177,7 +177,7 @@ export function AddressEmailField({ formik, name, sx }: AddressFieldProps) {
|
|
|
177
177
|
return (
|
|
178
178
|
<>
|
|
179
179
|
<TextField
|
|
180
|
-
label="
|
|
180
|
+
label="Email"
|
|
181
181
|
sx={{ width: 400, display: "block", ...sx }}
|
|
182
182
|
name={name as string}
|
|
183
183
|
id={name as string}
|
|
File without changes
|