-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from denispan/module7-task1
Истина где-то на сервере
- Loading branch information
Showing
20 changed files
with
354 additions
and
1,241 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import ContentLoader from 'react-content-loader'; | ||
|
||
function OfferLoader () { | ||
|
||
return ( | ||
<div className="cities__places-list places__list tabs__content"> | ||
<ContentLoader | ||
speed={2} | ||
width={285} | ||
height={330} | ||
viewBox="0 0 285 330" | ||
backgroundColor="#f5f5f5" | ||
foregroundColor="#ecebeb" | ||
> | ||
<rect x="2" y="0" rx="8" ry="8" width="270" height="200" /> | ||
<rect x="2" y="212" rx="8" ry="8" width="100" height="19" /> | ||
<rect x="2" y="238" rx="8" ry="8" width="73" height="12" /> | ||
<rect x="2" y="258" rx="8" ry="8" width="200" height="22" /> | ||
</ContentLoader> | ||
</div> | ||
); | ||
} | ||
|
||
export default OfferLoader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ContentLoader from 'react-content-loader'; | ||
import OfferLoader from '../offer-loader/offer-loader.tsx'; | ||
import {OFFERS_LOADER_COUNT} from '../../const.ts'; | ||
|
||
|
||
function OffersListLoader () { | ||
const offerLoaders = Array.from({length: OFFERS_LOADER_COUNT}, (i: number) => i++); | ||
return ( | ||
<section className="cities__places places"> | ||
<h2 className="visually-hidden">Places</h2> | ||
<div style={{width: '100%'}}> | ||
<ContentLoader | ||
speed={2} | ||
width={572} | ||
height={120} | ||
viewBox="0 0 572 120" | ||
backgroundColor="#f5f5f5" | ||
foregroundColor="#ecebeb" | ||
> | ||
<rect x="2" y="20" rx="8" ry="8" width="450" height="28"/> | ||
<rect x="2" y="70" rx="4" ry="4" width="100" height="14"/> | ||
</ContentLoader> | ||
</div> | ||
|
||
<div className="cities__places-list places__list tabs__content"> | ||
{offerLoaders.map((loader) => <OfferLoader key={loader}/>)} | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
export default OffersListLoader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import type {OfferShortInfo} from '../../types/offer.ts'; | ||
import OfferCard from '../offer-card/offer-card.tsx'; | ||
import {useActionCreators, useAppSelector} from '../../hooks/store.ts'; | ||
import {offersActions, offersSelectors} from '../../store/slices/offers.ts'; | ||
import {sortOffers} from '../../utils/sort.ts'; | ||
import {SORT_OPTION_DEFAULT, SortOption} from '../sort/const.ts'; | ||
import Sort from '../sort/sort.tsx'; | ||
import {useState} from 'react'; | ||
import {CITIES, RequestStatus} from '../../const.ts'; | ||
import OffersListLoader from '../offers-list-loader/offers-list-loader.tsx'; | ||
|
||
interface OffersListProps { | ||
offersByCity: OfferShortInfo[]; | ||
city: typeof CITIES[number]; | ||
} | ||
|
||
function OffersList ({offersByCity, city}: OffersListProps) { | ||
const [activeSortOption, setActiveSortOption] = useState<SortOption>(SORT_OPTION_DEFAULT); | ||
|
||
const {setActiveOffer} = useActionCreators(offersActions); | ||
const status = useAppSelector(offersSelectors.status); | ||
|
||
const offersSorted = sortOffers(activeSortOption, offersByCity); | ||
|
||
if (status === RequestStatus.Loading) { | ||
return ( | ||
<OffersListLoader /> | ||
); | ||
} | ||
|
||
return ( | ||
<section className="cities__places places"> | ||
<h2 className="visually-hidden">Places</h2> | ||
<b className="places__found"> | ||
{offersByCity.length} place{offersByCity.length > 1 && 's'} to stay in {city?.name} | ||
</b> | ||
<Sort | ||
activeSortOption={activeSortOption} | ||
setActiveSortOption={setActiveSortOption} | ||
/> | ||
<div className="cities__places-list places__list tabs__content"> | ||
{offersSorted.map((offer: OfferShortInfo) => | ||
( | ||
<OfferCard | ||
key={offer.id} | ||
componentType={'cities'} | ||
offer={offer} | ||
hoverHandler={() => setActiveOffer(offer)} | ||
/> | ||
))} | ||
</div> | ||
</section> | ||
|
||
); | ||
} | ||
|
||
export default OffersList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.