diff --git a/src/components/app/app.js b/src/components/app/app.js index 5e460dd..fe20519 100644 --- a/src/components/app/app.js +++ b/src/components/app/app.js @@ -10,7 +10,7 @@ export default class App extends PureComponent {
- +
); } diff --git a/src/components/restaurants/restaurants.js b/src/components/restaurants/restaurants.js index 79ed192..7d9fe2c 100644 --- a/src/components/restaurants/restaurants.js +++ b/src/components/restaurants/restaurants.js @@ -1,41 +1,43 @@ -import { useEffect, useMemo } from 'react'; +import { useEffect } from 'react'; import { connect } from 'react-redux'; +import { NavLink } from 'react-router-dom'; import PropTypes from 'prop-types'; import Restaurant from '../restaurant'; -import Tabs from '../tabs'; import Loader from '../loader'; import { restaurantsListSelector, - activeIdRestaurantSelector, restaurantsLoadingSelector, restaurantsLoadedSelector, } from '../../redux/selectors'; -import { loadRestaurants, changeRestaurant } from '../../redux/actions'; +import { loadRestaurants } from '../../redux/actions'; -function Restaurants({ - restaurants, - activeId, - loading, - loaded, - loadRestaurants, - changeRestaurant, -}) { +import styles from './restaurants.module.css'; + +function Restaurants({ restaurants, loading, loaded, loadRestaurants, match }) { useEffect(() => { if (!loading && !loaded) loadRestaurants(); }, [loading, loaded, loadRestaurants]); - const tabs = useMemo( - () => restaurants.map(({ id, name }) => ({ id, label: name })), - [restaurants] - ); - if (loading) return ; if (!loaded) return 'No data :('; + const { restId } = match.params; + return (
- - +
+ {restaurants.map(({ id, name }) => ( + + {name} + + ))} +
+
); } @@ -50,7 +52,6 @@ Restaurants.propTypes = { }; const mapStateToProps = (state) => ({ - activeId: activeIdRestaurantSelector(state), restaurants: restaurantsListSelector(state), loading: restaurantsLoadingSelector(state), loaded: restaurantsLoadedSelector(state), @@ -58,7 +59,6 @@ const mapStateToProps = (state) => ({ const mapDispatchToProps = { loadRestaurants, - changeRestaurant, }; export default connect(mapStateToProps, mapDispatchToProps)(Restaurants); diff --git a/src/components/restaurants/restaurants.module.css b/src/components/restaurants/restaurants.module.css new file mode 100644 index 0000000..f93fc10 --- /dev/null +++ b/src/components/restaurants/restaurants.module.css @@ -0,0 +1,19 @@ +.tabs { + height: auto; + text-align: center; + padding: 12px; + background-color: var(--grey); +} + +.tabs span { + cursor: pointer; +} + +.tab { + padding: 4px 12px; + color: var(--black); +} + +.tab.active { + border-bottom: 1px solid var(--black); +}