Skip to content

Commit

Permalink
done main-page-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmman committed Nov 30, 2024
1 parent 5c4db2a commit ef6b355
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 37 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="src/pages/not-found-page/not-found-page.css">
<link rel="stylesheet" href="src/components/spinner/spinner.css">
<link rel="stylesheet" href="src/pages/main-page/main-page-empty.css">
</head>

<body>
Expand Down
4 changes: 4 additions & 0 deletions src/Pages/main-page/main-page-empty.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.no-offers {
background-image: url("../../../public/img/[email protected]");
background-size: cover;
}
91 changes: 54 additions & 37 deletions src/Pages/main-page/main-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,69 @@ export function MainPage(): React.JSX.Element {
const [activeOffer, setActiveOffer] = useState<Nullable<Offer>>(null);
const city = useAppSelector(getCity);
const offers = useAppSelector(getSortedOffers);
const offersCountCaption =
offers.length === 0
? 'No places to stay available'
: `${pluralizeAndCombine('place', offers.length)} to stay in ${city.name}`;
const handleActiveOfferChange = useCallback(
(offer: Nullable<Offer>) => setActiveOffer(offer),
[],
);
const offersCountCaption = `${pluralizeAndCombine('place', offers.length)} to stay in ${city.name}`;
return (
<div className="page page--gray page--main">
<Layout>
<main className="page__main page__main--index">
<Helmet>6 cities</Helmet>
<h1 className="visually-hidden">Cities</h1>
<CitiesList activeCityName={city.name} />
<div className="cities">
<div className="cities__places-container container">
<section className="cities__places places">
<h2 className="visually-hidden">Places</h2>
<b className="places__found">{offersCountCaption}</b>
<OfferSortSelect />
<OffersList
offers={offers}
onActiveOfferChange={useCallback(
(offer: Nullable<Offer>) => setActiveOffer(offer),
[],
)}
isOnMainPage
/>
</section>
<div className="cities__right-section">
<Map
city={city}
points={offers.map((x) => ({
location: x.location,
id: x.id,
}))}
selectedPoint={
activeOffer
? {
location: activeOffer?.location,
id: activeOffer?.id,
}
: undefined
}
isOnMainPage
/>
{offers.length > 0 ? (
<div className="cities">
<div className="cities__places-container container">
<section className="cities__places places">
<h2 className="visually-hidden">Places</h2>
<b className="places__found">{offersCountCaption}</b>
<OfferSortSelect />
<OffersList
offers={offers}
onActiveOfferChange={handleActiveOfferChange}
isOnMainPage
/>
</section>
<div className="cities__right-section">
<Map
city={city}
points={offers.map((x) => ({
location: x.location,
id: x.id,
}))}
selectedPoint={
activeOffer
? {
location: activeOffer?.location,
id: activeOffer?.id,
}
: undefined
}
isOnMainPage
/>
</div>
</div>
</div>
) : (
<div className="cities">
<div className="cities__places-container cities__places-container--empty container">
<section className="cities__no-places">
<div className="cities__status-wrapper tabs__content">
<b className="cities__status">
No places to stay available
</b>
<p className="cities__status-description">
{`We could not find any property available at the moment in
${city.name}`}
</p>
</div>
</section>
<div className="cities__right-section no-offers"></div>
</div>
</div>
</div>
)}
</main>
</Layout>
</div>
Expand Down

0 comments on commit ef6b355

Please sign in to comment.