mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Handle case where data is undefined (#7486)
This commit is contained in:
		@@ -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>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user