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

This commit is contained in:
Shaun Hamilton
2021-07-09 04:00:04 +01:00
committed by GitHub
parent 6a562571ba
commit d95962e405
2 changed files with 9 additions and 7 deletions

View File

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

View File

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