fix(client): adjust project link logic to show files (#42717)

pull/42803/head
Shaun Hamilton 2021-07-09 04:00:04 +01:00 committed by GitHub
parent 6a562571ba
commit d95962e405
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -23,14 +23,14 @@ interface IShowProjectLinksProps {
type SolutionStateType = {
projectTitle: string;
challengeFiles: ChallengeFileType[] | null;
files?: ChallengeFileType[] | null;
solution: CompletedChallenge['solution'];
isOpen: boolean;
};
const initSolutionState: SolutionStateType = {
projectTitle: '',
challengeFiles: null,
files: null,
solution: null,
isOpen: false
};
@ -55,16 +55,16 @@ const ShowProjectLinks = (props: IShowProjectLinksProps): JSX.Element => {
return null;
}
const { solution, githubLink, challengeFiles } = completedProject;
const { solution, githubLink, files } = completedProject;
const onClickHandler = () =>
setSolutionState({
projectTitle,
challengeFiles,
files,
solution,
isOpen: true
});
if (challengeFiles) {
if (files) {
return (
<button
className='project-link-button-override'
@ -162,7 +162,7 @@ const ShowProjectLinks = (props: IShowProjectLinksProps): JSX.Element => {
name,
user: { username }
} = props;
const { challengeFiles, isOpen, projectTitle, solution } = solutionState;
const { files, isOpen, projectTitle, solution } = solutionState;
return (
<div>
{t(
@ -176,7 +176,7 @@ const ShowProjectLinks = (props: IShowProjectLinksProps): JSX.Element => {
<Spacer />
{isOpen ? (
<ProjectModal
files={challengeFiles}
files={files}
handleSolutionModalHide={handleSolutionModalHide}
isOpen={isOpen}
projectTitle={projectTitle}

View File

@ -305,6 +305,8 @@ export type CompletedChallenge = {
challengeType?: number;
completedDate: number;
challengeFiles: ChallengeFileType[] | null;
// TODO: remove once files->challengeFiles is refactored
files?: ChallengeFileType[] | null;
};
// TODO: renames: files => challengeFiles; key => fileKey; #42489
export type ChallengeFileType =