refactor(client): current-challenge-link to TypeScript
This commit is contained in:
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Link, Spacer, Loader, FullWidthRow } from '../helpers';
|
import { Link, Spacer, Loader, FullWidthRow } from '../helpers';
|
||||||
import { randomQuote } from '../../utils/get-words';
|
import { randomQuote } from '../../utils/get-words';
|
||||||
import CurrentChallengeLink from '../helpers/CurrentChallengeLink';
|
import CurrentChallengeLink from '../helpers/current-challenge-link';
|
||||||
import IntroDescription from './components/IntroDescription';
|
import IntroDescription from './components/IntroDescription';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
@ -1,18 +1,22 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import envData from '../../../../config/env.json';
|
import envData from '../../../../config/env.json';
|
||||||
|
|
||||||
const { apiLocation } = envData;
|
interface EnvData {
|
||||||
|
apiLocation?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { apiLocation } = envData as EnvData;
|
||||||
|
|
||||||
const currentChallengeApi = '/challenges/current-challenge';
|
const currentChallengeApi = '/challenges/current-challenge';
|
||||||
|
|
||||||
const propTypes = {
|
function CurrentChallengeLink({
|
||||||
children: PropTypes.any,
|
children,
|
||||||
isLargeBtn: PropTypes.bool
|
isLargeBtn
|
||||||
};
|
}: {
|
||||||
|
children?: React.ReactNode;
|
||||||
function CurrentChallengeLink({ children, isLargeBtn }) {
|
isLargeBtn?: boolean;
|
||||||
|
}): JSX.Element {
|
||||||
let classNames;
|
let classNames;
|
||||||
if (isLargeBtn) {
|
if (isLargeBtn) {
|
||||||
classNames = 'btn btn-lg btn-primary btn-block';
|
classNames = 'btn btn-lg btn-primary btn-block';
|
||||||
@ -20,13 +24,15 @@ function CurrentChallengeLink({ children, isLargeBtn }) {
|
|||||||
classNames = 'btn btn-primary btn-block';
|
classNames = 'btn btn-primary btn-block';
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<a className={classNames} href={`${apiLocation}${currentChallengeApi}`}>
|
<a
|
||||||
|
className={classNames}
|
||||||
|
href={`${apiLocation as string}${currentChallengeApi}`}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentChallengeLink.displayName = 'CurrentChallengeLink';
|
CurrentChallengeLink.displayName = 'CurrentChallengeLink';
|
||||||
CurrentChallengeLink.propTypes = propTypes;
|
|
||||||
|
|
||||||
export default CurrentChallengeLink;
|
export default CurrentChallengeLink;
|
@ -5,7 +5,7 @@ export { default as Loader } from './loader';
|
|||||||
export { default as SkeletonSprite } from './skeleton-sprite';
|
export { default as SkeletonSprite } from './skeleton-sprite';
|
||||||
export { default as Spacer } from './spacer';
|
export { default as Spacer } from './spacer';
|
||||||
export { default as Link } from './link';
|
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 ImageLoader } from './image-loader';
|
||||||
export { default as AvatarRenderer } from './AvatarRenderer';
|
export { default as AvatarRenderer } from './AvatarRenderer';
|
||||||
export { default as borderColorPicker } from './borderColorPicker';
|
export { default as borderColorPicker } from './borderColorPicker';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"include": ["./i18n/**/*", "./plugins/**/*","./src/**/*","./utils/**/*"],
|
"include": ["./i18n/**/*", "./plugins/**/*", "./src/**/*", "./utils/**/*"],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2020",
|
"target": "es2020",
|
||||||
"module": "es2020",
|
"module": "es2020",
|
||||||
@ -11,6 +11,7 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"skipLibCheck": true
|
"skipLibCheck": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user