-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathAside.tsx
132 lines (124 loc) · 4.51 KB
/
Aside.tsx
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import * as React from 'react';
import { Card, CardContent } from '@mui/material';
import LocalOfferIcon from '@mui/icons-material/LocalOfferOutlined';
import BarChartIcon from '@mui/icons-material/BarChart';
import AttachMoneyIcon from '@mui/icons-material/AttachMoney';
import {
FilterList,
FilterListItem,
FilterLiveSearch,
SavedQueriesList,
useGetList,
} from 'react-admin';
import { Category } from '../types';
import { humanize } from 'inflection';
const Aside = () => {
const { data } = useGetList<Category>('categories', {
pagination: { page: 1, perPage: 100 },
sort: { field: 'name', order: 'ASC' },
});
return (
<Card
sx={{
display: { xs: 'none', md: 'block' },
order: -1,
width: '15em',
mr: 2,
alignSelf: 'flex-start',
}}
>
<CardContent sx={{ pt: 1 }}>
<FilterLiveSearch hiddenLabel />
<SavedQueriesList />
<FilterList
label="resources.products.filters.sales"
icon={<AttachMoneyIcon />}
>
<FilterListItem
label="resources.products.filters.best_sellers"
value={{
sales_lte: undefined,
sales_gt: 25,
sales: undefined,
}}
/>
<FilterListItem
label="resources.products.filters.average_sellers"
value={{
sales_lte: 25,
sales_gt: 10,
sales: undefined,
}}
/>
<FilterListItem
label="resources.products.filters.low_sellers"
value={{
sales_lte: 10,
sales_gt: 0,
sales: undefined,
}}
/>
<FilterListItem
label="resources.products.filters.never_sold"
value={{
sales_lte: undefined,
sales_gt: undefined,
sales: 0,
}}
/>
</FilterList>
<FilterList
label="resources.products.filters.stock"
icon={<BarChartIcon />}
>
<FilterListItem
label="resources.products.filters.no_stock"
value={{
stock_lt: undefined,
stock_gt: undefined,
stock: 0,
}}
/>
<FilterListItem
label="resources.products.filters.low_stock"
value={{
stock_lt: 10,
stock_gt: 0,
stock: undefined,
}}
/>
<FilterListItem
label="resources.products.filters.average_stock"
value={{
stock_lt: 50,
stock_gt: 9,
stock: undefined,
}}
/>
<FilterListItem
label="resources.products.filters.enough_stock"
value={{
stock_lt: undefined,
stock_gt: 49,
stock: undefined,
}}
/>
</FilterList>
<FilterList
label="resources.products.filters.categories"
icon={<LocalOfferIcon />}
>
{data &&
data.map((record: any) => (
<FilterListItem
label={humanize(record.name)}
key={record.id}
value={{ category_id: record.id }}
/>
))}
</FilterList>
</CardContent>
</Card>
);
};
export default Aside;