Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmman committed Nov 20, 2024
1 parent 7868f1d commit 125af5d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Helmet } from 'react-helmet-async';
import { Layout } from '../components/layout.tsx';
import { OfferGroup } from '../components/offer/offer-group.tsx';
import { Offer } from '../dataTypes/offer.ts';
import { Layout } from '../../components/layout.tsx';
import { OfferGroup } from '../../components/offer/offer-group.tsx';
import { Offer } from '../../dataTypes/offer.ts';

interface FavoritesPageProps {
offers: Offer[];
Expand Down
File renamed without changes.
22 changes: 12 additions & 10 deletions src/Pages/main-page.tsx → src/Pages/main-page/main-page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useState } from 'react';
import { Offer } from '../dataTypes/offer.ts';
import { OffersList } from '../components/offer/offers-list.tsx';
import { Layout } from '../components/layout.tsx';
import { Offer } from '../../dataTypes/offer.ts';
import { OffersList } from '../../components/offer/offers-list.tsx';
import { Layout } from '../../components/layout.tsx';
import { Helmet } from 'react-helmet-async';
import { Nullable } from 'vitest';
import { Map } from '../components/map/map.tsx';
import { useAppSelector } from '../store/store.ts';
import { CitiesList } from '../components/cities-list.tsx';
import { pluralizeAndCombine } from '../utils/string-utils.ts';
import { OfferSortSelect } from '../components/offer/offer-sort-select.tsx';
import { Map } from '../../components/map/map.tsx';
import { useAppSelector } from '../../store/store.ts';
import { CitiesList } from '../../components/cities-list.tsx';
import { pluralizeAndCombine } from '../../utils/string-utils.ts';
import { OfferSortSelect } from '../../components/offer/offer-sort-select.tsx';

export function MainPage(): React.JSX.Element {
const [activeOffer, setActiveOffer] = useState<Nullable<Offer>>(null);
Expand All @@ -19,6 +19,9 @@ export function MainPage(): React.JSX.Element {
);
const sort = useAppSelector((state) => state.sorting);
const offers = sort(unsortedOffers);
const offersCountCaption = offers.length === 0
? 'No places to stay available'
: `${pluralizeAndCombine('place', offers.length)} to stay in ${city.name}`;
return (
<div className="page page--gray page--main">
<Layout showFooter>
Expand All @@ -31,8 +34,7 @@ export function MainPage(): React.JSX.Element {
<section className="cities__places places">
<h2 className="visually-hidden">Places</h2>
<b className="places__found">
{pluralizeAndCombine('place', offers.length)} to stay in{' '}
{city.name}
{offersCountCaption}
</b>
<OfferSortSelect/>
<OffersList
Expand Down
24 changes: 12 additions & 12 deletions src/Pages/offer-page.tsx → src/Pages/offer-page/offer-page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Helmet } from 'react-helmet-async';
import { Layout } from '../components/layout.tsx';
import { OffersList } from '../components/offer/offers-list.tsx';
import { offerMocks } from '../mocks/offers.ts';
import { Reviews } from '../components/reviews/reviews.tsx';
import { reviewMocks } from '../mocks/reviews.ts';
import { Map } from '../components/map/map.tsx';
import { Layout } from '../../components/layout.tsx';
import { OffersList } from '../../components/offer/offers-list.tsx';
import { offerMocks } from '../../mocks/offers.ts';
import { Reviews } from '../../components/reviews/reviews.tsx';
import { reviewMocks } from '../../mocks/reviews.ts';
import { Map } from '../../components/map/map.tsx';
import React from 'react';
import { useParams } from 'react-router-dom';
import { OfferInsideItems } from '../components/offer/offer-inside-items.tsx';
import { detailedOfferMocks } from '../mocks/detailed-offer.ts';
import { OfferHost } from '../components/offer/offer-host.tsx';
import { capitalize, pluralizeAndCombine } from '../utils/string-utils.ts';
import { Rating } from '../components/rating.tsx';
import { OfferGallery } from '../components/offer/offer-gallery.tsx';
import { OfferInsideItems } from '../../components/offer/offer-inside-items.tsx';
import { detailedOfferMocks } from '../../mocks/detailed-offer.ts';
import { OfferHost } from '../../components/offer/offer-host.tsx';
import { capitalize, pluralizeAndCombine } from '../../utils/string-utils.ts';
import { Rating } from '../../components/rating.tsx';
import { OfferGallery } from '../../components/offer/offer-gallery.tsx';
import { BookmarkButton } from '../components/bookmark-button.tsx';

export function OfferPage(): React.JSX.Element {
Expand Down
8 changes: 4 additions & 4 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { MainPage } from '../pages/main-page.tsx';
import { MainPage } from '../pages/main-page/main-page.tsx';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import { LoginPage } from '../pages/login-page.tsx';
import { FavoritesPage } from '../pages/favorites-page.tsx';
import { OfferPage } from '../pages/offer-page.tsx';
import { LoginPage } from '../pages/login-page/login-page.tsx';
import { FavoritesPage } from '../pages/favorites-page/favorites-page.tsx';
import { OfferPage } from '../pages/offer-page/offer-page.tsx';
import { NotFoundPage } from '../pages/not-found-page/not-found-page.tsx';
import { AuthorizationWrapper } from './authorization-wrapper.tsx';
import { AppRoutes } from '../dataTypes/enums/app-routes.ts';
Expand Down
6 changes: 3 additions & 3 deletions src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { City } from '../dataTypes/city.ts';
import { Offer } from '../dataTypes/offer.ts';
import { SortOffers } from '../dataTypes/sort-offers.ts';

export const changeCity = createAction<City>('mainPage/changeCity');
export const changeCity = createAction<City>('offers/changeCity');

export const fillOffers = createAction<Offer[]>('mainPage/fillOffers');
export const setOffers = createAction<Offer[]>('offers/setOffers');

export const setSorting = createAction<SortOffers>('mainPage/setSorting');
export const setSorting = createAction<SortOffers>('offers/setSorting');
4 changes: 2 additions & 2 deletions src/store/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { configureStore, createReducer } from '@reduxjs/toolkit';
import {changeCity, fillOffers, setSorting} from './actions.ts';
import {changeCity, setOffers, setSorting} from './actions.ts';
import { offerMocks } from '../mocks/offers.ts';
import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
import { AppDispatch, State } from '../dataTypes/store-types.ts';
Expand All @@ -17,7 +17,7 @@ const reducer = createReducer(initialState, (builder) => {
.addCase(changeCity, (state, action) => {
state.city = action.payload;
})
.addCase(fillOffers, (state, action) => {
.addCase(setOffers, (state, action) => {
state.offers = action.payload;
})
.addCase(setSorting, (state, action) => {
Expand Down

0 comments on commit 125af5d

Please sign in to comment.