Skip to content

Commit 1e4a310

Browse files
harshsinghatzroboquat
authored andcommitted
change: if statements to switch statements in dashboard
1 parent 8b7242c commit 1e4a310

File tree

1 file changed

+41
-45
lines changed

1 file changed

+41
-45
lines changed

components/dashboard/src/App.tsx

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -428,21 +428,20 @@ function App() {
428428
<Route
429429
exact
430430
path={projectsPathMainWithParams}
431-
render={(props) => {
432-
const { resourceOrPrebuild } = props.match.params;
433-
if (resourceOrPrebuild === "events") {
434-
return <Events />;
435-
}
436-
if (resourceOrPrebuild === "prebuilds") {
437-
return <Prebuilds />;
438-
}
439-
if (resourceOrPrebuild === "settings") {
440-
return <ProjectSettings />;
441-
}
442-
if (resourceOrPrebuild === "variables") {
443-
return <ProjectVariables />;
431+
render={({ match }) => {
432+
const { resourceOrPrebuild } = match.params;
433+
switch (resourceOrPrebuild) {
434+
case "events":
435+
return <Events />;
436+
case "prebuilds":
437+
return <Prebuilds />;
438+
case "settings":
439+
return <ProjectSettings />;
440+
case "variables":
441+
return <ProjectVariables />;
442+
default:
443+
return resourceOrPrebuild ? <Prebuild /> : <Project />;
444444
}
445-
return resourceOrPrebuild ? <Prebuild /> : <Project />;
446445
}}
447446
/>
448447
</Route>
@@ -459,39 +458,36 @@ function App() {
459458
<Route
460459
exact
461460
path={`/t/${team.slug}/:maybeProject/:resourceOrPrebuild?`}
462-
render={(props) => {
463-
const { maybeProject, resourceOrPrebuild } = props.match.params;
464-
if (maybeProject === "projects") {
465-
return <Projects />;
466-
}
467-
if (maybeProject === "workspaces") {
468-
return <Workspaces />;
469-
}
470-
if (maybeProject === "members") {
471-
return <Members />;
472-
}
473-
if (maybeProject === "settings") {
474-
return <TeamSettings />;
461+
render={({ match }) => {
462+
const { maybeProject, resourceOrPrebuild } = match.params;
463+
switch (maybeProject) {
464+
case "projects":
465+
return <Projects />;
466+
case "workspaces":
467+
return <Workspaces />;
468+
case "members":
469+
return <Members />;
470+
case "settings":
471+
return <TeamSettings />;
472+
case "billing":
473+
return <TeamBilling />;
474+
case "usage":
475+
return <TeamUsage />;
476+
default:
477+
break;
475478
}
476-
if (maybeProject === "billing") {
477-
return <TeamBilling />;
478-
}
479-
if (maybeProject === "usage") {
480-
return <TeamUsage />;
481-
}
482-
if (resourceOrPrebuild === "events") {
483-
return <Events />;
484-
}
485-
if (resourceOrPrebuild === "prebuilds") {
486-
return <Prebuilds />;
487-
}
488-
if (resourceOrPrebuild === "settings") {
489-
return <ProjectSettings />;
490-
}
491-
if (resourceOrPrebuild === "variables") {
492-
return <ProjectVariables />;
479+
switch (resourceOrPrebuild) {
480+
case "events":
481+
return <Events />;
482+
case "prebuilds":
483+
return <Prebuilds />;
484+
case "settings":
485+
return <ProjectSettings />;
486+
case "variables":
487+
return <ProjectVariables />;
488+
default:
489+
return resourceOrPrebuild ? <Prebuild /> : <Project />;
493490
}
494-
return resourceOrPrebuild ? <Prebuild /> : <Project />;
495491
}}
496492
/>
497493
</Route>

0 commit comments

Comments
 (0)