Closed ancasimon closed 4 years ago
An article that helped me figure out how to transform the dates into timestamps and compare them and sort them correctly! https://www.codementor.io/@robertwozniak/javascript-story-sorting-records-by-dates-pf8oev5iy
User Story
As a user, when I am on the Home Page, I can see a Diary section that includes a descending (by timestamp) list of cards listing places I have already been with the following details: the name of the location from the card the user was typing in, the text that was in the text box from that card, timestamp for when the diary entry was created.
AC
WHEN I look at a the Diary section below the Destinations section, THEN I see a list of diary entries, AND each diary entry displays the following: location name, timestamp of when I created it/ clicked Submit, and the notes I entered in the input box, AND all the entries are displayed in ascending order base on their timestamp (Req: "Newest entries should appear at the bottom.")
Dev Notes
index.html
file. add a div with the Id ofdiaryDiv
.diaryData.js
file. Add an axios get method that pulls all the data from the diaryEntries collection in Firebase.diaryContainer
component and corresponding js and scss files.diaryComponent.js
file:diaryData.js
utils
forprintToDom
.diaryCard.js
.getDiaryEntries
function from thediaryData.js
file and prints it to thediaryDiv
div.authData.js
file:diaryContainer.js
file and call the build function in it inside the checkLoginStatus function - but outside the if statement that checks if user is logged in.diaryEntries.json
objects.const sortedDiaryEntries = diaryEntries.sort((a, b) => a.timestamp - b.timestamp);
.sortedDiaryEntries
when you start the forEach loop so that you loop over them in the correct order.