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

106
Views
Alertas de refactorización

Hola, soy bastante nuevo en la codificación. Estoy trabajando en un proyecto y siento que puedo refactorizar este código para que sea menos voluminoso, pero realmente no sé por dónde empezar. Tal vez el mapeo podría ser útil. ¿Alguna sugerencia?

 const CriticalAlertStatus = isCriticalAlertingEnabled ? allIcons.LMAlertSeverityCriticalOutline20Px : Disabled; const isCriticalStaticAlertSuppressed = R.path( ["children", "CRITICAL", "isStaticAlertSuppressed"], props ); const CriticalStaticAlertStatus = isCriticalStaticAlertSuppressed ? allIcons.LMAlertsCritical20Px : Disabled; const isErrorAlertingEnabled = R.path(["children", "ERROR", "isAlertingEnabled"], props); const ErrorAlertStatus = isErrorAlertingEnabled ? allIcons.LMAlertSeverityErrorOutline20Px : Disabled; const isErrorStaticAlertSuppressed = R.path( ["children", "ERROR", "isStaticAlertSuppressed"], props ); const ErrorStaticAlertStatus = isErrorStaticAlertSuppressed ? allIcons.LMAlertsError20Px : Disabled; const isWarningAlertingEnabled = R.path(["children", "WARNING", "isAlertingEnabled"], props); const WarningAlertStatus = isWarningAlertingEnabled ? allIcons.LMAlertSeverityWarningOutline20Px : Disabled; const isWarningStaticAlertSuppressed = R.path( ["children", "WARNING", "isStaticAlertSuppressed"], props ); const WarningStaticAlertStatus = isWarningStaticAlertSuppressed ? allIcons.LMAlertsWarning20Px : Disabled;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar R.ifElse para crear una función de fábrica que generaría una nueva función de estadísticas de alerta según los parámetros que pase:

 const Disabled = 'Disabled' // Demo Disabled const getAlertState = R.curry((path, icon, props) => R.ifElse(R.path(path), R.always(icon), R.always(Disabled)) (props)) // Example of usage // Demo icons const allIcons = { LMAlertSeverityCriticalOutline20Px: 'LMAlertSeverityCriticalOutline20Px', LMAlertsCritical20Px: 'LMAlertsCritical20Px' }; // Create funnctions const CriticalAlertStatus = getAlertState(["children", "CRITICAL", "isCriticalAlertingEnabled"], allIcons.LMAlertSeverityCriticalOutline20Px) const CriticalStaticAlertStatus = getAlertState(["children", "CRITICAL", "isStaticAlertSuppressed"], allIcons.LMAlertsCritical20Px) // Demo props const props = { children: { CRITICAL: { isCriticalAlertingEnabled: false, isStaticAlertSuppressed: true } } } console.log(CriticalAlertStatus(props)); // Disabled console.log(CriticalStaticAlertStatus(props)); // LMAlertsCritical20Px
 <script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.js" integrity="sha512-3sdB9mAxNh2MIo6YkY05uY1qjkywAlDfCf5u1cSotv6k9CZUSyHVf4BJSpTYgla+YHLaHG8LUpqV7MHctlYzlw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

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!