-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Caceves/appeals 53755 code climate fixes (#22427)
* Code climate fixes initial commit * Added proptypes to tooltiphelper file * Jest fixes * Updated jest snap shots * Fix for dentical blocks of code being found in multiple locations for radio input field * Lint fixes * Jest fixes * Jest fixes updating the snapshots * Codeclimate fixes for const props * testing the duplication error fix for jest * User tests 'FeatureToggle.enabled?(:correspondence_queue)' at least 3 times * Add ignore for pdf offense * Complexity fixes --------- Co-authored-by: divyadasari-va <divya.dasari@va.gov> Co-authored-by: divyadasari-va <135847343+divyadasari-va@users.noreply.github.com>
- Loading branch information
1 parent
63165da
commit eca8845
Showing
16 changed files
with
3,771 additions
and
1,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ACD_LEVERS from '../../constants/ACD_LEVERS'; | ||
|
||
const RadioInput = ({ handleChange, name, idPart, option, controlled, value, inputRef, inputProps }) => { | ||
const isChecked = controlled ? value === option.value : option.checked; | ||
|
||
return ( | ||
<input | ||
onChange={handleChange} | ||
name={name} | ||
type={ACD_LEVERS.data_types.radio} | ||
id={`${idPart}_${option.value}`} | ||
value={option.value} | ||
checked={isChecked} | ||
disabled={Boolean(option.disabled)} | ||
ref={inputRef} | ||
{...inputProps} | ||
/> | ||
); | ||
}; | ||
|
||
RadioInput.propTypes = { | ||
handleChange: PropTypes.func.isRequired, | ||
name: PropTypes.string.isRequired, | ||
idPart: PropTypes.string.isRequired, | ||
option: PropTypes.object.isRequired, | ||
controlled: PropTypes.bool.isRequired, | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]).isRequired, | ||
inputRef: PropTypes.oneOfType([ | ||
PropTypes.func, | ||
PropTypes.shape({ current: PropTypes.instanceOf(Element) }), | ||
]), | ||
inputProps: PropTypes.object, | ||
}; | ||
|
||
export default RadioInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Tooltip from './Tooltip'; | ||
|
||
const MaybeAddTooltip = ({ option, children }) => { | ||
if (!option.tooltipText) { | ||
return children; | ||
} | ||
|
||
const keyId = `tooltip-${option.value}`; | ||
|
||
return ( | ||
<Tooltip | ||
key={keyId} | ||
id={keyId} | ||
text={option.tooltipText} | ||
position="right" | ||
className="cf-radio-option-tooltip" | ||
offset={{ right: 15 }} | ||
> | ||
{children} | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
MaybeAddTooltip.propTypes = { | ||
option: PropTypes.shape({ | ||
tooltipText: PropTypes.string, | ||
value: PropTypes.string.isRequired, | ||
}).isRequired, | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
export default MaybeAddTooltip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const extractFieldProps = (props) => { | ||
const { id, className, label, inputRef } = props; | ||
return { id, className, label, inputRef }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.