diff --git a/lib/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/lib/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx index 93fce564..2ed9f691 100644 --- a/lib/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx +++ b/lib/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx @@ -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 } diff --git a/lib/src/Components/Profile/Subcomponents/ProfileTextView.tsx b/lib/src/Components/Profile/Subcomponents/ProfileTextView.tsx index 2adbb3e1..ea62c6d7 100644 --- a/lib/src/Components/Profile/Subcomponents/ProfileTextView.tsx +++ b/lib/src/Components/Profile/Subcomponents/ProfileTextView.tsx @@ -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 (
- {!(text === '' && hideWhenEmpty) && ( -

{heading}

- )} + {shouldShowHeading &&

{heading}

}
- +
)