From ecca21fd6e186dd70e1abf6e2ab3a1e8d68c678b Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sat, 19 Jul 2025 21:36:34 +0100 Subject: [PATCH] Refactor TagsDisplay component to handle string and array inputs for tags, ensuring proper rendering and fallback for empty values. --- src/components/Dashboard/common/TagsDisplay.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/Dashboard/common/TagsDisplay.jsx b/src/components/Dashboard/common/TagsDisplay.jsx index fa34894..ebdaaf2 100644 --- a/src/components/Dashboard/common/TagsDisplay.jsx +++ b/src/components/Dashboard/common/TagsDisplay.jsx @@ -4,14 +4,25 @@ import PropTypes from 'prop-types' const { Text } = Typography -const TagsDisplay = ({ tags = [], style }) => { - if (tags.length == 0) { +const TagsDisplay = ({ tags, style }) => { + let tagArray = [] + if (typeof tags === 'string') { + tagArray = [tags] + } else if (Array.isArray(tags)) { + tagArray = tags + } + + if ( + !tagArray || + tagArray.length === 0 || + (tagArray.length === 1 && !tagArray[0]) + ) { return n/a } return ( - {tags.map((tag, index) => ( + {tagArray.map((tag, index) => ( {tag}