diff --git a/starter-project-web-vue2/components/sileshi/SileshiAddBlog.vue b/starter-project-web-vue2/components/sileshi/SileshiAddBlog.vue new file mode 100644 index 00000000..24aa6d56 --- /dev/null +++ b/starter-project-web-vue2/components/sileshi/SileshiAddBlog.vue @@ -0,0 +1,55 @@ + + diff --git a/starter-project-web-vue2/components/sileshi/SileshiBlogPost.vue b/starter-project-web-vue2/components/sileshi/SileshiBlogPost.vue new file mode 100644 index 00000000..d8428ecf --- /dev/null +++ b/starter-project-web-vue2/components/sileshi/SileshiBlogPost.vue @@ -0,0 +1,109 @@ + + + diff --git a/starter-project-web-vue2/components/sileshi/userAuthForm.vue b/starter-project-web-vue2/components/sileshi/userAuthForm.vue new file mode 100644 index 00000000..870a3c09 --- /dev/null +++ b/starter-project-web-vue2/components/sileshi/userAuthForm.vue @@ -0,0 +1,49 @@ + + + + + \ No newline at end of file diff --git a/starter-project-web-vue2/pages/abraham/login.vue b/starter-project-web-vue2/pages/abraham/login.vue index d4fb4d77..0b0e5c2e 100644 --- a/starter-project-web-vue2/pages/abraham/login.vue +++ b/starter-project-web-vue2/pages/abraham/login.vue @@ -13,7 +13,7 @@ export default { }, methods: { async loginUser(loginInfo) { - const res = await this.$auth.loginWith('local', { + await this.$auth.loginWith('local', { data: loginInfo, }) }, diff --git a/starter-project-web-vue2/pages/index.vue b/starter-project-web-vue2/pages/index.vue index d55af3a6..41ae0c73 100644 --- a/starter-project-web-vue2/pages/index.vue +++ b/starter-project-web-vue2/pages/index.vue @@ -38,6 +38,12 @@ export default { link: '/abraham', }, + { + name: "Sileshi Abebe", + description: 'Summer Intern', + link: + '/sileshi', + }, ], } }, diff --git a/starter-project-web-vue2/pages/sileshi/README.md b/starter-project-web-vue2/pages/sileshi/README.md deleted file mode 100644 index 8b137891..00000000 --- a/starter-project-web-vue2/pages/sileshi/README.md +++ /dev/null @@ -1 +0,0 @@ - diff --git a/starter-project-web-vue2/pages/sileshi/index.vue b/starter-project-web-vue2/pages/sileshi/index.vue new file mode 100644 index 00000000..c6a82126 --- /dev/null +++ b/starter-project-web-vue2/pages/sileshi/index.vue @@ -0,0 +1,15 @@ + + + diff --git a/starter-project-web-vue2/pages/sileshi/login.vue b/starter-project-web-vue2/pages/sileshi/login.vue new file mode 100644 index 00000000..ae15bf87 --- /dev/null +++ b/starter-project-web-vue2/pages/sileshi/login.vue @@ -0,0 +1,22 @@ + + + \ No newline at end of file diff --git a/starter-project-web-vue2/pages/starter-project-web-vue2.code-workspace b/starter-project-web-vue2/pages/starter-project-web-vue2.code-workspace new file mode 100644 index 00000000..b5ed53ca --- /dev/null +++ b/starter-project-web-vue2/pages/starter-project-web-vue2.code-workspace @@ -0,0 +1,11 @@ +{ + "folders": [ + { + "path": ".." + }, + { + "path": "..\\..\\..\\..\\..\\Desktop\\git" + } + ], + "settings": {} +} \ No newline at end of file diff --git a/starter-project-web-vue2/store/sileshi.js b/starter-project-web-vue2/store/sileshi.js new file mode 100644 index 00000000..bbe90511 --- /dev/null +++ b/starter-project-web-vue2/store/sileshi.js @@ -0,0 +1,42 @@ + +export const state = { + blogs: [], +} +export const actions = { + async fetchBlogs({ commit }) { + const response = await this.$axios.get( + 'https://blog-app-backend.onrender.com/api/articles/all' + ) + commit('setBlogs', response.data) + }, + async addBlog({ commit }, blogPost) { + const response = await this.$axios.post( + 'https://blog-app-backend.onrender.com/api/articles', + blogPost) + commit('newBlog', response.data) + }, + async deleteBlog({ commit }, id) { + await this.$axios.delete( + `https://blog-app-backend.onrender.com/api/articles/${id}`) + commit('removeBlog', id) + }, + async updateBlog({ commit }, updBlog) { + const response = await this.$axios.patch( + `https://blog-app-backend.onrender.com/api/articles/${updBlog._id}`, + updBlog) + commit('updateBlog', response.data) + }, +} +export const mutations = { + setBlogs: (state, blogs) => (state.blogs = blogs), + newBlog: (state, blog) => state.blogs.unshift(blog), + removeBlog: (state, id) => + (state.blogs = state.blogs.filter((blog) => blog._id !== id)), + updateBlog: (state, updBlog) => { + const index = state.blogs.findIndex((blog) => blog._id === updBlog._id) + + if (index !== -1) { + state.blogs.splice(index, 1, updBlog) + } + }, +}