@springmicro/cart 0.5.14 → 0.5.16

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.
@@ -55,6 +55,7 @@ export type AddCardProps = {
55
55
  };
56
56
  stacked?: boolean;
57
57
  error?: string;
58
+ cardRequired?: boolean;
58
59
  address?: boolean;
59
60
  onSubmit?: (
60
61
  values: CreditCardValues & Partial<AddressValues>
@@ -71,6 +72,7 @@ export type AddCardProps = {
71
72
 
72
73
  export const AddCard = ({
73
74
  contact,
75
+ cardRequired = true,
74
76
  error,
75
77
  stacked = false,
76
78
  address = true,
@@ -102,33 +104,37 @@ export const AddCard = ({
102
104
  }
103
105
  }
104
106
  >
105
- <Cards
106
- {...(formik.values as CreditCardValues)}
107
- focused={formik.values.focus || "number"}
108
- />
109
-
110
- <div>
111
- <TextField
112
- sx={stacked ? { mt: 2 } : {}}
113
- fullWidth
114
- type="tel"
115
- name="number"
116
- label="Card Number"
117
- required
118
- onBlur={formik.handleBlur}
119
- onChange={handleInputChange}
120
- onFocus={handleInputFocus}
121
- variant="outlined"
122
- value={formik.values.number}
123
- error={Boolean(formik.touched.number && formik.errors.number)}
124
- helperText={formik.touched.number && formik.errors.number}
107
+ {cardRequired && (
108
+ <Cards
109
+ {...(formik.values as CreditCardValues)}
110
+ focused={formik.values.focus || "number"}
125
111
  />
112
+ )}
113
+
114
+ <Box sx={{ flexGrow: cardRequired ? undefined : 1 }}>
115
+ {cardRequired && (
116
+ <TextField
117
+ sx={stacked ? { mt: 2 } : {}}
118
+ fullWidth
119
+ type="tel"
120
+ name="number"
121
+ label="Card Number"
122
+ required
123
+ onBlur={formik.handleBlur}
124
+ onChange={handleInputChange}
125
+ onFocus={handleInputFocus}
126
+ variant="outlined"
127
+ value={formik.values.number}
128
+ error={Boolean(formik.touched.number && formik.errors.number)}
129
+ helperText={formik.touched.number && formik.errors.number}
130
+ />
131
+ )}
126
132
  <TextField
127
133
  sx={{ mt: 2 }}
128
134
  fullWidth
129
135
  type="text"
130
136
  name="name"
131
- label="Name on Card"
137
+ label={cardRequired ? "Name on Card" : "Name"}
132
138
  required
133
139
  onBlur={formik.handleBlur}
134
140
  onChange={handleInputChange}
@@ -138,104 +144,119 @@ export const AddCard = ({
138
144
  error={Boolean(formik.touched.name && formik.errors.name)}
139
145
  helperText={formik.touched.name && formik.errors.name}
140
146
  />
141
- <TextField
142
- sx={{ mt: 2, width: "calc(50% - 8px)", mr: 1 }}
143
- type="tel"
144
- name="expiry"
145
- label="Valid Thru"
146
- placeholder="MM/YY"
147
- inputProps={{ pattern: "[0-9]{2}/[0-9]{2}" }}
148
- required
149
- onBlur={formik.handleBlur}
150
- onChange={handleInputChange}
151
- onFocus={handleInputFocus}
152
- variant="outlined"
153
- value={formik.values.expiry}
154
- error={Boolean(formik.touched.expiry && formik.errors.expiry)}
155
- helperText={
156
- (formik.touched.expiry && formik.errors.expiry) || "MM/YY"
157
- }
158
- />
159
- <TextField
160
- sx={{ mt: 2, width: "calc(50% - 8px)", ml: 1 }}
161
- type="tel"
162
- name="cvc"
163
- label="CVC"
164
- required
165
- onBlur={formik.handleBlur}
166
- onChange={handleInputChange}
167
- onFocus={handleInputFocus}
168
- variant="outlined"
169
- value={formik.values.cvc}
170
- error={Boolean(formik.touched.cvc && formik.errors.cvc)}
171
- helperText={formik.touched.cvc && formik.errors.cvc}
172
- />
173
- </div>
147
+ {cardRequired && (
148
+ <>
149
+ <TextField
150
+ sx={{ mt: 2, width: "calc(50% - 8px)", mr: 1 }}
151
+ type="tel"
152
+ name="expiry"
153
+ label="Valid Thru"
154
+ placeholder="MM/YY"
155
+ inputProps={{ pattern: "[0-9]{2}/[0-9]{2}" }}
156
+ required
157
+ onBlur={formik.handleBlur}
158
+ onChange={handleInputChange}
159
+ onFocus={handleInputFocus}
160
+ variant="outlined"
161
+ value={formik.values.expiry}
162
+ error={Boolean(formik.touched.expiry && formik.errors.expiry)}
163
+ helperText={
164
+ (formik.touched.expiry && formik.errors.expiry) || "MM/YY"
165
+ }
166
+ />
167
+ <TextField
168
+ sx={{ mt: 2, width: "calc(50% - 8px)", ml: 1 }}
169
+ type="tel"
170
+ name="cvc"
171
+ label="CVC"
172
+ required
173
+ onBlur={formik.handleBlur}
174
+ onChange={handleInputChange}
175
+ onFocus={handleInputFocus}
176
+ variant="outlined"
177
+ value={formik.values.cvc}
178
+ error={Boolean(formik.touched.cvc && formik.errors.cvc)}
179
+ helperText={formik.touched.cvc && formik.errors.cvc}
180
+ />
181
+ </>
182
+ )}
183
+ </Box>
174
184
  {/* {formik.errors.submit && (
175
185
  <Typography color="error" sx={{ mt: 2 }} variant="body2">
176
186
  {formik.errors.submit}
177
187
  </Typography>
178
188
  )} */}
179
189
  </Box>
180
- <Box
181
- sx={{ display: "flex", flexDirection: "row", gap: 2, width: "100%" }}
182
- >
183
- <Box sx={{ flexGrow: 1 }}>
184
- {!address ? null : (
185
- <Box>
186
- <Typography variant="h6" sx={{ mt: 2, mb: 3 }}>
187
- Billing Address
188
- </Typography>
189
- <AddressCountryField formik={formik} name="country" />
190
- <AddressEmailField
191
- formik={formik}
192
- name="email"
193
- sx={{ mt: 2 }}
194
- />
195
- <AddressOrganizationNameField
196
- sx={{ mt: 2 }}
197
- formik={formik}
198
- name="organization"
199
- />
200
- <AddressStreetField
201
- sx={{ mt: 2 }}
202
- formik={formik}
203
- name="line1"
204
- lineNo="1"
205
- />
206
- <AddressStreetField
207
- sx={{ mt: 2 }}
208
- formik={formik}
209
- name="line2"
210
- lineNo="2"
211
- required={false}
212
- />
213
- <AddressCityField sx={{ mt: 2 }} formik={formik} name="city" />
214
- <AddressRegionField
215
- sx={{ mt: 2 }}
216
- formik={formik}
217
- name="region"
218
- />
219
- <AddressPostalCodeField
220
- sx={{ mt: 2 }}
221
- formik={formik}
222
- name="postal_code"
223
- />
224
- </Box>
225
- )}
226
- </Box>
190
+ {cardRequired && (
227
191
  <Box
228
192
  sx={{
229
- mt: "16px",
230
193
  display: "flex",
231
- flexDirection: "column",
232
- alignItems: "flex-end",
233
- flexGrow: 1,
194
+ flexDirection: "row",
195
+ gap: 2,
196
+ width: "100%",
234
197
  }}
235
198
  >
236
- {PriceDetails}
199
+ <Box sx={{ flexGrow: 1 }}>
200
+ {!address ? null : (
201
+ <Box>
202
+ <Typography variant="h6" sx={{ mt: 2, mb: 3 }}>
203
+ Billing Address
204
+ </Typography>
205
+ <AddressCountryField formik={formik} name="country" />
206
+ <AddressEmailField
207
+ formik={formik}
208
+ name="email"
209
+ sx={{ mt: 2 }}
210
+ />
211
+ <AddressOrganizationNameField
212
+ sx={{ mt: 2 }}
213
+ formik={formik}
214
+ name="organization"
215
+ />
216
+ <AddressStreetField
217
+ sx={{ mt: 2 }}
218
+ formik={formik}
219
+ name="line1"
220
+ lineNo="1"
221
+ />
222
+ <AddressStreetField
223
+ sx={{ mt: 2 }}
224
+ formik={formik}
225
+ name="line2"
226
+ lineNo="2"
227
+ required={false}
228
+ />
229
+ <AddressCityField
230
+ sx={{ mt: 2 }}
231
+ formik={formik}
232
+ name="city"
233
+ />
234
+ <AddressRegionField
235
+ sx={{ mt: 2 }}
236
+ formik={formik}
237
+ name="region"
238
+ />
239
+ <AddressPostalCodeField
240
+ sx={{ mt: 2 }}
241
+ formik={formik}
242
+ name="postal_code"
243
+ />
244
+ </Box>
245
+ )}
246
+ </Box>
247
+ <Box
248
+ sx={{
249
+ mt: "16px",
250
+ display: "flex",
251
+ flexDirection: "column",
252
+ alignItems: "flex-end",
253
+ flexGrow: 1,
254
+ }}
255
+ >
256
+ {PriceDetails}
257
+ </Box>
237
258
  </Box>
238
- </Box>
259
+ )}
239
260
  {error && (
240
261
  <Typography color="error" sx={{ mt: 2 }} variant="body2">
241
262
  {error}
File without changes
@@ -21,6 +21,7 @@ export function CartList({
21
21
  formDisabled,
22
22
  formErrorState,
23
23
  }) {
24
+ console.log("DISABLED", formDisabled);
24
25
  const [status, setStatus] = statusState;
25
26
  const [formError, setFormError] = formErrorState;
26
27
  return (
@@ -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: #ff000040 !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: #ff000040 !important;
62
+ transition: all 0.2s !important;
63
+ }
64
+
65
+ .product-card:hover .remove-button {
66
+ color: red !important;
67
+ }
File without changes