-
Notifications
You must be signed in to change notification settings - Fork 0
/
Filters.jsx
68 lines (67 loc) · 1.78 KB
/
Filters.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { Form, useLoaderData, Link } from 'react-router-dom';
import FormInput from './FormInput';
import FormSelect from './FormSelect';
import FormRange from './FormRange';
import FormCheckbox from './FormCheckbox';
const Filters = () => {
const { meta, params } = useLoaderData();
const { search, company, category, shipping, order, price } = params;
return (
<Form className='bg-base-200 rounded-md px-8 py-4 grid gap-x-4 gap-y-8 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 items-center'>
{/* SEARCH */}
<FormInput
type='search'
label='search product'
name='search'
size='input-sm'
defaultValue={search}
/>
{/* CATEGORIES */}
<FormSelect
label='select category'
name='category'
list={meta.categories}
size='select-sm'
defaultValue={category}
/>
{/* COMPANIES */}
<FormSelect
label='select company'
name='company'
list={meta.companies}
size='select-sm'
defaultValue={company}
/>
{/* ORDER */}
<FormSelect
label='sort by'
name='order'
list={['a-z', 'z-a', 'high', 'low']}
size='select-sm'
defaultValue={order}
/>
{/* PRICE */}
<FormRange
name='price'
label='select price'
size='range-sm'
price={price}
/>
{/* SHIPPING */}
<FormCheckbox
name='shipping'
label='free shipping'
size='checkbox-sm'
defaultValue={shipping}
/>
{/* BUTTONS */}
<button type='submit' className='btn btn-primary btn-sm'>
search
</button>
<Link to='/products' className='btn btn-accent btn-sm'>
reset
</Link>
</Form>
);
};
export default Filters;