export function addCollectionTag(tagInput, setTagInput, collection, setCollection) {
  if (tagInput.trim() && !collection.tags.includes(tagInput.trim())) {
    setCollection({
      ...collection,
      tags: [...collection.tags, tagInput.trim()],
    });
    setTagInput('');
  }
}

export function removeCollectionTag(tagToRemove, collection, setCollection) {
  setCollection({
    ...collection,
    tags: collection.tags.filter((tag) => tag !== tagToRemove),
  });
}

export function handleCollectionTagKeyPress(
  e,
  tagInput,
  setTagInput,
  collection,
  setCollection
) {
  if (e.key === 'Enter') {
    e.preventDefault();
    addCollectionTag(tagInput, setTagInput, collection, setCollection);
  }
}
