Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
how can I change my call condition into a switch case

I need to change this condition into a switch case according to this condition I set API call will work if this condition will match.

useEffect(() => {
        user?.app_permission == true &&
        user?.corp_permission == true &&
        appName == "@common/su"
          ? (fetchAppList({
              id: data.search_id,
              ...(appName !== "@common/su" ? parameter : {}),
            }),
            fetchCorpList({
              id: data.search_id,
              ...(appName !== "@common/su" ? parameter : {}),
            }))
          : user?.App_permission == true &&
            user?.corp_permission == false &&
            appName == "@common/su"
          ? fetchAppList({
              id: data.search_id,
              ...(appName !== "@common/su" ? parameter : {}),
            })
          : user?.corp_permission == true &&
            user?.App_permission == false &&
            appName == "@common/su"
          ? fetchCorpList({
              id: data.search_id,
              ...(appName !== "@common/su" ? parameter : {}),
            })
          : null;
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function demo(appName, user) {
    let conditionOne = user ? .app_permission == true && user ? .corp_permission == true && appName == "@common/su";
    let conditionTwo = user ? .App_permission == true && user ? .corp_permission == false && appName == "@common/su";
    let conditionThree = user ? .corp_permission == true && user ? .App_permission == false && appName == "@common/su";

if (conditionOne) {
    let fetchAppList = fetchAppList({
            id: data.search_id,
            ...(appName !== "@common/su" ? parameter : {}),
        });
      let fetchCorpList = fetchCorpList({
            id: data.search_id,
            ...(appName !== "@common/su" ? parameter : {}),
        });
    return [fetchCorpList,fetchAppList];
}
if (conditionTwo) {
      let fetchAppList = fetchAppList({
            id: data.search_id,
            ...(appName !== "@common/su" ? parameter : {}),
        });
    return [fetchAppList];
}
if (conditionThree) {
    let fetchCorpList = fetchCorpList({
            id: data.search_id,
            ...(appName !== "@common/su" ? parameter : {}),
        });
    return [fetchCorpList];
  }
return null;
}


useEffect(() => {
     let result = demo(appName,user);
  },[])
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!