Skip to content

Commit

Permalink
Merge pull request #11 from Shepard-m/module7-task3
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Mar 27, 2024
2 parents 362033e + 1201148 commit b2d6b0f
Show file tree
Hide file tree
Showing 24 changed files with 478 additions and 446 deletions.
121 changes: 53 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "vitest --passWithNoTests"
},
"dependencies": {
"@reduxjs/toolkit": "1.9.7",
"@reduxjs/toolkit": "2.2.1",
"axios": "1.5.1",
"clsx": "2.1.0",
"dayjs": "1.11.10",
Expand All @@ -20,20 +20,19 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-helmet-async": "1.3.0",
"react-redux": "8.1.3",
"react-redux": "9.1.0",
"react-router-dom": "6.16.0",
"react-toastify": "10.0.5"
},
"devDependencies": {
"@jedmao/redux-mock-store": "3.0.5",
"@testing-library/jest-dom": "6.1.3",
"@testing-library/react": "14.0.0",
"@testing-library/user-event": "14.5.1",
"@types/faker": "5.5.9",
"@types/leaflet": "1.9.3",
"@types/react": "18.2.25",
"@types/react-dom": "18.2.11",
"@types/react-redux": "7.1.27",
"@types/react-redux": "7.1.33",
"@types/testing-library__jest-dom": "5.14.9",
"@typescript-eslint/eslint-plugin": "6.7.4",
"@typescript-eslint/parser": "6.7.4",
Expand Down Expand Up @@ -61,4 +60,4 @@
"last 1 safari version"
]
}
}
}
6 changes: 3 additions & 3 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import OfferPage from '../pages/offer-page';
import FavoritePage from '../pages/favorite-page';
import LoginPage from '../pages/login-page';
import { Route, Routes } from 'react-router-dom';
import { AppRoute, AuthorizationStatus } from '../const';
import { AppRoute } from '../const';
import NotFoundPage from '../pages/not-found-page/not-found-page';
import ProtectedRoute from './protected-route';
import HistoryRouter from './history-route';
Expand All @@ -24,11 +24,11 @@ export default function App() {
/>
<Route
path={AppRoute.Favorites}
element={<ProtectedRoute authorizationStatus={AuthorizationStatus.UN_KNOWN}> <FavoritePage /></ProtectedRoute>}
element={<ProtectedRoute> <FavoritePage /></ProtectedRoute>}
/>
<Route
path={AppRoute.Login}
element={<LoginPage navigation={false} />}
element={<ProtectedRoute onlyUnAuth><LoginPage navigation={false} /></ProtectedRoute>}
/>
<Route
path='*'
Expand Down
11 changes: 2 additions & 9 deletions src/components/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Link } from 'react-router-dom';
import { OfferPreviews } from '../types/offer-preview';
import Rating from './rating';
import { AppRoute } from '../const';
import { chooseId } from '../store/action';
import { useAppDispatch } from '../hooks';

type TCardProps = {
offer: OfferPreviews;
Expand All @@ -17,11 +15,6 @@ type TCardProps = {

export default function Card({ offer, optionCard, handelPointCardMouseOver }: TCardProps) {
const { width, height, classCard } = optionCard;
const dispatch = useAppDispatch();

const onTransmissionDataClick = () => {
dispatch(chooseId(offer.id));
};

const onPointCardMouseOver = () => {
handelPointCardMouseOver(offer);
Expand All @@ -39,7 +32,7 @@ export default function Card({ offer, optionCard, handelPointCardMouseOver }: TC
</div>}

<div className="cities__image-wrapper place-card__image-wrapper">
<Link to={`/${AppRoute.Offer}/${offer.id}`} onClick={onTransmissionDataClick}>
<Link to={`/${AppRoute.Offer}/${offer.id}`}>
<img className="place-card__image" src={`${offer.previewImage}`} width={width} height={height} alt="Place image" />
</Link>
</div>
Expand All @@ -58,7 +51,7 @@ export default function Card({ offer, optionCard, handelPointCardMouseOver }: TC
</div>
<Rating ratingClass="place-card" rating={offer.rating} />
<h2 className="place-card__name" >
<Link to={`/${AppRoute.Offer}/${offer.id}`} state={offer} onClick={onTransmissionDataClick}>{offer.title}</Link>
<Link to={`/${AppRoute.Offer}/${offer.id}`} state={offer}>{offer.title}</Link>
</h2>
<p className="place-card__type" >{offer.type}</p>
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@ import { useEffect } from 'react';
import { checkAuthAction, fetchUserAction } from '../store/api-action';
import { logoutAction } from '../store/api-action';
import { AuthorizationStatus } from '../const';
import { userSelector } from '../store/slice/user';

type THeaderProps = {
navigation: boolean;
}

export default function Header({ navigation }: THeaderProps) {
const dispatch = useAppDispatch();
const favorite = useAppSelector((state) => state.favorite);
// const favorite = useAppSelector((state) => state.favorite);
const favorite = [];
useEffect(() => {
dispatch(fetchUserAction());
dispatch(checkAuthAction());
}, [dispatch]);
const authorizationStatus = useAppSelector((state) => state.authorizationStatus);
const user = useAppSelector((state) => state.dataUser);
const authorizationStatus = useAppSelector(userSelector.authorizationStatus);
const user = useAppSelector(userSelector.dataUser);

const logoutAccount = () => {
dispatch(logoutAction());
Expand Down
Loading

0 comments on commit b2d6b0f

Please sign in to comment.