Skip to content

Commit

Permalink
fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmman committed Dec 20, 2024
1 parent 50ce732 commit 07aa99d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/components/cities-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CITIES } from '../consts/cities.ts';
import { City } from '../dataTypes/city.ts';
import { useAppDispatch } from '../store/store.ts';
import { changeCity } from '../store/offers/offers.slice.ts';
import { fetchOffers } from '../store/async-actions.ts';

interface CitiesListProps {
activeCityName: string;
Expand All @@ -25,7 +26,10 @@ function CitiesListImpl({
) : (
<div
className="locations__item-link tabs__item"
onClick={() => dispatch(changeCity(city))}
onClick={() => {
dispatch(fetchOffers());
dispatch(changeCity(city));
}}
>
<span>{city.name}</span>
</div>
Expand Down
12 changes: 10 additions & 2 deletions src/components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import { Link } from 'react-router-dom';
import { AppRoute } from '../../dataTypes/enums/app-route.ts';
import { useAppSelector } from '../../store/store.ts';
import { useAppDispatch, useAppSelector } from '../../store/store.ts';
import { memo } from 'react';
import { UserInfo } from './user-info.tsx';
import { getIsAuthorized } from '../../store/user/user.selectors.ts';
import { fetchOffers } from '../../store/async-actions.ts';

interface HeaderProps {
dontShowUserInfo: boolean;
}

function HeaderImpl({ dontShowUserInfo }: HeaderProps) {
const dispatch = useAppDispatch();
const isAuthorized = useAppSelector(getIsAuthorized);
return (
<header className="header">
<div className="container">
<div className="header__wrapper">
<div className="header__left">
<Link className="header__logo-link" to={AppRoute.MainPage}>
<Link
className="header__logo-link"
to={AppRoute.MainPage}
onClick={() => {
dispatch(fetchOffers());
}}
>
<img
className="header__logo"
src="img/logo.svg"
Expand Down
2 changes: 1 addition & 1 deletion src/store/offers/offers.selector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('offers selectors test', () => {
city: AMSTERDAM,
offers: getMockOffers(3),
sorting: (offers: Offer[]) =>
offers.toSorted((a, b) => a.price - b.price),
offers.sort((a, b) => a.price - b.price),
favoritesOffers: getMockOffers(4),
},
};
Expand Down

0 comments on commit 07aa99d

Please sign in to comment.