Skip to content

Commit 61bd748

Browse files
authored
Merge pull request #3 from oslabs-beta/David/Joseph-RouteDescription
David/joseph route description
2 parents 5982a1c + dfc0b35 commit 61bd748

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/app/components/RouteDescription.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import React from "react";
1+
import React from 'react';
22

3-
const RouteDescription = (props) => {
3+
type RouteProps = {
4+
actions: JSX.Element[],
5+
}
6+
7+
const RouteDescription = (props: RouteProps): JSX.Element => {
48
// Use new URL to use the url.pathname method.
5-
const url = new URL(props.actions[0].props.routePath);
9+
const { actions } = props;
10+
const url = new URL(actions[0].props.routePath);
611
return (
712
<div className="routedescription">
8-
<h3 className='route'>Route: {url.pathname}</h3>
9-
{props.actions}
13+
<h3 className="route">
14+
Route:
15+
{url.pathname}
16+
</h3>
17+
{actions}
1018
</div>
1119
);
1220
};

src/app/containers/ActionContainer.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { emptySnapshots, changeView, changeSlider } from '../actions/actions';
1212
import { useStoreContext } from '../store';
1313
import RouteDescription from '../components/RouteDescription';
1414

15-
1615
const resetSlider = () => {
1716
const slider = document.querySelector('.rc-slider-handle');
1817
if (slider) {
@@ -147,8 +146,12 @@ function ActionContainer(props): JSX.Element {
147146
};
148147

149148
// Logic to create the route description components
149+
type routes = {
150+
[route: string]: [];
151+
}
152+
150153
const routes = {};
151-
for (let i = 0; i < actionsArr.length; i++) {
154+
for (let i = 0; i < actionsArr.length; i += 1) {
152155
if (!routes.hasOwnProperty(actionsArr[i].props.routePath)) {
153156
routes[actionsArr[i].props.routePath] = [actionsArr[i]];
154157
} else {
@@ -199,11 +202,8 @@ function ActionContainer(props): JSX.Element {
199202
</button>
200203
</div>
201204
{/* Rendering of route description components */}
202-
{Object.keys(routes).map((route) => {
203-
return (
204-
<RouteDescription actions = {routes[route]}></RouteDescription>
205-
)
206-
})}
205+
{Object.keys(routes).map(route => (
206+
<RouteDescription actions={routes[route]} />))}
207207
</div>
208208
) : null}
209209
</div>

0 commit comments

Comments
 (0)