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

199
Vistas
Conditional (ternary) operator is going directly to else option

I am trying to make a conditional to choose a link according to the type of user I get from the sessionStorage, but it always goes directly to else. I can't find the error, and I don't know what else to try.

I´m using React, and the function Link is what I'm using as href for the

Thank you very much!

export default function IndexCards(props) {

let tipoUser = sessionStorage.getItem("TipoUser")
console.log(tipoUser, "Soy tipo user")

const linkPax = "https://test.com/pax_mockUp.html"
const linkRamp = "https://test.com/ramp_mockUp.html"
const linkLogin = "https://test.com/Login/"


function Link() {
    return tipoUser === 14 ? linkPax
         : tipoUser === 15 ? linkRamp
         : linkLogin
}


return (
    <Fragment>
        <a id="idRef" href={Link()}>
            <div className="div_container">
                <div className="div_container-superior">
                    <p>{props.data.Al}{props.data.FlNoOut}</p>
                    <p>{props.data.sAPT}</p>
                </div>
                <div className="div_container-inferior">
                    <div className='ckin_container_abre'>
                        <h5>ABRE CHECK-IN</h5>
                        <p>{props.data.STDOut.slice(10)}</p>
                    </div>
                    <div className='ckin_container_cierra'>
                        <h5>CIERRA CHECK-IN</h5>
                        <p>{props.data.STDOut.slice(10)}</p>
                    </div>
                </div>
            </div>
        </a>
    </Fragment>
);

}

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

let tipoUser = parseInt(sessionStorage.getItem("TipoUser"))
about 4 years ago · Juan Pablo Isaza Denunciar

0

The issue might be because of the type of the tipoUser variable. This will work for you

let tipoUser = Number(sessionStorage.getItem("TipoUser"))
about 4 years ago · Juan Pablo Isaza Denunciar
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