diff --git a/src/App.tsx b/src/App.tsx index 2dfc562..1229ac2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,12 @@ +import Results from './Results'; import Table from './Table'; import usePersistence from './usePersistence'; -export default function App(): JSX.Element { - const { state, select } = usePersistence(); +export default function App(): JSX.Element { + const { state, select, mark, note } = usePersistence(); return ( -
+ <>

Ervaringskompas

Welke ervaring heb je opgedaan met deze beroepsactiviteit in de praktijk @@ -19,7 +20,10 @@ export default function App(): JSX.Element { ))}

- - +
+
+
+ + ); } diff --git a/src/CompetenceResult.tsx b/src/CompetenceResult.tsx new file mode 100644 index 0000000..77c23bb --- /dev/null +++ b/src/CompetenceResult.tsx @@ -0,0 +1,51 @@ +import { MAX_LEVEL, State } from './usePersistence'; + +export default function CompetenceResult({ + state, +}: { + state: State; +}): JSX.Element { + const results = state.competences.map((competence, index) => { + const [score, max] = state.themes.reduce( + (acc, theme) => { + const [score, max] = theme.experiences.reduce( + (acc, exp) => { + return [ + acc[0] + exp.competences[index] * exp.level, + acc[1] + exp.competences[index] * MAX_LEVEL, + ]; + }, + [0, 0] + ); + return [acc[0] + score, acc[1] + max]; + }, + [0, 0] + ); + + return { + competence, + percentage: Math.round((score / max) * 100), + }; + }); + + return ( +
+ + {results.map(({ competence, percentage }) => ( + + + + + + ))} + +
{competence}{percentage}% +
+
+ ); +} diff --git a/src/ExperienceRow.tsx b/src/ExperienceRow.tsx index 975320f..70e0297 100644 --- a/src/ExperienceRow.tsx +++ b/src/ExperienceRow.tsx @@ -1,14 +1,26 @@ interface ExperienceRowProps { name: string; - themeIndex: number, + themeIndex: number; index: number; color: string; levels: string[]; selected: number; + marked: boolean; + onMark: (marked: boolean) => void; onSelect: (level: number) => void; } -export default function ExperienceRow({ name, themeIndex, index, color, levels, selected, onSelect }: ExperienceRowProps): JSX.Element { +export default function ExperienceRow({ + name, + themeIndex, + index, + color, + levels, + marked, + selected, + onMark, + onSelect, +}: ExperienceRowProps): JSX.Element { return ( @@ -17,6 +29,8 @@ export default function ExperienceRow({ name, themeIndex, index, color, levels, type="checkbox" id={`check-${themeIndex}-${index}`} name={`check-${themeIndex}-${index}`} + checked={marked} + onChange={(e) => onMark(e.target.checked)} /> @@ -33,8 +47,10 @@ export default function ExperienceRow({ name, themeIndex, index, color, levels, key={level} style={{ borderBottomColor: color, - borderRightColor: levelIndex === levels.length - 1 ? color : undefined - }}> + borderRightColor: + levelIndex === levels.length - 1 ? color : undefined, + }} + >