diff --git a/src/layouts/default.vue b/src/layouts/default.vue index cf80cfa..75c6588 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -47,9 +47,6 @@ - - - @@ -103,7 +100,7 @@ export default { main text-align center - margin-top 40px + margin-top 0px header margin 0 diff --git a/src/pages/Profile.vue b/src/pages/Profile.vue new file mode 100644 index 0000000..ad649f7 --- /dev/null +++ b/src/pages/Profile.vue @@ -0,0 +1,177 @@ + + + + diff --git a/src/pages/success.vue b/src/pages/success.vue index bb92e4c..3460c1c 100644 --- a/src/pages/success.vue +++ b/src/pages/success.vue @@ -13,8 +13,8 @@ detail="You just got points for your tag." appear :actions="[ - { label: 'Tag Another', icon: 'alarm', handler: () => { window.location = '#/tag' } }, - { label: 'Verify Photos', icon: 'done', handler: () => { window.location = '#/hello' } } + { label: 'Tag Another', icon: 'alarm', handler: () => { this.$router.push('/tag') } }, + { label: 'Verify Photos', icon: 'done', handler: () => { this.$router.push('/istree') } } ]" class="q-mt-md" > @@ -30,7 +30,7 @@ diff --git a/src/pages/tag.vue b/src/pages/tag.vue index 56b7d61..70b4e00 100644 --- a/src/pages/tag.vue +++ b/src/pages/tag.vue @@ -19,12 +19,9 @@
-
+
- + @@ -34,9 +31,6 @@ - - - @@ -182,28 +176,13 @@ Loading.hide() console.error(err.message) }) - //this.updateProfilePoints }, save (formData) { // upload data to the server let key let imageUrl - // let blob this.currentStatus = STATUS_SAVING - this.uploadaws(formData) - .then(x => { - Loading.hide() - //this.currentStatus = STATUS_SUCCESS - console.log("Loaded AWS - About to upload firebase") - // save data to database - }) - .catch(err => { - Loading.hide() - console.log(error) - // this.uploadError = err.response - this.currentStatus = STATUS_FAILED - }) this.$treesRef.push(this.tree) .then((data) => { console.log("Pushed to firebase") @@ -230,7 +209,6 @@ }) .then(downloadURL => { console.log(`Successfully uploaded file and got download link - ${downloadURL}`); - //return downloadURL; return this.$treesRef.child(key).update({imageUrl: downloadURL}) }) .then(() => { @@ -245,16 +223,16 @@ // this.uploadError = err.response }) }, - uploadaws(formData) { - const url = 'https://s3.amazonaws.com/ash-tree-photos' - return this.$axios.post(url, formData) - .then(function (response) { - console.log("Loaded AWS") //response.data - }) - .catch(function (error) { - console.log(error + Date.now()) - }) - }, + // uploadaws(formData) { + // const url = 'https://s3.amazonaws.com/ash-tree-photos' + // return this.$axios.post(url, formData) + // .then(function (response) { + // console.log("Loaded AWS") //response.data + // }) + // .catch(function (error) { + // console.log(error + Date.now()) + // }) + // }, triggerFileInput () { this.$refs.fileInput.click() @@ -263,10 +241,17 @@ console.log("about to go to success page") const p = Object.assign({}, this.profile) p.points = p.points + this.tagPoints - // add userPoints in firebase - - // this.profilesRef.child(this.tree.user_id).update({points: p.points}) - // .then(this.$store.dispatch('setProfile', p)) + // add userPoints in firebase then update our local store + this.$profilesRef.child(this.tree.user_id).update({points: p.points}) + .then(() => { + this.$store.dispatch('setProfile', p) + }) + .catch(err => { + console.log(error) + this.currentStatus = STATUS_FAILED + Loading.hide() + }) + Loading.hide() console.log("going to success page") this.$router.push('/success') }, diff --git a/src/plugins/firebase.js b/src/plugins/firebase.js index 46fc159..076ad07 100644 --- a/src/plugins/firebase.js +++ b/src/plugins/firebase.js @@ -25,8 +25,7 @@ export default ({ app, router, Vue }) => { Vue.prototype.$firebase = fireb Vue.prototype.$auth = auth Vue.prototype.$treesRef = treesRef + Vue.prototype.$profilesRef = profilesRef Vue.prototype.$storefb = storefb.ref() Vue.prototype.$db = db - // Vue.use(VueFire) - } diff --git a/src/router/routes.js b/src/router/routes.js index 69d4c7d..47e7cd9 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -2,19 +2,21 @@ export default [ { path: '/', - component: () => import('layouts/default'), + component: () => import('layouts/Default'), children: [ - { path: '/', component: () => import('pages/login') }, - { path: '/login', component: () => import('pages/login') }, - { path: '/hello', component: () => import('pages/hello'), meta: { + { path: '/', component: () => import('pages/Login') }, + { path: '/login', component: () => import('pages/Login') }, + { path: '/hello', component: () => import('pages/Hello'), meta: { requiresAuth: true }}, - { path: '/tag', component: () => import('pages/tag'), meta: { + { path: '/tag', component: () => import('pages/Tag'), meta: { requiresAuth: true }}, { path: '/identification', component: () => import('pages/Identification'), meta: { requiresAuth: true }}, - { path: '/success', component: () => import('pages/success'), meta: { + { path: '/profile', component: () => import('pages/Profile'), meta: { requiresAuth: true }}, - { path: '/nearbyTrees', component: () => import('pages/nearbyTrees') } + { path: '/success', component: () => import('pages/Success'), meta: { + requiresAuth: true }}, + { path: '/nearbyTrees', component: () => import('pages/NearbyTrees') } ] },