Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
How to put the admin user always at the top of the table?

I made a table using .map() returning users from an array that has only one admin user.

I know the user is admin because it renders name (ADM) as follows: I'm fetching the user.email from the users array and comparing it with the user.email from the context (it takes the data that is coming from auth0). If this email has the admin permission (manage:accounts), then its name will be followed by (ADM). I think this code can help to make the .sort(), but I couldn't do it

Here is the array : The email michelle@gmail.com is the one with admin permission on auth0

const userList = [
  {
    name: 'Bob', email: 'bob@gmail.com', birth_date: '13/03/1954'
  },
  {
    name: 'Susy', email: 'suzy@gmail.com', birth_date: '23/03/1987'
  },
  {
    name: 'Michelle', email: 'michelle@gmail.com', birth_date: '31/10/1992'
  }
];

Here is the code I just described:

{user.name} {user.email === context.user.email && context.user.permissions.includes('manage:accounts') && ('(ADM)')}

Here is the table I did:

<TableContainer component={Paper} elevation={0}>
  <S.TableContent>
  {userList?.length && userList.map((user, index) => (
    <TableRow key={index}>
      <S.TableCellIcon>
        <S.UserIcon src={'/icon_profile.svg'} alt='Ícone do perfil' />
      </S.TableCellIcon>
      <S.TableCellUser>
        <span>{user.name} {user.email === context.user.email && context.user.permissions.includes('manage:accounts') && ('(ADM)')}</span>
        <p>{user.email}</p>
      </S.TableCellUser>
      <S.TableCellLastAcess>
        Último acesso: <b>{user.birth_date}</b>
      </S.TableCellLastAcess>
    </TableRow>
  ))}
  </S.TableContent>
</TableContainer>

Thank you for your help <3

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda