Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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>
);

}

>Solution :

let tipoUser = parseInt(sessionStorage.getItem("TipoUser"))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading