From 7fdd11f312f6972557d0752bcab54e978bb2d8b1 Mon Sep 17 00:00:00 2001
From: mayonnaise <90057279+Mayanzev@users.noreply.github.com>
Date: Wed, 29 May 2024 14:15:33 +0300
Subject: [PATCH] final
---
src/pages/offer-screen/offer-screen.tsx | 9 +++++++--
src/services/api.ts | 2 +-
src/store/offer-data/offer-data.ts | 3 +++
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/pages/offer-screen/offer-screen.tsx b/src/pages/offer-screen/offer-screen.tsx
index c014513..ee60d13 100644
--- a/src/pages/offer-screen/offer-screen.tsx
+++ b/src/pages/offer-screen/offer-screen.tsx
@@ -12,6 +12,7 @@ import { getChosenOffer, getIsChosenOfferDataLoading, getNearbyOffers, getReview
import { getOffers } from '../../store/offers-data/selectors';
import { changeHighlightedMarker } from '../../store/common-data/common-data';
import ChangeFavoriteButton from '../../components/change-favorite-button/change-favorite-button';
+import NotFoundScreen from '../not-found-screen/not-found-screen';
const MAXIMUM_NEARBY_PREVIEW = 3;
@@ -20,7 +21,7 @@ function OfferScreen(): JSX.Element {
const offer = useAppSelector(getChosenOffer);
const reviews = useAppSelector(getReviews);
const nearbyOffers = useAppSelector(getNearbyOffers);
- const city = useAppSelector(getOffers)[0].city;
+ const offers = useAppSelector(getOffers);
const id = String(useParams().id);
const displayedNearby = (nearbyOffers).slice(
@@ -42,6 +43,10 @@ function OfferScreen(): JSX.Element {
);
}
+ if (!offer) {
+ return