Skip to content

Commit 8ba70d8

Browse files
authored
Merge pull request #383 from reactioncommerce/feat-update-components-context
Update components context
2 parents c850021 + b3b1653 commit 8ba70d8

File tree

15 files changed

+86
-109
lines changed

15 files changed

+86
-109
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"suiteName": "jest-tests"
9797
},
9898
"dependencies": {
99-
"@reactioncommerce/components-context": "1.0.0",
99+
"@reactioncommerce/components-context": "^1.1.0",
100100
"babel-polyfill": "^6.26.0",
101101
"prop-types": "15.6.2",
102102
"react": "16.4.2",

package/src/components/AddressCapture/v1/AddressCapture.js

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ class AddressCapture extends Component {
134134
_form = null;
135135

136136
/**
137-
*
138137
* @method hasAddressSuggestion
139138
* @summary returns true if we have a suggested address from a address validation service
140139
* @return {Boolean} - true if address suggestion on props
@@ -145,7 +144,6 @@ class AddressCapture extends Component {
145144
}
146145

147146
/**
148-
*
149147
* @method hasValidationError
150148
* @summary returns true if we have any validation errors from a address validation service
151149
* @return {Boolean} - true if validation errors on props
@@ -156,7 +154,6 @@ class AddressCapture extends Component {
156154
}
157155

158156
/**
159-
*
160157
* @method addressEntered
161158
* @summary getter that returns the entered address
162159
* @return {Object} addressEntered - Address object
@@ -167,7 +164,6 @@ class AddressCapture extends Component {
167164
}
168165

169166
/**
170-
*
171167
* @method addressSuggestion
172168
* @summary getter that returns the suggested address
173169
* @return {Object} addressSuggestion - Address object
@@ -178,7 +174,6 @@ class AddressCapture extends Component {
178174
}
179175

180176
/**
181-
*
182177
* @method addressProvided
183178
* @summary getter that returns the provided address form value
184179
* @return {Object} addressProvided - Address object
@@ -189,50 +184,46 @@ class AddressCapture extends Component {
189184
}
190185

191186
/**
192-
*
193187
* @method inEntry
194188
* @summary getter that returns true if in entry mode
195-
* @return {Boolean}
189+
* @return {Boolean} True if currently in entry status
196190
*/
197191
get inEntry() {
198192
const { status } = this.state;
199193
return status === ENTRY;
200194
}
201195

202196
/**
203-
*
204197
* @method inEdit
205198
* @summary getter that returns true if in edit mode
206-
* @return {Boolean}
199+
* @return {Boolean} True if currently in edit status
207200
*/
208201
get inEdit() {
209202
const { status } = this.state;
210203
return status === EDIT;
211204
}
212205

213206
/**
214-
*
215207
* @method inReview
216208
* @summary getter that returns true if in review mode
217-
* @return {Boolean}
209+
* @return {Boolean} True if currently in review status
218210
*/
219211
get inReview() {
220212
const { status } = this.state;
221213
return status === REVIEW;
222214
}
223215

224216
/**
225-
*
226217
* @method toggleStatus
227218
* @summary setter that toggles the Component's status.
219+
* @param {String} status The new status
228220
* @return {undefined}
229221
*/
230222
set toggleStatus(status) {
231223
this.setState({ status });
232224
}
233225

234226
/**
235-
*
236227
* @method formRef
237228
* @summary binds the active form element to the `_form` property
238229
* @param {Object} form - React ref element
@@ -243,8 +234,7 @@ class AddressCapture extends Component {
243234
};
244235

245236
/**
246-
*
247-
* @name submit
237+
* @method submit
248238
* @summary Instance method that submits the form, this allows a parent component access to the Form submit event.
249239
* @return {undefined}
250240
*/
@@ -253,10 +243,9 @@ class AddressCapture extends Component {
253243
};
254244

255245
/**
256-
*
257246
* @method handleSubmit
258247
* @summary validate or submit the entered address object.
259-
* @param {Object} address - submited address object
248+
* @param {Object} address - submitted address object
260249
* @return {undefined}
261250
*/
262251
handleSubmit = async (address) => {

package/src/components/AddressReview/v1/AddressReview.test.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,29 @@ const mockAddressSuggestion = {
2727
};
2828

2929
test("basic snapshot with only required props", () => {
30-
const component = renderer.create(<AddressReview
31-
addressEntered={mockAddressEntered}
32-
addressSuggestion={mockAddressSuggestion}
33-
components={mockComponents}
34-
/>);
30+
const component = renderer.create((
31+
<AddressReview
32+
addressEntered={mockAddressEntered}
33+
addressSuggestion={mockAddressSuggestion}
34+
components={mockComponents}
35+
/>
36+
));
3537

3638
const tree = component.toJSON();
3739
expect(tree).toMatchSnapshot();
3840
});
3941

4042
test("basic snapshot with all props", () => {
41-
const component = renderer.create(<AddressReview
42-
addressEntered={mockAddressEntered}
43-
addressSuggestion={mockAddressSuggestion}
44-
components={mockComponents}
45-
value="entered"
46-
warningTitle="Warning"
47-
warningMessage="Something is wrong"
48-
/>);
43+
const component = renderer.create((
44+
<AddressReview
45+
addressEntered={mockAddressEntered}
46+
addressSuggestion={mockAddressSuggestion}
47+
components={mockComponents}
48+
value="entered"
49+
warningTitle="Warning"
50+
warningMessage="Something is wrong"
51+
/>
52+
));
4953

5054
const tree = component.toJSON();
5155
expect(tree).toMatchSnapshot();

package/src/components/ErrorsBlock/v1/ErrorsBlock.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,4 @@ class ErrorsBlock extends Component {
9898
}
9999
}
100100

101-
const WrappedErrorsBlock = withComponents(ErrorsBlock);
102-
103-
WrappedErrorsBlock.isFormErrors = true;
104-
105-
export default WrappedErrorsBlock;
101+
export default withComponents(ErrorsBlock);

package/src/components/FinalReviewCheckoutAction/v1/FinalReviewCheckoutAction.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ const Items = styled.div`
3535
`;
3636

3737
class FinalReviewCheckoutAction extends Component {
38+
// Checkout review is the final step so it has no complete state
39+
static renderComplete = () => null;
40+
3841
static propTypes = {
3942
/**
4043
* Cart data
@@ -182,10 +185,4 @@ class FinalReviewCheckoutAction extends Component {
182185
}
183186
}
184187

185-
const WrappedFinalReviewCheckoutAction = withComponents(FinalReviewCheckoutAction);
186-
187-
// Checkout review is the final step so it has no complete state
188-
// eslint-disable-next-line
189-
WrappedFinalReviewCheckoutAction.renderComplete = () => null
190-
191-
export default WrappedFinalReviewCheckoutAction;
188+
export default withComponents(FinalReviewCheckoutAction);

package/src/components/FulfillmentOptionsCheckoutAction/v1/FulfillmentOptionsCheckoutAction.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ const FulfillmentOptionShape = PropTypes.shape({
3030
});
3131

3232
class FulfillmentOptionsCheckoutAction extends Component {
33+
static renderComplete({ fulfillmentGroup: { selectedFulfillmentOption } }) {
34+
return (
35+
<FulfillmentOption>
36+
{selectedFulfillmentOption.fulfillmentMethod.displayName}{selectedFulfillmentOption.price.displayAmount}
37+
</FulfillmentOption>
38+
);
39+
}
40+
3341
static propTypes = {
3442
/**
3543
* Alert object provides alert into to InlineAlert.
@@ -183,13 +191,4 @@ class FulfillmentOptionsCheckoutAction extends Component {
183191
}
184192
}
185193

186-
const WrappedFullfillmentOptionsCheckoutAction = withComponents(FulfillmentOptionsCheckoutAction);
187-
188-
// eslint-disable-next-line
189-
WrappedFullfillmentOptionsCheckoutAction.renderComplete = ({ fulfillmentGroup: { selectedFulfillmentOption } }) => (
190-
<FulfillmentOption>
191-
{selectedFulfillmentOption.fulfillmentMethod.displayName}{selectedFulfillmentOption.price.displayAmount}
192-
</FulfillmentOption>
193-
);
194-
195-
export default WrappedFullfillmentOptionsCheckoutAction;
194+
export default withComponents(FulfillmentOptionsCheckoutAction);

package/src/components/InlineAlert/v1/InlineAlert.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,5 @@ class InlineAlert extends Component {
175175
);
176176
}
177177
}
178-
const WrappedInlineAlert = withComponents(InlineAlert);
179178

180-
export default WrappedInlineAlert;
179+
export default withComponents(InlineAlert);

package/src/components/PhoneNumberInput/v1/PhoneNumberInput.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,4 @@ class PhoneNumberInput extends Component {
479479
}
480480
}
481481

482-
const WrappedPhoneNumberInput = withComponents(PhoneNumberInput);
483-
484-
WrappedPhoneNumberInput.isFormInput = true;
485-
486-
export default WrappedPhoneNumberInput;
482+
export default withComponents(PhoneNumberInput);

package/src/components/RegionInput/v1/RegionInput.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,4 @@ class RegionInput extends Component {
8080
}
8181
}
8282

83-
const WrappedRegionInput = withComponents(RegionInput);
84-
85-
WrappedRegionInput.isFormInput = true;
86-
87-
export default WrappedRegionInput;
83+
export default withComponents(RegionInput);

package/src/components/SelectableList/v1/SelectableList.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,4 @@ class SelectableList extends Component {
359359
}
360360
}
361361

362-
const WrappedSelectableList = withComponents(SelectableList);
363-
364-
WrappedSelectableList.isFormInput = true;
365-
366-
export default WrappedSelectableList;
362+
export default withComponents(SelectableList);

0 commit comments

Comments
 (0)