No. Seats: 12 Seats
diff --git a/src/components/Favorite.js b/src/components/Favorite.js
new file mode 100644
index 0000000..1b43e9d
--- /dev/null
+++ b/src/components/Favorite.js
@@ -0,0 +1,17 @@
+import React from 'react';
+import BusInfoContainer from './BusInfoContainer';
+
+export default function Favorite() {
+ return (
+ <>
+
+ >
+ );
+}
diff --git a/src/components/RouteList.js b/src/components/RouteList.js
index e255e6d..71c298c 100644
--- a/src/components/RouteList.js
+++ b/src/components/RouteList.js
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useCallback } from 'react';
import PropTypes from 'prop-types';
import WayLine from './WayLine';
import Fuse from 'fuse.js';
@@ -12,27 +12,34 @@ const RouteList = ({ handleSetPath }) => {
const [routes, setRoutes] = useState([]);
const [busses, setBusses] = useState([]);
- const getRoutes = async () => {
- const snapshot = await routesRef.get();
+ const getRoutes = useCallback(async () => {
+ const snapshot = await routesRef.get().catch(console.log);
const routes = [];
snapshot.forEach((doc) => {
routes.push({ ...doc.data(), id: doc.id });
});
setRoutes(routes);
- };
+ }, [setRoutes]);
- const getBusses = async (routeId) => {
- const snapshot = await bussesRef.where('route_id', '==', routeId).get();
- const busses = [];
- snapshot.forEach((doc) => {
- busses.push({ ...doc.data(), id: doc.id });
- });
- setBusses(busses);
- };
+ const getBusses = useCallback(
+ async (routeId) => {
+ const snapshot = await bussesRef
+ .where('route_id', '==', routeId)
+ .get()
+ .catch(console.log);
+
+ const busses = [];
+ snapshot.forEach((doc) => {
+ busses.push({ ...doc.data(), id: doc.id });
+ });
+ setBusses(busses);
+ },
+ [setBusses]
+ );
useEffect(() => {
getRoutes();
- });
+ }, [getRoutes]);
const handleShowAvailableBuses = (id) => {
setShowAvailableBuses((oldId) => (oldId === id ? null : id));
diff --git a/src/components/RouteListMap.js b/src/components/RouteListMap.js
index 7357d49..4ed912f 100644
--- a/src/components/RouteListMap.js
+++ b/src/components/RouteListMap.js
@@ -12,38 +12,36 @@ export default function RouteListMap({ path }) {
});
return (
- <>
-
{
- setViewport({ ...viewport, width: '100%', height: '100%' });
- }}
- mapStyle="mapbox://styles/shna/ckd4x2xmy02kh1ir3hihcr36m"
- >
- {path && (
-
- )}
-
- >
+
{
+ setViewport({ ...viewport, width: '100%', height: '100%' });
+ }}
+ mapStyle="mapbox://styles/shna/ckd4x2xmy02kh1ir3hihcr36m"
+ >
+ {path && (
+
+ )}
+
);
}
RouteListMap.propTypes = {
- path: PropTypes.func,
+ path: PropTypes.object,
};
diff --git a/src/components/VerticalLineDivide.js b/src/components/VerticalLineDivide.js
index 6ba3d93..1b6368d 100644
--- a/src/components/VerticalLineDivide.js
+++ b/src/components/VerticalLineDivide.js
@@ -3,7 +3,7 @@ import React from 'react';
export default function VerticalLineDivide() {
return (
);
}
diff --git a/src/components/__test__/RouteList.test.js b/src/components/__test__/RouteList.test.js
index 2e851ff..d29c748 100644
--- a/src/components/__test__/RouteList.test.js
+++ b/src/components/__test__/RouteList.test.js
@@ -3,5 +3,5 @@ import { render } from '@testing-library/react';
import RouteList from '../RouteList';
test('renders the RouteList', () => {
- render(
);
+ render(
{}} />);
});
diff --git a/src/pages/favorite.js b/src/pages/favorite.js
index 079e17b..b7c40e9 100644
--- a/src/pages/favorite.js
+++ b/src/pages/favorite.js
@@ -1,4 +1,10 @@
import React from 'react';
+import Favorite from '../components/Favorite';
+
export default function favorite() {
- return @todo return favorite page
;
+ return (
+
+
+
+ );
}