| 4 | import {Link} from 'react-router-dom'; |
| 5 | |
| 6 | const CustomButton: React.FC<CustomButtonProps> = props => { |
| 7 | const renderIcon = () => { |
| 8 | return props.icon && <IconButton>props.icon</IconButton>; |
| 9 | }; |
| 10 | |
| 11 | const renderBtnContent = () => { |
| 12 | return ( |
| 13 | <> |
| 14 | {props.label} |
| 15 | {renderIcon()} |
| 16 | </> |
| 17 | ); |
| 18 | }; |
| 19 | const button_component = ( |
| 20 | <Link to={props.href ? props.href : '#'}> |
| 21 | <Button |
| 22 | variant={props.variant} |
| 23 | color={props.color} |
| 24 | size={props.size} |
| 25 | disabled={props.disabled || props.loading} |
| 26 | onClick={props.onClick} |
| 27 | > |
| 28 | {renderBtnContent()} |
| 29 | </Button> |
| 30 | </Link> |
| 31 | ); |
| 32 | return ( |
| 33 | <> |
| 34 | {props.title ? ( |
| 35 | <Tooltip title={props.title} placement={props.placement}> |
| 36 | {button_component} |
| 37 | </Tooltip> |
| 38 | ) : ( |
| 39 | button_component |
| 40 | )} |
| 41 | </> |
| 42 | ); |
| 43 | }; |
| 44 | |
| 45 | CustomButton.propTypes = { |
| 46 | label: PropTypes.string.isRequired, |
nothing calls this directly
no test coverage detected