-
Notifications
You must be signed in to change notification settings - Fork 0
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 #16 from Ayon95/cabin_filter_and_sort
Add cabin filter and sort controls
- Loading branch information
Showing
14 changed files
with
512 additions
and
13 deletions.
There are no files selected for viewing
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,60 @@ | ||
import styled from 'styled-components'; | ||
|
||
import Filter from '@/ui/Filter'; | ||
import SortDropdown from '@/ui/SortDropdown'; | ||
import { CabinFields } from '@/types/cabins'; | ||
import { SortDirections } from '@/types/sort'; | ||
|
||
type SortOptions = { | ||
label: string; | ||
value: `${CabinFields}-${SortDirections}`; | ||
}[]; | ||
|
||
const filterOptions = [ | ||
{ label: 'Discount', value: 'true' }, | ||
{ label: 'No discount', value: 'false' }, | ||
]; | ||
|
||
const sortOptions: SortOptions = [ | ||
{ | ||
label: 'Name (A-Z)', | ||
value: 'name-asc', | ||
}, | ||
{ | ||
label: 'Name (Z-A)', | ||
value: 'name-desc', | ||
}, | ||
{ | ||
label: 'Price (lowest to highest)', | ||
value: 'regular_price-asc', | ||
}, | ||
{ | ||
label: 'Price (highest to lowest)', | ||
value: 'regular_price-desc', | ||
}, | ||
{ | ||
label: 'Max capacity (lowest to highest)', | ||
value: 'max_capacity-asc', | ||
}, | ||
{ | ||
label: 'Max capacity (highest to lowest)', | ||
value: 'max_capacity-desc', | ||
}, | ||
]; | ||
|
||
function CabinFilterAndSortControls() { | ||
return ( | ||
<Container> | ||
<Filter<CabinFields> options={filterOptions} field="discount" /> | ||
<SortDropdown options={sortOptions} /> | ||
</Container> | ||
); | ||
} | ||
|
||
export default CabinFilterAndSortControls; | ||
|
||
const Container = styled.div` | ||
& > *:first-child { | ||
margin-bottom: 1rem; | ||
} | ||
`; |
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
Oops, something went wrong.