Skip to content

Commit

Permalink
convert radio.js to tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ChancellorO committed Nov 9, 2023
1 parent 38e769b commit d9af311
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/components/common/Radio.js → src/components/common/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,32 @@ import '../../styles/Radio.scss';
* changes handle click to be called with all selected values
*/

export default class Radio extends React.Component {
constructor(props) {
interface OptionItem {
display : string;
value : number;
}
interface OptionsArray extends Array<OptionItem>{}

interface RadioProps {
defaultSelected ?: any;
allowMultipleSelected ?: boolean;
options : OptionsArray;
containerStyle : any;
optionStyle : any;
selectedOptionStyle : any;
selectedBgColor : any;
selectedColor : any;
bgColor : any;
color : any;
handleClick : any;
}

interface RadioState {
selected ?: any;
}

export default class Radio extends React.Component <RadioProps, RadioState> {
constructor(props : RadioProps) {
super(props);

let selected = this.props.defaultSelected;
Expand All @@ -39,7 +63,7 @@ export default class Radio extends React.Component {
};
}

updateSelectedState = (selected, alreadySelected) => {
updateSelectedState = (selected : number, alreadySelected : boolean) : void => {
if (this.props.allowMultipleSelected) {
let newState = this.state.selected;
if (alreadySelected) {
Expand All @@ -60,7 +84,7 @@ export default class Radio extends React.Component {
}
};

renderOption = ({ display, value }, index) => {
renderOption = ({ display, value } : {display: string, value: number}, index : number) : JSX.Element => {
// if no value is provided, use the index
value = value || index;

Expand Down

0 comments on commit d9af311

Please sign in to comment.