From 20b663b80a8c33ebb375bd9b164fd11f1c2b9b62 Mon Sep 17 00:00:00 2001 From: Thuan Bui Date: Fri, 27 Aug 2021 13:47:14 +0700 Subject: [PATCH] Completed 2.5 --- part2/2.1-2.5/src/App.js | 42 +----------------------- part2/2.1-2.5/src/components/Course.js | 44 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 41 deletions(-) create mode 100644 part2/2.1-2.5/src/components/Course.js diff --git a/part2/2.1-2.5/src/App.js b/part2/2.1-2.5/src/App.js index 45aede1..76a7543 100644 --- a/part2/2.1-2.5/src/App.js +++ b/part2/2.1-2.5/src/App.js @@ -1,4 +1,5 @@ import React from 'react' +import Course from './components/Course' const App = () => { const courses = [ @@ -53,45 +54,4 @@ const App = () => { ) } -const Course = ({course}) => { - return ( -
-
- - -
- ) -} - -const Header = (props) => { - return ( -

{props.course.name}

- ) -} - -const Content = (props) => { - //console.log(props) - return ( -
- {props.part.map(part => - - )} -
- - ) -} - -const Part = (props) => { - return ( -

{props.part.name} {props.part.exercises}

- ) -} - -const Total = ({part}) => { - const total = part.reduce((sum, p) => sum + p.exercises, 0) - return ( -

Total of exercises {total}

- ) -} - export default App \ No newline at end of file diff --git a/part2/2.1-2.5/src/components/Course.js b/part2/2.1-2.5/src/components/Course.js new file mode 100644 index 0000000..979287d --- /dev/null +++ b/part2/2.1-2.5/src/components/Course.js @@ -0,0 +1,44 @@ +import React from 'react'; + +const Course = ({course}) => { + return ( +
+
+ + +
+ ) + } + + const Header = (props) => { + return ( +

{props.course.name}

+ ) + } + + const Content = (props) => { + //console.log(props) + return ( +
+ {props.part.map(part => + + )} +
+ + ) + } + + const Part = (props) => { + return ( +

{props.part.name} {props.part.exercises}

+ ) + } + + const Total = ({part}) => { + const total = part.reduce((sum, p) => sum + p.exercises, 0) + return ( +

Total of exercises {total}

+ ) + } + + export default Course \ No newline at end of file