Skip to content

Commit d6ac389

Browse files
committed
fix(app-degree-pages): refactor defaultProps to use JS default params
1 parent e54b769 commit d6ac389

File tree

16 files changed

+71
-195
lines changed

16 files changed

+71
-195
lines changed

packages/app-rfi/src/components/AsuRfi/index.js

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ const currentScriptPath = getCurrentScriptPath();
2929
const AsuRfi = props => {
3030
const {
3131
appPathFolder,
32-
variant,
33-
campus,
34-
actualCampus,
35-
college,
36-
department,
37-
studentType,
38-
areaOfInterest,
39-
areaOfInterestOptional,
40-
programOfInterest,
41-
programOfInterestOptional,
42-
isCertMinor,
43-
country,
44-
stateProvince,
45-
successMsg,
46-
test,
47-
dataSourceDegreeSearch,
48-
dataSourceAsuOnline,
49-
dataSourceCountriesStates,
32+
variant = undefined,
33+
campus = undefined,
34+
actualCampus = undefined,
35+
college = undefined,
36+
department = undefined,
37+
studentType = undefined,
38+
areaOfInterest = undefined,
39+
areaOfInterestOptional = false,
40+
programOfInterest = undefined,
41+
programOfInterestOptional = false,
42+
isCertMinor = false,
43+
country = undefined,
44+
stateProvince = undefined,
45+
successMsg = undefined,
46+
test = false,
47+
dataSourceDegreeSearch = DATA_SOURCE.DEGREE_SEARCH,
48+
dataSourceAsuOnline = DATA_SOURCE.ASU_ONLINE,
49+
dataSourceCountriesStates = DATA_SOURCE.COUNTRIES_STATES,
5050
submissionUrl,
5151
} = props;
5252

@@ -134,28 +134,6 @@ const AsuRfi = props => {
134134

135135
export { AsuRfi };
136136

137-
// Props
138-
AsuRfi.defaultProps = {
139-
variant: undefined, // default set in appState
140-
campus: undefined,
141-
actualCampus: undefined,
142-
college: undefined,
143-
department: undefined,
144-
studentType: undefined,
145-
areaOfInterest: undefined,
146-
areaOfInterestOptional: false,
147-
programOfInterest: undefined,
148-
programOfInterestOptional: false,
149-
isCertMinor: false,
150-
country: undefined,
151-
stateProvince: undefined,
152-
successMsg: undefined,
153-
test: false,
154-
dataSourceDegreeSearch: DATA_SOURCE.DEGREE_SEARCH,
155-
dataSourceAsuOnline: DATA_SOURCE.ASU_ONLINE,
156-
dataSourceCountriesStates: DATA_SOURCE.COUNTRIES_STATES,
157-
};
158-
159137
AsuRfi.propTypes = {
160138
appPathFolder: PropTypes.string,
161139
variant: PropTypes.oneOf(["rfiVariant1", "rfiVariant2"]),

packages/app-rfi/src/components/controls/RfiCheckboxSingle.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const RfiCheckboxSingle = ({
1111
id,
1212
name,
1313
value,
14-
requiredIcon,
15-
required,
14+
requiredIcon = undefined,
15+
required = undefined,
1616
onBlur,
1717
}) => {
1818
const [field, meta] = useField({ name, type: "checkbox" });
@@ -41,11 +41,6 @@ const RfiCheckboxSingle = ({
4141
);
4242
};
4343

44-
RfiCheckboxSingle.defaultProps = {
45-
requiredIcon: undefined,
46-
required: undefined,
47-
};
48-
4944
RfiCheckboxSingle.propTypes = {
5045
children: PropTypes.node.isRequired,
5146
onBlur: PropTypes.func,

packages/app-rfi/src/components/controls/RfiDateInput.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { RfiLabel, RfiError } from "./controls-helpers";
1010
const RfiDateInput = ({
1111
label,
1212
name,
13-
id,
14-
requiredIcon,
15-
required,
16-
helperText,
17-
autoFocus,
13+
id = undefined,
14+
requiredIcon = undefined,
15+
required = undefined,
16+
helperText = undefined,
17+
autoFocus = undefined,
1818
onBlur,
1919
}) => {
2020
// Surface values from Formik context
@@ -75,14 +75,6 @@ const RfiDateInput = ({
7575
// duplicate the setting in our props got displaying the required icon until
7676
// Formik has a better way to do it.
7777

78-
RfiDateInput.defaultProps = {
79-
id: undefined,
80-
requiredIcon: undefined,
81-
required: undefined,
82-
autoFocus: undefined,
83-
helperText: undefined,
84-
};
85-
8678
RfiDateInput.propTypes = {
8779
label: PropTypes.string.isRequired,
8880
name: PropTypes.string.isRequired,

packages/app-rfi/src/components/controls/RfiEmailInput.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { RfiLabel, RfiError } from "./controls-helpers";
1010
const RfiEmailInput = ({
1111
name,
1212
label,
13-
id,
14-
requiredIcon,
15-
required,
16-
autoFocus,
13+
id = undefined,
14+
requiredIcon = undefined,
15+
required = undefined,
16+
autoFocus = undefined,
1717
onBlur,
1818
}) => (
1919
<Field name={name}>
@@ -45,13 +45,6 @@ const RfiEmailInput = ({
4545
</Field>
4646
);
4747

48-
RfiEmailInput.defaultProps = {
49-
id: undefined,
50-
requiredIcon: undefined,
51-
required: undefined,
52-
autoFocus: undefined,
53-
};
54-
5548
RfiEmailInput.propTypes = {
5649
id: PropTypes.string,
5750
label: PropTypes.string.isRequired,

packages/app-rfi/src/components/controls/RfiPhone.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import { RfiLabel, RfiError } from "./controls-helpers";
1414
const RfiPhone = ({
1515
label,
1616
name,
17-
id,
18-
requiredIcon,
19-
required,
20-
helperText,
17+
id = undefined,
18+
requiredIcon = undefined,
19+
required = undefined,
20+
helperText = undefined,
2121
onBlur,
2222
}) => {
2323
// Surface values from Formik context
@@ -85,13 +85,6 @@ const RfiPhone = ({
8585
// duplicate the setting in our props got displaying the required icon until
8686
// Formik has a better way to do it.
8787

88-
RfiPhone.defaultProps = {
89-
id: undefined,
90-
requiredIcon: undefined,
91-
required: undefined,
92-
helperText: undefined,
93-
};
94-
9588
RfiPhone.propTypes = {
9689
label: PropTypes.string.isRequired,
9790
name: PropTypes.string.isRequired,

packages/app-rfi/src/components/controls/RfiSelect.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import { RfiLabel, RfiError } from "./controls-helpers";
1111
// experienced using solely one of the other.
1212

1313
const RfiSelect = ({
14-
id,
14+
id = undefined,
1515
label,
1616
name,
17-
requiredIcon,
18-
required,
17+
requiredIcon = undefined,
18+
required = undefined,
1919
options,
20-
disabled,
21-
autoFocus,
20+
disabled = undefined,
21+
autoFocus = undefined,
2222
onBlur,
2323
}) => {
2424
const [field, meta, helpers] = useField({ name });
@@ -74,14 +74,6 @@ const RfiSelect = ({
7474
// duplicate the setting in our props for displaying the required icon until
7575
// Formik has a better way to do it.
7676

77-
RfiSelect.defaultProps = {
78-
id: undefined,
79-
requiredIcon: undefined,
80-
required: undefined,
81-
autoFocus: undefined,
82-
disabled: false,
83-
};
84-
8577
RfiSelect.propTypes = {
8678
id: PropTypes.string,
8779
label: PropTypes.string.isRequired,

packages/app-rfi/src/components/controls/RfiTextArea.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import { RfiLabel, RfiError } from "./controls-helpers";
1010
const RfiTextArea = ({
1111
label,
1212
name,
13-
id,
14-
requiredIcon,
15-
required,
16-
autoFocus,
17-
disabled,
18-
helperText,
13+
id = undefined,
14+
requiredIcon = undefined,
15+
required = undefined,
16+
autoFocus = undefined,
17+
disabled = undefined,
18+
helperText = undefined,
1919
onBlur,
2020
}) => (
2121
<Field name={name}>
@@ -52,15 +52,6 @@ const RfiTextArea = ({
5252
// duplicate the setting in our props got displaying the required icon until
5353
// Formik has a better way to do it.
5454

55-
RfiTextArea.defaultProps = {
56-
id: undefined,
57-
requiredIcon: undefined,
58-
required: undefined,
59-
autoFocus: undefined,
60-
disabled: false,
61-
helperText: undefined,
62-
};
63-
6455
RfiTextArea.propTypes = {
6556
label: PropTypes.string.isRequired,
6657
name: PropTypes.string.isRequired,

packages/app-rfi/src/components/controls/RfiTextInput.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { RfiLabel, RfiError } from "./controls-helpers";
1010
const RfiTextInput = ({
1111
label,
1212
name,
13-
id,
14-
requiredIcon,
15-
required,
16-
helperText,
17-
autoFocus,
13+
id = undefined,
14+
requiredIcon = undefined,
15+
required = undefined,
16+
helperText = undefined,
17+
autoFocus = undefined,
1818
onBlur,
1919
}) => {
2020
// Surface values from Formik context
@@ -69,14 +69,6 @@ const RfiTextInput = ({
6969
// duplicate the setting in our props got displaying the required icon until
7070
// Formik has a better way to do it.
7171

72-
RfiTextInput.defaultProps = {
73-
id: undefined,
74-
requiredIcon: undefined,
75-
required: undefined,
76-
autoFocus: undefined,
77-
helperText: undefined,
78-
};
79-
8072
RfiTextInput.propTypes = {
8173
label: PropTypes.string.isRequired,
8274
name: PropTypes.string.isRequired,

packages/app-rfi/src/components/controls/controls-helpers.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const GaEventPropTypes = {
1515
text: PropTypes.string,
1616
};
1717

18-
const RfiLabel = ({ label, name, id, requiredIcon }) => (
18+
const RfiLabel = ({ label, name, id = undefined, requiredIcon = undefined }) => (
1919
<label htmlFor={id || name}>
2020
{requiredIcon && (
2121
<>
@@ -29,7 +29,7 @@ const RfiLabel = ({ label, name, id, requiredIcon }) => (
2929
</label>
3030
);
3131

32-
const RfiLegend = ({ label, requiredIcon }) => (
32+
const RfiLegend = ({ label = undefined, requiredIcon = undefined }) => (
3333
<legend className="fw-bold">
3434
{requiredIcon && (
3535
<>
@@ -43,7 +43,7 @@ const RfiLegend = ({ label, requiredIcon }) => (
4343
</legend>
4444
);
4545

46-
const RfiError = ({ isError, metaError }) => (
46+
const RfiError = ({ isError = undefined, metaError = undefined }) => (
4747
<div role="alert">
4848
{isError && (
4949
<small className="form-text invalid-feedback">
@@ -59,33 +59,18 @@ const RfiError = ({ isError, metaError }) => (
5959
// duplicate the setting in our props got displaying the required icon until
6060
// Formik has a better way to do it.
6161

62-
RfiLabel.defaultProps = {
63-
id: undefined,
64-
requiredIcon: undefined,
65-
};
66-
6762
RfiLabel.propTypes = {
6863
label: PropTypes.string.isRequired,
6964
name: PropTypes.string.isRequired,
7065
id: PropTypes.string,
7166
requiredIcon: PropTypes.bool,
7267
};
7368

74-
RfiLegend.defaultProps = {
75-
label: undefined,
76-
requiredIcon: undefined,
77-
};
78-
7969
RfiLegend.propTypes = {
8070
label: PropTypes.string.isRequired,
8171
requiredIcon: PropTypes.bool,
8272
};
8373

84-
RfiError.defaultProps = {
85-
isError: undefined,
86-
metaError: undefined,
87-
};
88-
8974
RfiError.propTypes = {
9075
isError: PropTypes.bool,
9176
metaError: PropTypes.string,

packages/component-footer/src/components/Contact/index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ColumnSection } from "../ColumnSection";
1111
*/
1212

1313
const Contact = ({
14-
contact: { title, contactLink, contributionLink, columns },
14+
contact: { title = "", contactLink = "", contributionLink = "", columns = []},
1515
}) => {
1616
return (
1717
<div className="wrapper" id="wrapper-footer-columns" data-testid="contact">
@@ -72,12 +72,4 @@ Contact.propTypes = {
7272
}),
7373
};
7474

75-
Contact.defaultProps = {
76-
contact: {
77-
title: "",
78-
contactLink: "",
79-
contributionLink: "",
80-
},
81-
};
82-
8375
export { Contact };

0 commit comments

Comments
 (0)