2025-05-18 19:46:45 +02:00
|
|
|
const Header = (props) => {
|
|
|
|
|
return <h1>{props.course}</h1>
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-18 19:50:11 +02:00
|
|
|
const Part = (props) => {
|
|
|
|
|
return <p>{props.partName} {props.exerciseCount}</p>
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-18 19:46:45 +02:00
|
|
|
const Content = (props) => {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{props.sections.map((section) => {
|
2025-05-18 19:50:11 +02:00
|
|
|
return <Part partName={section.part} exerciseCount={section.exerciseCount}/>
|
2025-05-18 19:46:45 +02:00
|
|
|
})}
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Total = (props) => {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<p>Number of exercises {props.totalExerciseCount}</p>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const App = () => {
|
|
|
|
|
const course = 'Half Stack application development'
|
|
|
|
|
const part1 = 'Fundamentals of React'
|
|
|
|
|
const exercises1 = 10
|
|
|
|
|
const part2 = 'Using props to pass data'
|
|
|
|
|
const exercises2 = 7
|
|
|
|
|
const part3 = 'State of a component'
|
|
|
|
|
const exercises3 = 14
|
|
|
|
|
|
|
|
|
|
const sections = [
|
|
|
|
|
{
|
|
|
|
|
part: part1,
|
|
|
|
|
exerciseCount: exercises1
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
part: part2,
|
|
|
|
|
exerciseCount: exercises2
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
part: part3,
|
|
|
|
|
exerciseCount: exercises3
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<Header course={course}/>
|
|
|
|
|
<Content sections={sections}/>
|
|
|
|
|
<Total totalExerciseCount={exercises1 + exercises2 + exercises3}/>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App
|