2021-06-15 10:37:13 -05:00
|
|
|
/* eslint-disable max-len */
|
|
|
|
|
|
|
|
// Package Utilities
|
2021-08-02 15:39:40 +02:00
|
|
|
import { graphql } from 'gatsby';
|
2021-06-15 10:37:13 -05:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import Helmet from 'react-helmet';
|
2021-08-02 15:39:40 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { bindActionCreators } from 'redux';
|
2021-06-25 09:59:33 -05:00
|
|
|
import type { Dispatch } from 'redux';
|
2021-06-15 10:37:13 -05:00
|
|
|
|
|
|
|
// Local Utilities
|
2021-06-29 19:31:22 +05:30
|
|
|
import LearnLayout from '../../../components/layouts/learn';
|
2021-06-25 09:59:33 -05:00
|
|
|
import {
|
|
|
|
ChallengeNodeType,
|
|
|
|
ChallengeMetaType
|
|
|
|
} from '../../../redux/prop-types';
|
2021-06-15 10:37:13 -05:00
|
|
|
import { updateChallengeMeta, challengeMounted } from '../redux';
|
|
|
|
// Redux
|
|
|
|
const mapStateToProps = () => ({});
|
2021-06-25 09:59:33 -05:00
|
|
|
const mapDispatchToProps = (dispatch: Dispatch) =>
|
2021-06-15 10:37:13 -05:00
|
|
|
bindActionCreators(
|
|
|
|
{
|
|
|
|
updateChallengeMeta,
|
|
|
|
challengeMounted
|
|
|
|
},
|
|
|
|
dispatch
|
|
|
|
);
|
|
|
|
|
2021-06-25 09:59:33 -05:00
|
|
|
// Types
|
|
|
|
interface ShowCodeAllyProps {
|
|
|
|
data: { challengeNode: ChallengeNodeType };
|
|
|
|
pageContext: {
|
|
|
|
challengeMeta: ChallengeMetaType;
|
|
|
|
};
|
|
|
|
updateChallengeMeta: (arg0: ChallengeMetaType) => void;
|
|
|
|
}
|
2021-06-15 10:37:13 -05:00
|
|
|
|
|
|
|
// Component
|
2021-06-25 09:59:33 -05:00
|
|
|
class ShowCodeAlly extends Component<ShowCodeAllyProps> {
|
|
|
|
static displayName: string;
|
|
|
|
componentDidMount(): void {
|
2021-06-15 10:37:13 -05:00
|
|
|
const {
|
|
|
|
updateChallengeMeta,
|
|
|
|
data: {
|
|
|
|
challengeNode: { challengeType, title }
|
|
|
|
},
|
|
|
|
pageContext: { challengeMeta }
|
|
|
|
} = this.props;
|
|
|
|
updateChallengeMeta({ ...challengeMeta, title, challengeType });
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
title,
|
|
|
|
fields: { blockName },
|
|
|
|
url
|
|
|
|
} = this.props.data.challengeNode;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<LearnLayout>
|
|
|
|
<Helmet title={`${blockName}: ${title} | freeCodeCamp.org`} />
|
|
|
|
<iframe
|
2021-09-23 17:31:56 +02:00
|
|
|
className='codeally-frame'
|
2021-06-25 09:59:33 -05:00
|
|
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
2021-09-23 17:31:56 +02:00
|
|
|
sandbox='allow-modals allow-forms allow-popups allow-scripts allow-same-origin'
|
2021-10-27 00:46:45 +02:00
|
|
|
src={`https://codeally.io/embed/?repoUrl=${url}`}
|
2021-06-15 10:37:13 -05:00
|
|
|
title='Editor'
|
|
|
|
/>
|
|
|
|
</LearnLayout>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowCodeAlly.displayName = 'ShowCodeAlly';
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ShowCodeAlly);
|
|
|
|
|
|
|
|
// GraphQL
|
|
|
|
export const query = graphql`
|
|
|
|
query CodeAllyChallenge($slug: String!) {
|
|
|
|
challengeNode(fields: { slug: { eq: $slug } }) {
|
|
|
|
title
|
|
|
|
challengeType
|
|
|
|
url
|
|
|
|
fields {
|
|
|
|
blockName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|