refactor(client): current-challenge-link to TypeScript

This commit is contained in:
Marlon Johnson
2021-06-21 13:51:04 -07:00
parent 6d88a95e0a
commit 9767ee6bbc
4 changed files with 21 additions and 14 deletions

View File

@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Link, Spacer, Loader, FullWidthRow } from '../helpers';
import { randomQuote } from '../../utils/get-words';
import CurrentChallengeLink from '../helpers/CurrentChallengeLink';
import CurrentChallengeLink from '../helpers/current-challenge-link';
import IntroDescription from './components/IntroDescription';
import { Trans, useTranslation } from 'react-i18next';

View File

@ -1,18 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import envData from '../../../../config/env.json';
const { apiLocation } = envData;
interface EnvData {
apiLocation?: string;
}
const { apiLocation } = envData as EnvData;
const currentChallengeApi = '/challenges/current-challenge';
const propTypes = {
children: PropTypes.any,
isLargeBtn: PropTypes.bool
};
function CurrentChallengeLink({ children, isLargeBtn }) {
function CurrentChallengeLink({
children,
isLargeBtn
}: {
children?: React.ReactNode;
isLargeBtn?: boolean;
}): JSX.Element {
let classNames;
if (isLargeBtn) {
classNames = 'btn btn-lg btn-primary btn-block';
@ -20,13 +24,15 @@ function CurrentChallengeLink({ children, isLargeBtn }) {
classNames = 'btn btn-primary btn-block';
}
return (
<a className={classNames} href={`${apiLocation}${currentChallengeApi}`}>
<a
className={classNames}
href={`${apiLocation as string}${currentChallengeApi}`}
>
{children}
</a>
);
}
CurrentChallengeLink.displayName = 'CurrentChallengeLink';
CurrentChallengeLink.propTypes = propTypes;
export default CurrentChallengeLink;

View File

@ -5,7 +5,7 @@ export { default as Loader } from './loader';
export { default as SkeletonSprite } from './skeleton-sprite';
export { default as Spacer } from './spacer';
export { default as Link } from './link';
export { default as CurrentChallengeLink } from './CurrentChallengeLink';
export { default as CurrentChallengeLink } from './current-challenge-link';
export { default as ImageLoader } from './image-loader';
export { default as AvatarRenderer } from './AvatarRenderer';
export { default as borderColorPicker } from './borderColorPicker';

View File

@ -11,6 +11,7 @@
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmit": true,
"skipLibCheck": true
"skipLibCheck": true,
"resolveJsonModule": true
}
}