From 23d8b56c0e1c895e6e502d478f924bc5ab1db9cc Mon Sep 17 00:00:00 2001 From: Liam Cabra Teixeira Date: Thu, 22 Oct 2020 05:19:57 -0300 Subject: [PATCH] Follow page started --- src/components/cpmUserFollow.vue | 135 ++++++++++++++++++++++++++++++ src/router/index.js | 5 ++ src/store/index.js | 4 +- src/store/modules/FollowVuex.js | 61 ++++++++++++++ src/views/private/FollowIndex.vue | 50 +++++++++++ 5 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 src/components/cpmUserFollow.vue create mode 100644 src/store/modules/FollowVuex.js create mode 100644 src/views/private/FollowIndex.vue diff --git a/src/components/cpmUserFollow.vue b/src/components/cpmUserFollow.vue new file mode 100644 index 0000000..6959522 --- /dev/null +++ b/src/components/cpmUserFollow.vue @@ -0,0 +1,135 @@ + + + + + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 387f83e..2da5273 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -56,6 +56,11 @@ const routes = [ path: '/Coment/1', name: 'Coment', component: () => import('../views/private/Coment.vue') + }, + { + path: '/Follow', + name: 'FollowIndex', + component: () => import('../views/private/FollowIndex.vue') } ] diff --git a/src/store/index.js b/src/store/index.js index af100a6..eecea83 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -5,6 +5,7 @@ import FeedVuex from './modules/FeedVuex' import RegisterVuex from './modules/RegisterVuex' import LoginVuex from './modules/LoginVuex' import ProfileVuex from './modules/ProfileVuex' +import FollowVuex from './modules/FollowVuex' Vue.use(Vuex) @@ -38,6 +39,7 @@ export default new Vuex.Store({ RegisterVuex, FeedVuex, LoginVuex, - ProfileVuex + ProfileVuex, + FollowVuex } }) diff --git a/src/store/modules/FollowVuex.js b/src/store/modules/FollowVuex.js new file mode 100644 index 0000000..4aa3f01 --- /dev/null +++ b/src/store/modules/FollowVuex.js @@ -0,0 +1,61 @@ +import axios from '../../util/axios' + + +export default { + + namespaced: true, + + state: { + users: [], + + following: [], + }, + + getters: { + + usersData: state => state.usersData + + }, + + mutations: { + + setUsers(state, newState){ + state.users = newState + }, + + setFollowing(state, newState){ + state.following = newState + } + + }, + + actions: { + + async getUsers(context){ + const users = await axios.get(process.env.VUE_APP_BASE_URL+'/user'); + + const [thisUser] = users.data.filter(item => localStorage.id == item.id); + + users.data.splice(users.data.indexOf(thisUser), 1) + + await context.commit('setUsers', users.data); + + return users.data; + }, + + async doFollow(context, new_follow_id){ + const follow = await axios.put(process.env.VUE_APP_BASE_URL+`/user/${new_follow_id}/follow`); + + return follow.data; + }, + + async getFollowing(context){ + const following = await axios.get(process.env.VUE_APP_BASE_URL+`/user/${localStorage.id}/following`); + + await context.commit('setFollowing', following.data); + + return following.data; + } + + } +} \ No newline at end of file diff --git a/src/views/private/FollowIndex.vue b/src/views/private/FollowIndex.vue new file mode 100644 index 0000000..5c4a729 --- /dev/null +++ b/src/views/private/FollowIndex.vue @@ -0,0 +1,50 @@ + + + + +