generated from freeCodeCamp/template
-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated details dashboard logic to avoid merging 3 APIs and utilize f… (
#488) * Updated details dashboard logic to avoid merging 3 APIs and utilize funtions instead. Updated snapshot tests to accomodate new props associated with details dashboard ammendment. Minor name changes to old variables to be more specific Co-authored-by: Guillermo Flores V <hello@gfloresv.dev> Co-authored-by: Komal Kaur <kaur91499@gmail.com> Co-authored-by: Utsab Saha <utsab.k.saha@gmail.com> Co-authored-by: Edgar Peralta <https://github.com/EPeralta18> * [CodeFactor] Apply fixes to commit 9a093f4 --------- Co-authored-by: Guillermo Flores V <hello@gfloresv.dev> Co-authored-by: Komal Kaur <kaur91499@gmail.com> Co-authored-by: Utsab Saha <utsab.k.saha@gmail.com> Co-authored-by: codefactor-io <support@codefactor.io>
- Loading branch information
1 parent
e28118d
commit b9e5a4e
Showing
9 changed files
with
514 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.student_header { | ||
display: flex; | ||
font-size: 1.1rem; | ||
margin: 10px; | ||
border-bottom: 2px solid purple; | ||
color: navy; | ||
font-weight: 100; | ||
background-color: hsl(194, 35%, 76%); | ||
max-width: fit-content; | ||
} | ||
|
||
.board_container { | ||
border: 4px solid black; | ||
padding: 10px; | ||
margin: 0px 5px 1px; | ||
background-color: grey; | ||
color: white; | ||
} | ||
|
||
.list_container { | ||
display: flex; | ||
|
||
flex-direction: row; | ||
align-items: center; | ||
gap: 10px; | ||
} | ||
|
||
.list_container h1 { | ||
font-weight: bold; | ||
font-size: 1.2rem; | ||
} | ||
.list_container button { | ||
font-size: 0.7rem; | ||
text-transform: uppercase; | ||
border: 1px solid navy; | ||
|
||
padding: 5px 10px; | ||
background-color: orange; | ||
} | ||
|
||
.list_container button:hover { | ||
background-color: rgb(89, 103, 174); | ||
color: white; | ||
} | ||
.inner_comp { | ||
background-color: grey; | ||
color: white; | ||
} | ||
|
||
.details_progress_stats { | ||
background-color: rgb(27, 15, 86); | ||
color: white; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
border: 1px solid rgb(93, 0, 255); | ||
padding: 10px; | ||
} | ||
|
||
.detailsBlockTitle { | ||
font-size: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import styles from './DetailsCSS.module.css'; | ||
import DetailsDashboardList from './DetailsDashboardList'; | ||
//getStudentProgressInSuperblock | ||
|
||
import { getStudentProgressInSuperblock } from '../util/api_proccesor'; | ||
|
||
export default function DetailsDashboard(props) { | ||
const printSuperblockTitle = individualSuperblockJSON => { | ||
let indexOfTitleInSuperblockTitlesArray = | ||
props.superblocksDetailsJSONArray.indexOf(individualSuperblockJSON); | ||
let superblockTitle = | ||
props.superblockTitles[indexOfTitleInSuperblockTitlesArray]; | ||
return superblockTitle; | ||
}; | ||
|
||
const superblockProgress = superblockDashedName => { | ||
let studentProgress = props.studentData; | ||
|
||
return getStudentProgressInSuperblock( | ||
studentProgress, | ||
superblockDashedName | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
{props.superblocksDetailsJSONArray.map((arrayOfBlockObjs, idx) => { | ||
let index = props.superblocksDetailsJSONArray.indexOf(arrayOfBlockObjs); | ||
let superblockDashedName = | ||
props.superblocksDetailsJSONArray[index][0].superblock; | ||
let progressInBlocks = superblockProgress(superblockDashedName); | ||
let superblockTitle = printSuperblockTitle(arrayOfBlockObjs); | ||
return ( | ||
<div key={idx} className={styles.board_container}> | ||
<DetailsDashboardList | ||
superblockTitle={superblockTitle} | ||
blockData={arrayOfBlockObjs} | ||
studentProgressInBlocks={progressInBlocks} | ||
></DetailsDashboardList> | ||
</div> | ||
); | ||
})} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react'; | ||
import { useState } from 'react'; | ||
import styles from './DetailsCSS.module.css'; | ||
import { getStudentTotalChallengesCompletedInBlock } from '../util/api_proccesor'; | ||
|
||
export default function DetailsDashboardList(props) { | ||
const [hideDetails, setHideDetails] = useState(true); | ||
const [buttonText, setButtonText] = useState('View details'); | ||
|
||
const handleShowDetails = () => { | ||
if (hideDetails) { | ||
setHideDetails(false); | ||
} else { | ||
setHideDetails(true); | ||
} | ||
|
||
handleButtonText(hideDetails); | ||
}; | ||
|
||
const handleButtonText = hideDetails => { | ||
if (hideDetails) { | ||
setButtonText('View less'); | ||
} else { | ||
setButtonText('View details'); | ||
} | ||
}; | ||
|
||
const getStudentsProgressInBlock = blockName => { | ||
return getStudentTotalChallengesCompletedInBlock( | ||
props.studentProgressInBlocks, | ||
blockName | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className={styles.list_container}> | ||
<h1>{props.superblockTitle} </h1> | ||
|
||
<button onClick={handleShowDetails}>{buttonText}</button> | ||
</div> | ||
<div className={styles.inner_comp}> | ||
{hideDetails ? ( | ||
'' | ||
) : ( | ||
<> | ||
<ul> | ||
<li> | ||
{props.blockData.map((blockDetails, idx) => { | ||
return ( | ||
<div className={styles.details_progress_stats} key={idx}> | ||
<h1 className={styles.detailsBlockTitle}> | ||
{blockDetails.blockName} | ||
</h1> | ||
<h1 className={styles.focus}> | ||
{getStudentsProgressInBlock(blockDetails.selector) + | ||
'/' + | ||
blockDetails.allChallenges.length} | ||
</h1> | ||
</div> | ||
); | ||
})} | ||
</li> | ||
</ul> | ||
</> | ||
)} | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.