-
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 GooDeene/module6-task2
- Loading branch information
Showing
15 changed files
with
177 additions
and
27 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/components/dropdown-offers-filter/dropdown-offers-filter-option.tsx
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,26 @@ | ||
import {SortingOrder} from '../../types/sorting-order.ts'; | ||
import classNames from 'classnames'; | ||
import React from 'react'; | ||
import {useDispatch} from 'react-redux'; | ||
import {setSortingOrder} from '../../store/acions.ts'; | ||
|
||
type DropdownOffersFilterOptionProps = { | ||
sortingOption: SortingOrder; | ||
isActive: boolean; | ||
dropdownStateSetter: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
function DropdownOffersFilterOption({sortingOption, isActive, dropdownStateSetter} : DropdownOffersFilterOptionProps) : JSX.Element { | ||
const dispatch = useDispatch(); | ||
const className = classNames('places__option', {'places__option--active' : isActive}); | ||
const handleSortingOptionOnClick = () => { | ||
dropdownStateSetter((state) => !state); | ||
dispatch(setSortingOrder(sortingOption)); | ||
}; | ||
|
||
return ( | ||
<li className={className} tabIndex={0} onClick={handleSortingOptionOnClick}>{sortingOption}</li> | ||
); | ||
} | ||
|
||
export default DropdownOffersFilterOption; |
49 changes: 40 additions & 9 deletions
49
src/components/dropdown-offers-filter/dropdown-offers-filter.tsx
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
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
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 |
---|---|---|
@@ -1,4 +1,12 @@ | ||
import {createAction} from '@reduxjs/toolkit'; | ||
import {City} from '../types/city.ts'; | ||
import {Nullable} from '../types/nullable.ts'; | ||
import {SortingOrder} from '../types/sorting-order.ts'; | ||
import {OffersShort} from '../types/offers/offer-short.ts'; | ||
|
||
export const setActiveCity = createAction<City>('setCity'); | ||
export const setHoverCardId = createAction<Nullable<string>>('setHooverCardId'); | ||
|
||
export const setSortingOrder = createAction<SortingOrder>('setSortingOrder'); | ||
|
||
export const setOffers = createAction<OffersShort>('setOffers'); |
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,6 @@ | ||
export enum SortingOrder { | ||
popular = 'Popular', | ||
priceToHigh = 'Price: low to high', | ||
priceToLow = 'Price: high to low', | ||
topRated = 'Top rated first', | ||
} |
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