-
Notifications
You must be signed in to change notification settings - Fork 1
Create Diary Entry #15
Copy link
Copy link
Open
Description
User Story
As a user, I would like to keep track of my diary entries.
Acceptance Criteria
CREATE:
GIVEN a user wants to create a diary entry on their dashboard
WHEN the user performs a gesture on a New Diary affordance
THEN a form should be presented to the user in which the following information can be entered:
- Date
- Title
- Entry
GIVEN a user has entered in all field values for storing a new diary entry
WHEN the user performs a gesture on the Save Diary affordance
THEN the diary should be saved in the database, and assigned to the user
Development
- Create a div with an id of
diary-div - Create a file called
diaryData.jsinside helpers/data/ - Inside this file import
axiosandapiKeys.js - Create a function called
addNewDiaryEntrythat posts a diary object to the firebase url - Create two files named
addDiary.jsandaddDiary.scsswith a path of src/javascripts/components/diary - Inside of
addDiary.jsimport theprintToDomfunction from util.js - Import
firebaseandfirebase/auth - Import
diaryData.jsfrom helpers/data/diaryData.js - Create a form inside of the
diaryStringBuilderthat allows a user to input and date, title, entry of a diary entry. - The form should have two buttons labeled
Save DiaryandCancelwith ids ofsave-diaryandcancel-save-diary - Print the
diaryStringBuildertodiary-div - Create click event listeners for the
Save DiaryandCancelthat run functionssaveDiaryEventandcancelDiaryEvent, respectively. - Create
saveDiaryEventfunction that captures data for new data and post to the diary database like this:
const saveNewDiary = (e) => {
e.preventDefault();
const newDiary = {
date: document.getElementById('date').value,
title: document.getElementById('title').value,
entry: document.getElementById('entry').value,
uid: firebase.auth().currentUser.uid,
};
diaryData.addNewDiary(newDiary)
.then(() => {
document.getElementById('date').value = '';
document.getElementById('title').value = '';
document.getElementById('entry').value = '';
})
.catch(err => console.error('no new friends', err));
console.error(newFriend);
};Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels