diff --git a/src/components/Home.js b/src/components/Home.js index 7166ffc1..ba7f95ca 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -11,12 +11,14 @@ export default props => {

Bienvenido

El lugar del cine

+ ` // root.innerHTML = "" // this should do it the router root.appendChild(div) // logic $('#start').onclick = () => props.navigate('/login') + $('#new').onclick = () => props.navigate('/new') return div } diff --git a/src/components/Recommendations.js b/src/components/Recommendations.js new file mode 100644 index 00000000..c1a05143 --- /dev/null +++ b/src/components/Recommendations.js @@ -0,0 +1,35 @@ +// imports +import $ from '../lib/tools.js' +import { createReview } from '../lib/firebase.js' + +export default props => { + + + let div = props.document.createElement('div') + // display + div.innerHTML = ` +
+
+ + + + +
+
+ ` + // root.innerHTML = "" // this should do it the router + root.appendChild(div) + // logic + $('#publicar').onsubmit = e => { + e.preventDefault() + console.log('sirve el form',e.target) + let obj = { + img:e.target.img.value, + title:e.target.title.value, + year:e.target.year.value + } + createReview(obj) + .then(data => console.log(data)) + } + +} diff --git a/src/index.js b/src/index.js index 47654f5e..4514b19b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,7 @@ //import { example } from './example.js'; import home from './components/Home.js' import login from './components/Login.js' +import recommendations from './components/Recommendations.js' function navigate(path) { root.lastElementChild.remove() @@ -13,6 +14,9 @@ function navigate(path) { function render(path) { let route switch (path) { + case '/new': + route = recommendations({document, navigate}) + break; case '/login': route = login({ document, navigate }) break; diff --git a/src/lib/firebase.js b/src/lib/firebase.js index 5c1ccb23..7b4aab86 100644 --- a/src/lib/firebase.js +++ b/src/lib/firebase.js @@ -12,6 +12,7 @@ const firebaseConfig = { firebase.initializeApp(firebaseConfig); let db = firebase.firestore() let usersRef = db.collection('users') +let reviewsRef = db.collection("reviews") export default firebase @@ -24,6 +25,11 @@ export function loginWithGoogle() { }) } +export function createReview(data){ + console.log(data) + return reviewsRef.add(data) +} + function saveUser(user) { let { displayName, uid, photoURL, email } = user let u = { @@ -35,4 +41,4 @@ function saveUser(user) { usersRef.doc(user.uid).set(u) // local localStorage.user = JSON.stringify(u) -} \ No newline at end of file +}