Refactor TagsDisplay component to handle string and array inputs for tags, ensuring proper rendering and fallback for empty values.
This commit is contained in:
parent
fdd16b2301
commit
ecca21fd6e
@ -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 <Text type='secondary'>n/a</Text>
|
||||
}
|
||||
|
||||
return (
|
||||
<Space size={'small'} wrap style={style}>
|
||||
{tags.map((tag, index) => (
|
||||
{tagArray.map((tag, index) => (
|
||||
<Tag key={index} color='blue' style={{ margin: 0 }}>
|
||||
{tag}
|
||||
</Tag>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user