#
luxiaotao1123
2024-09-09 b12bb2d9e4922c513185ca3bb480da1b54954304
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
import {
    SavedQueriesList,
    FilterLiveSearch,
    FilterList,
    FilterListItem,
    useTheme,
    useStore,
} from 'react-admin';
import { Box, Typography, Card, CardContent } from '@mui/material';
import { styled } from '@mui/material/styles';
import { DEFAULT_THEME_NAME } from '@/config/setting';
import * as Common from '@/utils/common';
import WcIcon from '@mui/icons-material/Wc';
import BookmarkIcon from '@mui/icons-material/BookmarkBorder';
import CategoryIcon from '@mui/icons-material/LocalOffer';
import AccessTimeIcon from '@mui/icons-material/AccessTime';
import {
    endOfYesterday,
    startOfWeek,
    subWeeks,
    startOfMonth,
    subMonths,
} from 'date-fns';
 
const UserListAside = (props) => {
    const theme = useTheme();
    console.log(endOfYesterday().toISOString())
 
    const isSelected = (value, filters) => {
        const categories = filters.categories || [];
        return categories.includes(value.category);
    };
 
    const toggleFilter = (value, filters) => {
        const categories = filters.categories || [];
        return {
            ...filters,
            categories: categories.includes(value.category)
                // Remove the category if it was already present
                ? categories.filter(v => v !== value.category)
                // Add the category if it wasn't already present
                : [...categories, value.category],
        };
    };
 
 
    return (
        <>
            <Card
                sx={{
                    display: { xs: 'none', md: 'block', },
                    order: -1,
                    mr: 2,
                    mt: 8,
                    alignSelf: 'flex-start',
                    border: theme[0] === 'light' && '1px solid #e0e0e3',
                    // borderRadius: 0,
                    // width: 200
                }}
            >
                <CardContent>
                    <SavedQueriesList icon={<BookmarkIcon />} />
                    <FilterLiveSearch source='condition' hiddenLabel />
 
                    <FilterList
                        label="filters.lastCreated"
                        icon={<AccessTimeIcon />}
                    >
                        <FilterListItem
                            label="filters.today"
                            value={{
                                timeStart: endOfYesterday().toISOString(),
                                timeEnd: undefined,
                            }}
                        />
                        <FilterListItem
                            label="filters.thisWeek"
                            value={{
                                timeStart: startOfWeek(new Date()).toISOString(),
                                timeEnd: undefined,
                            }}
                        />
                        <FilterListItem
                            label="filters.lastWeek"
                            value={{
                                timeStart: subWeeks(startOfWeek(new Date()), 1).toISOString(),
                                timeEnd: startOfWeek(new Date()).toISOString(),
                            }}
                        />
                        <FilterListItem
                            label="filters.thisMonth"
                            value={{
                                timeStart: startOfMonth(new Date()).toISOString(),
                                timeEnd: undefined,
                            }}
                        />
                        <FilterListItem
                            label="filters.lastMonth"
                            value={{
                                timeStart: subMonths(startOfMonth(new Date()), 1).toISOString(),
                                timeEnd: startOfMonth(new Date()).toISOString(),
                            }}
                        />
                        <FilterListItem
                            label="filters.earlier"
                            value={{
                                timeStart: undefined,
                                timeEnd: subMonths(startOfMonth(new Date()), 1).toISOString(),
                            }}
                        />
                    </FilterList>
 
                    <FilterList label="table.field.user.sex" icon={<WcIcon />}>
                        <FilterListItem label="Male" value={{ sex: '1' }} />
                        <FilterListItem label="Female" value={{ sex: '2' }} />
                        <FilterListItem label="They" value={{ sex: '0' }} />
                    </FilterList>
 
                    <FilterList label="Categories" icon={<CategoryIcon />}>
                        <FilterListItem
                            label="Tests"
                            value={{ category: 'tests' }}
                            isSelected={isSelected}
                            toggleFilter={toggleFilter}
                        />
                        <FilterListItem
                            label="News"
                            value={{ category: 'news' }}
                            isSelected={isSelected}
                            toggleFilter={toggleFilter}
                        />
                        <FilterListItem
                            label="Deals"
                            value={{ category: 'deals' }}
                            isSelected={isSelected}
                            toggleFilter={toggleFilter}
                        />
                    </FilterList>
                </CardContent>
            </Card>
        </>
    )
}
 
export default UserListAside;