usando apenas ifs | function handleApprovalStatus(status, current_step, postRegistrationUnderAnalysis, published) {
if (status !== "approved") return;
if (current_step === "board_registration_number") {
navigate("/saude/verificacao-inscricao");
} else if (current_step === "add_intersectionality_data" && !isDiversityRoute()) {
navigate("/saude/diversidade");
} else if (current_step && postRegistrationUnderAnalysis && isUnderAnalysisNotAllowedRoute()) {
navigate("/saude/painel-inicial");
} else if (!current_step && !published && !isNotActiveAccountAllowedRoute()) {
navigate("/saude/painel-inicial");
}
}
| ready |
Usando switch | function handleApprovalStatus(status, current_step, postRegistrationUnderAnalysis, published) {
if (status !== "approved") {
return;
}
const isDiversity = isDiversityRoute();
const isUnderAnalysisNotAllowed = isUnderAnalysisNotAllowedRoute();
const isNotActiveAccountAllowed = isNotActiveAccountAllowedRoute();
switch (current_step) {
case "board_registration_number":
navigate("/saude/verificacao-inscricao");
break;
case "add_intersectionality_data":
if (!isDiversity) {
navigate("/saude/diversidade");
}
break;
default:
if (current_step && postRegistrationUnderAnalysis && isUnderAnalysisNotAllowed) {
navigate("/saude/painel-inicial");
} else if (!current_step && !published && !isNotActiveAccountAllowed) {
navigate("/saude/painel-inicial");
}
break;
}
}
| ready |
switch pattern matching | function handleApprovalStatus(status, current_step, postRegistrationUnderAnalysis, published) {
if (status !== "approved") {
return;
}
switch (true) {
case current_step === "board_registration_number":
navigate("/saude/verificacao-inscricao");
break;
case current_step === "add_intersectionality_data" && isDiversityRoute():
navigate("/saude/diversidade");
break;
case (current_step && postRegistrationUnderAnalysis && isUnderAnalysisNotAllowedRoute()):
case !current_step && !published && !isNotActiveAccountAllowedRoute():
navigate("/saude/painel-inicial");
break;
}
}
| ready |