adjust TextView in Profile and popup

This commit is contained in:
Anton Tranelis 2025-10-08 14:30:11 +02:00
parent b23dded744
commit 6698cf78ff
2 changed files with 14 additions and 7 deletions

View File

@ -28,7 +28,7 @@ export const TextView = ({
}: {
item?: Item
itemId?: string
text?: string
text?: string | null
truncate?: boolean
rawText?: string
}) => {
@ -44,7 +44,15 @@ export const TextView = ({
if (rawText) {
innerText = replacedText = rawText
} else if (text) {
} else if (text === undefined) {
// Field was omitted by backend (no permission)
innerText =
replacedText = `Login to see this ${item?.layer?.name ? (item.layer.name.endsWith('s') ? item.layer.name.slice(0, -1) : item.layer.name) : ''}`
} else if (text === null || text === '') {
// Field is not set or empty - show nothing
innerText = ''
} else {
// Field has a value
innerText = text
}

View File

@ -17,15 +17,14 @@ export const ProfileTextView = ({
}) => {
const text = get(item, dataField)
const parsedText = typeof text !== 'string' ? '' : text
// undefined = no permission, null = not set, string = value exists
const shouldShowHeading = !(hideWhenEmpty && (text === '' || text === null))
return (
<div className='tw:my-10 tw:mt-2 tw:px-6'>
{!(text === '' && hideWhenEmpty) && (
<h2 className='tw:text-lg tw:font-semibold'>{heading}</h2>
)}
{shouldShowHeading && <h2 className='tw:text-lg tw:font-semibold'>{heading}</h2>}
<div className='tw:mt-2 tw:text-sm'>
<TextView itemId={item.id} rawText={parsedText} />
<TextView item={item} text={text as string | null | undefined} itemId={item.id} />
</div>
</div>
)