Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework 6 #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/basket/basket-item/basket-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ import cn from 'classnames';
import { increment, decrement, remove } from '../../../redux/actions';
import Button from '../../button';
import styles from './basket-item.module.css';
import { Link } from 'react-router-dom';

function BasketItem({
product,
amount,
subtotal,
restaurantId,
increment,
decrement,
remove,
}) {
return (
<div className={styles.basketItem}>
<div className={styles.name}>
<span>{product.name}</span>
<Link to={`/restaurants/${restaurantId}`}>{product.name}</Link>
</div>
<div className={styles.info}>
<div className={styles.counter}>
Expand Down
3 changes: 2 additions & 1 deletion src/components/basket/basket.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ function Basket({ title = 'Basket', total, orderProducts }) {
return (
<div className={styles.basket}>
<h4 className={styles.title}>{title}</h4>
{orderProducts.map(({ product, amount, subtotal }) => (
{orderProducts.map(({ product, amount, subtotal, restaurantId }) => (
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не нашел файл с селекторами, где добавляется restaurantId

<BasketItem
product={product}
amount={amount}
key={product.id}
subtotal={subtotal}
restaurantId={restaurantId}
/>
))}
<hr className={styles.hr} />
Expand Down
44 changes: 35 additions & 9 deletions src/components/restaurant/restaurant.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,50 @@ import Menu from '../menu';
import Reviews from '../reviews';
import Banner from '../banner';
import Rate from '../rate';
import Tabs from '../tabs';
import { averageRatingSelector } from '../../redux/selectors';
import { NavLink, Route, Switch, useRouteMatch } from 'react-router-dom';

import styles from './restaurant.module.css';

const Restaurant = ({ id, name, menu, reviews, averageRating }) => {
const tabs = [
{ title: 'Menu', content: <Menu menu={menu} restaurantId={id} /> },
{
title: 'Reviews',
content: <Reviews reviews={reviews} restaurantId={id} />,
},
];
const match = useRouteMatch();
const menuUrl = `${match.url}/menu`;
const reviewsUrl = `${match.url}/reviews`;
console.log(match);

return (
<div>
<Banner heading={name}>
{!!averageRating && <Rate value={averageRating} />}
</Banner>
<Tabs tabs={tabs} />
<div className={styles.tabs}>
<NavLink
key={'menu'}
to={menuUrl}
className={styles.tab}
activeClassName={styles.active}
>
Menu
</NavLink>
<NavLink
key={'reviews'}
to={reviewsUrl}
className={styles.tab}
activeClassName={styles.active}
>
Reviews
</NavLink>
</div>
<Switch>
<Route
path={`${match.path}/menu`}
render={() => <Menu menu={menu} restaurantId={id} />}
/>
<Route
path={`${match.path}/reviews`}
render={() => <Reviews reviews={reviews} restaurantId={id} />}
/>
</Switch>
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/restaurants/restaurants.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Restaurants = ({ restaurants, match }) => {
{restaurants.map(({ id, name }) => (
<NavLink
key={id}
to={`/restaurants/${id}`}
to={`/restaurants/${id}/menu`}
className={styles.tab}
activeClassName={styles.active}
>
Expand Down
1 change: 0 additions & 1 deletion src/components/tabs/index.js

This file was deleted.

39 changes: 0 additions & 39 deletions src/components/tabs/tabs.js

This file was deleted.