From 9c2eea9186490942c3d07eefbf18abd1e3b403f2 Mon Sep 17 00:00:00 2001 From: Moustafa Shaaban Date: Sun, 21 Apr 2024 00:24:58 +0200 Subject: [PATCH] Added update and delete tags functionality --- src/components/TagDetail.vue | 130 +++++++++++++++++++++++++++++++++++ src/components/TagList.vue | 6 ++ src/router/index.js | 6 ++ src/stores/notes.js | 5 +- 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 src/components/TagDetail.vue diff --git a/src/components/TagDetail.vue b/src/components/TagDetail.vue new file mode 100644 index 0000000..694a4f6 --- /dev/null +++ b/src/components/TagDetail.vue @@ -0,0 +1,130 @@ + + + + + + diff --git a/src/components/TagList.vue b/src/components/TagList.vue index 4635e06..d7d5220 100644 --- a/src/components/TagList.vue +++ b/src/components/TagList.vue @@ -13,6 +13,12 @@ const notesStore = useNotesStore();
{{ tag.name }}
+ + + + + Details +
diff --git a/src/router/index.js b/src/router/index.js index f92f0ff..5f15476 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,6 +5,7 @@ import NoteForm from "../components/NoteForm.vue"; import NoteDetail from "../components/NoteDetail.vue"; import TagForm from "../components/TagForm.vue"; import TagList from "../components/TagList.vue"; +import TagDetail from "../components/TagDetail.vue"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -34,6 +35,11 @@ const router = createRouter({ name: 'add-tag', component: TagForm, }, + { + path: '/tag-detail/:id', + name: 'tag-detail', + component: TagDetail, + }, { path: "/about", name: "about", diff --git a/src/stores/notes.js b/src/stores/notes.js index 6e93734..069ae16 100644 --- a/src/stores/notes.js +++ b/src/stores/notes.js @@ -12,7 +12,10 @@ export const useNotesStore = defineStore('notes', { getters: { getNoteById: (state) => { return (id) => state.notes.find((note) => note.id === id) - } + }, + getTagById: (state) => { + return (id) => state.tags.find((tag) => tag.id === id) + }, }, actions: { addNote(note) {