-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'aman.added_store' into amanabiy_practice
- Loading branch information
Showing
3 changed files
with
91 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const desc = "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Cum necessitatibus officia labore illo accusamus temporibus commodi eveniet praesentium ullam exercitationem vel nulla, deleniti modi obcaecati laudantium natus soluta laborum quisquam. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Cum necessitatibus officia labore illo accusamus temporibus commodi eveniet praesentium ullam exercitationem vel nulla, deleniti modi obcaecati laudantium natus soluta laborum quisquam. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Cum necessitatibus officia labore illo accusamus temporibus commodi eveniet praesentium ullam exercitationem vel nulla, deleniti modi obcaecati laudantium natus soluta laborum quisquam." | ||
|
||
export const state = { | ||
blogs: [ | ||
{ | ||
id: "1", | ||
title: "Why you should Wake up early", | ||
author: "Amanuel Sisay", | ||
desc, | ||
}, | ||
{ | ||
id: "2", | ||
title: "Why you should Gym and go to gym", | ||
desc, | ||
author: "Abel", | ||
}, | ||
{ | ||
id: "3", | ||
title: "The benifit of Working hard", | ||
desc, | ||
author: "Abebe", | ||
}, | ||
{ | ||
id: "4", | ||
title: "Interviews Trick", | ||
desc, | ||
author: "Kebede", | ||
}, | ||
], | ||
} | ||
|
||
export const actions = { | ||
getBlogs({ commit }) { | ||
commit('getBlogs', state.blogs) | ||
}, | ||
|
||
deleteBlog({ commit }, id) { | ||
commit('deleteBlog', id) | ||
}, | ||
|
||
addBlog({ commit }, addedBlog) { | ||
commit('addBlogs', addedBlog) | ||
}, | ||
|
||
updateBlog({ commit }, updatedBlog) { | ||
commit('updateBlog', updatedBlog) | ||
} | ||
|
||
} | ||
|
||
export const getters = { | ||
// sorted options | ||
|
||
// filtered options | ||
|
||
// filtered + sorterd options | ||
} | ||
|
||
export const mutations = { | ||
getBlogs: (state, blogs) => (state.blogs = blogs), | ||
deleteBlog: (state, id) => { | ||
(state.blogs = state.blogs.filter((blog) => blog.id !== id))}, | ||
editBlog: (state, newBlog) => { | ||
const blogToEdit = state.blogs.filter((blog) => blog.id === newBlog.id)[0] | ||
blogToEdit.title = newBlog.title | ||
blogToEdit.desc = newBlog.desc | ||
blogToEdit.author = newBlog.author | ||
}, | ||
addBlog: (state, newBlog) => { state.blogs.unshift(newBlog)} | ||
} |