fix: replace hardgoto with api links
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
5409e1e62e
commit
a7d595f349
@@ -1,30 +1,16 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { apiLocation } from '../../../config/env.json';
|
||||
|
||||
import { hardGoTo } from '../../redux';
|
||||
|
||||
const currentChallengeApi = '/challenges/current-challenge';
|
||||
|
||||
const propTypes = {
|
||||
children: PropTypes.any,
|
||||
hardGoTo: PropTypes.func.isRequired,
|
||||
isLargeBtn: PropTypes.bool
|
||||
};
|
||||
|
||||
const mapStateToProps = () => ({});
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators({ hardGoTo }, dispatch);
|
||||
|
||||
const createClickHandler = hardGoTo => e => {
|
||||
e.preventDefault();
|
||||
return hardGoTo(`${apiLocation}${currentChallengeApi}`);
|
||||
};
|
||||
|
||||
function CurrentChallengeLink({ children, hardGoTo, isLargeBtn }) {
|
||||
function CurrentChallengeLink({ children, isLargeBtn }) {
|
||||
let classNames;
|
||||
if (isLargeBtn) {
|
||||
classNames = 'btn btn-lg btn-primary btn-block';
|
||||
@@ -32,11 +18,7 @@ function CurrentChallengeLink({ children, hardGoTo, isLargeBtn }) {
|
||||
classNames = 'btn btn-cta-big btn-primary btn-block';
|
||||
}
|
||||
return (
|
||||
<a
|
||||
className={classNames}
|
||||
href={currentChallengeApi}
|
||||
onClick={createClickHandler(hardGoTo)}
|
||||
>
|
||||
<a className={classNames} href={`${apiLocation}${currentChallengeApi}`}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
@@ -45,7 +27,4 @@ function CurrentChallengeLink({ children, hardGoTo, isLargeBtn }) {
|
||||
CurrentChallengeLink.displayName = 'CurrentChallengeLink';
|
||||
CurrentChallengeLink.propTypes = propTypes;
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(CurrentChallengeLink);
|
||||
export default CurrentChallengeLink;
|
||||
|
Reference in New Issue
Block a user