@@ -5,7 +5,11 @@ import { breakpointLargeHandset } from 'common/constants'
5
5
import { useTranslation } from 'next-i18next'
6
6
import { Loader } from 'components/loader/loader'
7
7
import Link from 'next/link'
8
+ import { savedItemsSetSortOrder } from 'containers/saves/saved-items/saved-items.state'
9
+ import { savedItemsSetSortBy } from 'containers/saves/saved-items/saved-items.state'
8
10
import { SearchFilterMenu } from 'components/list-filter-menu/search-filter-menu'
11
+ import { ListSort } from 'components/list-sort/list-sort'
12
+ import { useDispatch } from 'react-redux'
9
13
10
14
const searchStyles = css `
11
15
margin-bottom : 1.5rem ;
@@ -50,7 +54,8 @@ const searchStyles = css`
50
54
}
51
55
}
52
56
.sourceBar {
53
- display : block;
57
+ display : flex;
58
+ justify-content : space-between;
54
59
a {
55
60
text-decoration : none;
56
61
display : inline-block;
@@ -68,8 +73,22 @@ const searchStyles = css`
68
73
}
69
74
`
70
75
71
- export const SearchPageHeader = ( { total, loading, query, searchType, filter } ) => {
76
+ export const SearchPageHeader = ( {
77
+ total,
78
+ loading,
79
+ query,
80
+ searchType,
81
+ filter,
82
+ sortOrder,
83
+ isPremium
84
+ } ) => {
72
85
const { t } = useTranslation ( )
86
+ const dispatch = useDispatch ( )
87
+
88
+ const handleNewest = ( ) => dispatch ( savedItemsSetSortOrder ( 'DESC' ) )
89
+ const handleOldest = ( ) => dispatch ( savedItemsSetSortOrder ( 'ASC' ) )
90
+ const handleRelevance = ( ) => dispatch ( savedItemsSetSortBy ( 'RELEVANCE' ) )
91
+
73
92
return query ? (
74
93
< header className = { searchStyles } >
75
94
< h1 className = "pageTitle" data-testid = "page-title" >
@@ -87,16 +106,29 @@ export const SearchPageHeader = ({ total, loading, query, searchType, filter })
87
106
) }
88
107
</ h1 >
89
108
< div className = "sourceBar" >
90
- < Link className = { searchType === 'all' ? 'active' : '' } href = { `/search?q=${ query } &st=all` } >
91
- All of Pocket
92
- </ Link > { ' ' }
93
- < Link
94
- className = { searchType === 'saves' ? 'active' : '' }
95
- href = { `/search?q=${ query } &st=saves` } >
96
- Only My Saves
97
- </ Link >
109
+ < div >
110
+ < Link className = { searchType === 'all' ? 'active' : '' } href = { `/search?q=${ query } &st=all` } >
111
+ All of Pocket
112
+ </ Link > { ' ' }
113
+ < Link
114
+ className = { searchType === 'saves' ? 'active' : '' }
115
+ href = { `/search?q=${ query } &st=saves` } >
116
+ Only My Saves
117
+ </ Link >
118
+ { searchType === 'saves' ? (
119
+ < SearchFilterMenu subset = "search" query = { query } filter = { filter } sortOrder = { sortOrder } />
120
+ ) : null }
121
+ </ div >
98
122
{ searchType === 'saves' ? (
99
- < SearchFilterMenu subset = "search" query = { query } filter = { filter } />
123
+ < ListSort
124
+ query = { query }
125
+ filter = { filter }
126
+ showRelevance = { isPremium }
127
+ sortOrder = { sortOrder }
128
+ handleNewest = { handleNewest }
129
+ handleOldest = { handleOldest }
130
+ handleRelevance = { handleRelevance }
131
+ />
100
132
) : null }
101
133
</ div >
102
134
</ header >
0 commit comments