mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-04 14:28:48 +00:00
Handle case where data is undefined (#7486)
This commit is contained in:
parent
8543e74c6e
commit
edd0680344
@ -135,11 +135,11 @@ function NameBadge({ pk, type }: { pk: string | number; type: BadgeType }) {
|
|||||||
case 200:
|
case 200:
|
||||||
return response.data;
|
return response.data;
|
||||||
default:
|
default:
|
||||||
return null;
|
return undefined;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
return null;
|
return undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -148,7 +148,9 @@ function NameBadge({ pk, type }: { pk: string | number; type: BadgeType }) {
|
|||||||
|
|
||||||
// Rendering a user's rame for the badge
|
// Rendering a user's rame for the badge
|
||||||
function _render_name() {
|
function _render_name() {
|
||||||
if (type === 'user' && settings.isSet('DISPLAY_FULL_NAMES')) {
|
if (!data) {
|
||||||
|
return '';
|
||||||
|
} else if (type === 'user' && settings.isSet('DISPLAY_FULL_NAMES')) {
|
||||||
if (data.first_name || data.last_name) {
|
if (data.first_name || data.last_name) {
|
||||||
return `${data.first_name} ${data.last_name}`;
|
return `${data.first_name} ${data.last_name}`;
|
||||||
} else {
|
} else {
|
||||||
@ -169,7 +171,7 @@ function NameBadge({ pk, type }: { pk: string | number; type: BadgeType }) {
|
|||||||
variant="filled"
|
variant="filled"
|
||||||
style={{ display: 'flex', alignItems: 'center' }}
|
style={{ display: 'flex', alignItems: 'center' }}
|
||||||
>
|
>
|
||||||
{data.name ?? _render_name()}
|
{data?.name ?? _render_name()}
|
||||||
</Badge>
|
</Badge>
|
||||||
<InvenTreeIcon icon={type === 'user' ? type : data.label} />
|
<InvenTreeIcon icon={type === 'user' ? type : data.label} />
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user