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 ;
+ }
+
const bedrooms = offer?.bedrooms;
const maxAdults = offer?.maxAdults;
@@ -132,7 +137,7 @@ function OfferScreen(): JSX.Element {
-
diff --git a/src/services/api.ts b/src/services/api.ts
index 35f6851..d179801 100644
--- a/src/services/api.ts
+++ b/src/services/api.ts
@@ -16,7 +16,7 @@ const StatusCodeMapping: Record = {
const shouldDisplayError = (response: AxiosResponse) => !!StatusCodeMapping[response.status];
-const BACKEND_URL = 'https://14.design.htmlacademy.pro/six-cities';
+const BACKEND_URL = 'https://14.design.htmlacademy.pro/six-citie';
const REQUEST_TIMEOUT = 5000;
export const createAPI = (): AxiosInstance => {
diff --git a/src/store/offer-data/offer-data.ts b/src/store/offer-data/offer-data.ts
index a6fbc4d..95c86fc 100644
--- a/src/store/offer-data/offer-data.ts
+++ b/src/store/offer-data/offer-data.ts
@@ -26,6 +26,9 @@ export const offerData = createSlice({
.addCase(fetchOfferAction.pending, (state) => {
state.isChosenOfferDataLoading = true;
})
+ .addCase(fetchOfferAction.rejected, (state) => {
+ state.isChosenOfferDataLoading = false;
+ })
.addCase(fetchReviewsAction.fulfilled, (state, action) => {
state.isChosenOfferDataLoading = false;
state.reviews = action.payload;