zammad/zammad

View on GitHub
app/frontend/shared/entities/user/utils/getUserDisplayName.ts

Summary

Maintainability
A
0 mins
Test Coverage
// Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/

import { isEmpty } from 'lodash-es'

import type { User } from '#shared/graphql/types.ts'

export const userDisplayName = (user: Partial<User>): string => {
  const { fullname, email, phone, login } = user

  return (
    [fullname, email, phone, login].find((elem) => elem && !isEmpty(elem)) ||
    '-'
  )
}