mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-03-01 12:44:17 +00:00
adjust TextView in Profile and popup
This commit is contained in:
parent
b23dded744
commit
6698cf78ff
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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>
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user