From 266f2a0372a507e550d0f1ddd664aabbc7b2cf17 Mon Sep 17 00:00:00 2001 From: Pedro Lopes Date: Thu, 17 Sep 2020 21:53:01 -0300 Subject: [PATCH] create event with loged user id --- src/components/cpmEventForm.vue | 25 ++++++++++++++++++++----- src/components/cpmToolBar.vue | 2 +- src/store/index.js | 2 ++ src/store/modules/EventVuex.js | 17 +++++++++++++++++ src/store/modules/LoginVuex.js | 4 +--- src/views/private/Event.vue | 5 +++-- src/views/private/Profile.vue | 2 ++ src/views/public/Home.vue | 6 ++++-- 8 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 src/store/modules/EventVuex.js diff --git a/src/components/cpmEventForm.vue b/src/components/cpmEventForm.vue index 67c234c..05768b8 100644 --- a/src/components/cpmEventForm.vue +++ b/src/components/cpmEventForm.vue @@ -12,9 +12,9 @@ --> + - - +
@@ -163,7 +163,7 @@ import firebase, { storage } from 'firebase'; import uploadImageToFirebase from '../util/firebase' import { - mapActions + mapActions, mapGetters } from 'vuex' export default { @@ -172,6 +172,7 @@ export default { }, data:() => ({ + userId: localStorage.getItem('id'), fileInput:'', currentFilePath:'', value:'', @@ -198,7 +199,6 @@ export default { address:'', eventDate:'', img:'', - user:5 }, name:'', @@ -244,11 +244,26 @@ export default { this.eventForm.private = false }, + computed: { + ...mapGetters({ + test: 'test', + }) + }, + methods: { ...mapActions({ createEvent: 'createEvent' }), + testVuex(){ + let obj = { + nome:'sei la', + record:'21321083218' + } + + this.$store.commit('test', obj) + }, + save (date) { this.$refs.menu.save(date) }, @@ -339,7 +354,7 @@ export default { eventDate:this.eventForm.eventDate, latitude:this.eventForm.latitude, longitude:this.eventForm.longitude, - user:{user: this.eventForm.user}, + user:{id: this.userId}, } console.log(body) diff --git a/src/components/cpmToolBar.vue b/src/components/cpmToolBar.vue index 7d88013..688a2ce 100644 --- a/src/components/cpmToolBar.vue +++ b/src/components/cpmToolBar.vue @@ -63,7 +63,7 @@
- + SAIR
diff --git a/src/store/index.js b/src/store/index.js index df77c62..afc1285 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,5 +1,6 @@ import Vue from 'vue' import Vuex from 'vuex' +import EventVuex from './modules/EventVuex' import FeedVuex from './modules/FeedVuex' import RegisterVuex from './modules/RegisterVuex' import LoginVuex from './modules/LoginVuex' @@ -28,6 +29,7 @@ export default new Vuex.Store({ actions: { }, modules: { + EventVuex, RegisterVuex, FeedVuex, LoginVuex, diff --git a/src/store/modules/EventVuex.js b/src/store/modules/EventVuex.js new file mode 100644 index 0000000..6220f1c --- /dev/null +++ b/src/store/modules/EventVuex.js @@ -0,0 +1,17 @@ + +export default { + + namespaced: true, + + state: { + }, + + getters: { + }, + + mutations: { + }, + + actions: { + } +} diff --git a/src/store/modules/LoginVuex.js b/src/store/modules/LoginVuex.js index d920307..ec5fce6 100644 --- a/src/store/modules/LoginVuex.js +++ b/src/store/modules/LoginVuex.js @@ -23,10 +23,8 @@ export default { async authLogin (context, newData) { - console.log(newData) - const autho = await axios.post(process.env.VUE_APP_BASE_URL + '/user/auth', newData) - + localStorage.setItem('id', autho.data[1]) return autho }, diff --git a/src/views/private/Event.vue b/src/views/private/Event.vue index 3fa36a2..bdfd9fe 100644 --- a/src/views/private/Event.vue +++ b/src/views/private/Event.vue @@ -2,8 +2,7 @@
-

CRIAR EVENTO

- +
@@ -14,10 +13,12 @@ import EventForm from '@/components/cpmEventForm' import ToolBar from '@/components/cpmToolBar' export default { + components: { ToolBar, EventForm, }, + data:() => ({}), mounted() {}, diff --git a/src/views/private/Profile.vue b/src/views/private/Profile.vue index 7539abc..c952100 100644 --- a/src/views/private/Profile.vue +++ b/src/views/private/Profile.vue @@ -98,6 +98,7 @@ export default { methods: { ...mapActions({ + getEvents: "FeedVuex/getEvents", getUser: "ProfileVuex/getUser", updateUser: "ProfileVuex/updateUser", getMyEvents: "ProfileVuex/getMyEvents", @@ -126,6 +127,7 @@ export default { }, created() { + this.getEvents(); this.loadUser(); this.loadEvents(); }, diff --git a/src/views/public/Home.vue b/src/views/public/Home.vue index b3becba..08996db 100644 --- a/src/views/public/Home.vue +++ b/src/views/public/Home.vue @@ -5,9 +5,11 @@ - Entrar +
+ Entrar - Cadastro + Cadastro +