Skip to content

Commit

Permalink
feat: automatic order to sections and courses
Browse files Browse the repository at this point in the history
this closes #206
  • Loading branch information
marianzburlea committed Sep 9, 2019
1 parent b2e8eaf commit 8eaa3f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/component/home/home.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ const Home = () => {

const sectionSnapshot = await db
.collection('section')
.orderBy('order', 'asc')
// .orderBy('order', 'asc')
.get();
const sectionList = sectionSnapshot.docs.map(doc => ({
id: doc.id,
...doc.data()
}));
const sectionList = sectionSnapshot.docs
.map(doc => ({
id: doc.id,
...doc.data()
}))
.sort((a, b) => a.order - b.order)

updateData({ lectureList, courseList, sectionList });
// console.log(lectureList.map(x => x.course))
Expand Down
4 changes: 3 additions & 1 deletion src/component/section-panel/section-panel.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const SectionPanel = ({ course }) => {

const [section, setSection] = useState(defaultSection)
const { sectionList } = WebInfoState()
console.log(sectionList)

const change = what => {
setSection({ ...section, ...what })
Expand All @@ -28,7 +29,8 @@ const SectionPanel = ({ course }) => {
}
else {
// we want to add a Section
sectionCollection.add({ title, description, course })
const order = sectionList.length
sectionCollection.add({ title, description, course, order })
}
setSection(defaultSection)
}
Expand Down

0 comments on commit 8eaa3f2

Please sign in to comment.