2
2
import { motion } from 'framer-motion'
3
3
import styles from '@style'
4
4
import { DropDown , DropdownButton } from '@atoms/dropdown'
5
- import { IconToggle } from '@atoms/toggles'
6
- import { SingleViewIcon , MasonryIcon , ChevronIcon } from '@icons'
5
+ import { IconToggle , Toggle } from '@atoms/toggles'
6
+ import { SingleViewIcon , MasonryIcon , ChevronIcon , FiltersIcon } from '@icons'
7
7
8
- import { useState } from 'react'
8
+ import { useCallback , useState } from 'react'
9
9
import { Button } from '@atoms/button'
10
10
11
11
import { useLocalSettings } from '@context/localSettingsStore'
12
12
import { useLocation , useNavigate } from 'react-router'
13
13
import { useEffect } from 'react'
14
14
import { Line } from '@atoms/line'
15
15
import { shallow } from 'zustand/shallow'
16
+ import { Input } from '@atoms/input'
17
+ import { useSearchParams } from 'react-router-dom'
16
18
17
- // const MediaFilter = ({ label, tagline }) => {
18
- // return (
19
- // <div className={styles.media_type}>
20
- // <Toggle box label={label} />
21
- // <p className={styles.tagline}>{tagline}</p>
22
- // </div>
23
- // )
24
- // }
19
+ const MediaFilter = ( { label, tagline } ) => {
20
+ return (
21
+ < div className = { styles . media_type } >
22
+ < Toggle box label = { label } />
23
+ < p className = { styles . tagline } > { tagline } </ p >
24
+ </ div >
25
+ )
26
+ }
25
27
26
28
const locationMap = new Map ( [
27
29
[ '/' , 'Recent Sales' ] ,
@@ -51,7 +53,7 @@ const locationNeedSync = ['/feed/friends']
51
53
const locationPaths = [ ...locationMap . keys ( ) ]
52
54
53
55
export const FeedToolbar = ( { feeds_menu = false } ) => {
54
- // const [price, setPrice] = useState({ from: 0, to: 0 })
56
+ const [ price , setPrice ] = useState ( { from : 0 , to : 0 } )
55
57
56
58
const [ viewMode , setViewMode ] = useLocalSettings (
57
59
( st ) => [ st . viewMode , st . setViewMode ] ,
@@ -62,6 +64,8 @@ export const FeedToolbar = ({ feeds_menu = false }) => {
62
64
63
65
const navigate = useNavigate ( )
64
66
67
+ const [ searchParams , setSearchParams ] = useSearchParams ( )
68
+
65
69
useEffect ( ( ) => {
66
70
for ( const pth of locationPaths . slice ( 1 ) ) {
67
71
if ( location . pathname . includes ( pth ) ) {
@@ -72,8 +76,18 @@ export const FeedToolbar = ({ feeds_menu = false }) => {
72
76
// return locationMap[location]
73
77
} , [ location ] )
74
78
79
+ const updateParams = useCallback (
80
+ ( key , value ) => {
81
+ setSearchParams ( {
82
+ ...Object . fromEntries ( searchParams ) ,
83
+ [ key ] : value ,
84
+ } )
85
+ } ,
86
+ [ searchParams , setSearchParams ]
87
+ )
88
+
75
89
// TODO: finish the filtering logic
76
- // const filters = false
90
+ const filters = true
77
91
return (
78
92
< motion . div className = { styles . toolbar } >
79
93
{ feeds_menu && (
@@ -130,8 +144,37 @@ export const FeedToolbar = ({ feeds_menu = false }) => {
130
144
icon = { < MasonryIcon /> }
131
145
/>
132
146
</ div >
147
+ { true && (
148
+ < DropdownButton
149
+ direction = "left"
150
+ menuID = "sort"
151
+ icon = { < FiltersIcon /> }
152
+ label = "Sort"
153
+ className = { styles . sort_area }
154
+ >
155
+ < DropDown left menuID = "sort" >
156
+ < motion . div key = "filters" className = { styles . filters_container } >
157
+ < motion . div key = "media" className = { styles . filter_box } >
158
+ < Button onClick = { ( ) => updateParams ( 'sort' , 'price' ) } box fit >
159
+ By Price
160
+ </ Button >
161
+ < Button
162
+ onClick = { ( ) => updateParams ( 'sort' , 'buy_date' ) }
163
+ box
164
+ fit
165
+ >
166
+ By Last Purchase Date
167
+ </ Button >
168
+ < Button onClick = { ( ) => updateParams ( 'sort' , 'id' ) } box fit >
169
+ By ID Number
170
+ </ Button >
171
+ </ motion . div >
172
+ </ motion . div >
173
+ </ DropDown >
174
+ </ DropdownButton >
175
+ ) }
133
176
{ /* KEEP */ }
134
- { /* { filters && (
177
+ { filters && (
135
178
< DropdownButton
136
179
direction = "left"
137
180
menuID = "filters"
@@ -164,78 +207,68 @@ export const FeedToolbar = ({ feeds_menu = false }) => {
164
207
</ motion . div >
165
208
< motion . div key = "prices" className = { styles . filter_box } >
166
209
< h1 > Price</ h1 >
167
- <div style={{ display: 'flex' }}>
168
- <Input
169
- type="number"
170
- min={0}
171
- max={1e6}
172
- onChange={(e) => {
173
- console.log(e.target.value)
174
- setPrice({ ...price, from: e.target.value })
175
- console.log(price)
176
- }}
177
- placeholder={`0`}
178
- label="From"
179
- value={price.from}
180
- >
181
- <Line/>
182
- </Input>
183
- <Input
184
- type="number"
185
- min={0}
186
- max={1e6}
187
- onChange={(e) => {
188
- console.log(e.target.value)
189
- setPrice({ ...price, to: e.target.value })
190
- console.log(price)
191
- }}
192
- placeholder={`0`}
193
- label="To"
194
- value={price.to}
195
- >
196
- <Line/>
197
- </Input>
210
+ < div >
211
+ < div style = { { display : 'flex' } } >
212
+ < Input
213
+ type = "number"
214
+ min = { 0 }
215
+ max = { 1e6 }
216
+ onChange = { ( e ) => {
217
+ console . log ( e . target . value )
218
+ setPrice ( { ...price , from : e . target . value } )
219
+ console . log ( price )
220
+ } }
221
+ placeholder = { `0` }
222
+ label = "From"
223
+ value = { price . from }
224
+ >
225
+ < Line />
226
+ </ Input >
227
+ < Input
228
+ type = "number"
229
+ min = { 0 }
230
+ max = { 1e6 }
231
+ onChange = { ( e ) => {
232
+ console . log ( e . target . value )
233
+ setPrice ( { ...price , to : e . target . value } )
234
+ console . log ( price )
235
+ } }
236
+ placeholder = { `0` }
237
+ label = "To"
238
+ value = { price . to }
239
+ >
240
+ < Line />
241
+ </ Input >
242
+ </ div >
243
+ < div style = { { display : 'flex' , width : '100%' } } >
244
+ < Toggle box label = "Primary" />
245
+ < Toggle box label = "Secondary" />
246
+ </ div >
198
247
</ div >
199
248
</ motion . div >
200
249
< motion . div key = "tags" className = { styles . filter_box } >
201
250
< h1 > Featured tags</ h1 >
202
251
< p className = { styles . tagline } > Events</ p >
203
252
< div className = { styles . tags } >
204
- <Toggle
205
- box
206
- key="pakistan"
207
- label="Pakistan"
208
- />
253
+ < Toggle box key = "pakistan" label = "Pakistan" />
209
254
< Toggle box key = "ukraine" label = "Ukraine" />
210
255
< Toggle box key = "iran" label = "Iran" />
211
256
</ div >
212
257
< p className = { styles . tagline } > Popular</ p >
213
258
< div className = { styles . tags } >
214
- <Toggle
215
- box
216
- key="pixelart"
217
- label="pixelart"
218
- />
219
- <Toggle
220
- box
221
- key="generativeart"
222
- label="generativeart"
223
- />
259
+ < Toggle box key = "pixelart" label = "pixelart" />
260
+ < Toggle box key = "generativeart" label = "generativeart" />
224
261
< Toggle box key = "gan" label = "gan" />
225
262
</ div >
226
263
</ motion . div >
227
264
</ motion . div >
228
265
< div key = "confirm_box" className = { styles . confirm_box } >
229
- <Button>
230
- Clear
231
- </Button>
232
- <Button onClick={() => context.closeDropdowns()}>
233
- Ok
234
- </Button>
266
+ < Button > Clear</ Button >
267
+ { /* <Button onClick={() => context.closeDropdowns()}>Ok</Button> */ }
235
268
</ div >
236
269
</ DropDown >
237
270
</ DropdownButton >
238
- )} */ }
271
+ ) }
239
272
</ motion . div >
240
273
)
241
274
}
0 commit comments