diff --git a/components/collections/addCollection.vue b/components/collections/addCollection.vue index 2789a52d7..c39b7b257 100644 --- a/components/collections/addCollection.vue +++ b/components/collections/addCollection.vue @@ -56,6 +56,10 @@ export default { }, methods: { addNewCollection() { + if (!this.$data.name) { + this.$toast.info('Please provide a valid name for the collection') + return; + } this.$store.commit("postwoman/addNewCollection", { name: this.$data.name }); diff --git a/components/collections/editCollection.vue b/components/collections/editCollection.vue index 4021557fe..98c9154be 100644 --- a/components/collections/editCollection.vue +++ b/components/collections/editCollection.vue @@ -59,6 +59,10 @@ export default { }, methods: { saveCollection() { + if (!this.$data.name) { + this.$toast.info('Please provide a valid name for the collection'); + return; + } const collectionUpdated = { ...this.$props.editingCollection, name: this.$data.name diff --git a/store/postwoman.js b/store/postwoman.js index 61712fb65..b7ae1258d 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -132,6 +132,12 @@ export const mutations = { editCollection({ collections }, payload) { const { collection, collectionIndex } = payload; + const { name } = collection + const duplicateCollection = collections.some(item => item.name === name) + if (duplicateCollection) { + this.$toast.info('Duplicate collection'); + return; + } collections[collectionIndex] = collection; },