For this assignment, we are going to create a simple schedule builder for sorting out how many sections of different classes we need to offer and who will teach them. We won't have any data connection yet, so our state is purely client-side (erased on reload).
The complete app will work as shown below. But this assignment is only the first part of the app. The next assignment will complete the interface that you see below, and the final assignment will make the server data connection.
Following the video example, create a component representing each Course
and display three of them.
Course
component to your App.js
file
Course
represents one of those rows abovemockups/mockup01.html
(pictured above), just as in part1Course
and use it as the state:
const name = "1370"; const sections = [ {id: 1, instructor: "Ayati"}, {id: 2, instructor: "Kim"} ];
App
display that component three times (as if there were three different courses)Continuing on, move the data to the App level and pass properties into your Courses
App
:
const courses = [ {name: "1370", sections: [ {id: 1, instructor: "Ayati"}, {id: 2, instructor: "Kim"} ]}, {name: "3329", sections: [ {id: 3, instructor: "Gao"}, {id: 4, instructor: "Tomai"}, {id: 5, instructor: "Tomai"} ]}, {name: "3340", sections: [ {id: 6, instructor: "Schweller"}, {id: 7, instructor: "Wylie"} ]} ];
App
component to iterate over that list creating Course
componentsCourse
component to accept name
and sections
as properties (props)key
attribute on each Course
As we've seen before, storing a simple name for each instructor in the database is limited. More likely, we will have a faculty table and store ids.
App
const instructors = [ {id: 12, name: 'Ayati'}, {id: 7, name: 'Gao'}, {id: 2, name: 'Kim'}, {id: 23, name: 'Schweller'}, {id: 31, name: 'Tomai'}, {id: 3, name: 'Wylie'} ];
courses
data with idsCourse
component to accept the instructors
list as an additional propCourse
component to look up instructors names based on the ids in the course data
hint: JavaScript arrays have a very nice find
method