import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
|
import {
|
SavedQueriesList,
|
FilterLiveSearch,
|
FilterList,
|
FilterListItem,
|
useTheme,
|
useStore,
|
useTranslate,
|
} from 'react-admin';
|
import { Box, Typography, Card, CardContent } from '@mui/material';
|
import * as Common from '@/utils/common';
|
import BookmarkIcon from '@mui/icons-material/BookmarkBorder';
|
import RunningWithErrorsIcon from '@mui/icons-material/RunningWithErrors';
|
import TypeSpecimenIcon from '@mui/icons-material/TypeSpecimen';
|
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
import {
|
endOfYesterday,
|
startOfWeek,
|
subWeeks,
|
startOfMonth,
|
subMonths,
|
} from 'date-fns';
|
import request from '@/utils/request'
|
|
const TaskListAside = (props) => {
|
const theme = useTheme();
|
const translate = useTranslate();
|
const [taskStsList, setTaskStsList] = React.useState([]);
|
const [taskTypeList, setTaskTypeList] = React.useState([]);
|
|
React.useEffect(() => {
|
request.post('/taskSts/list', {}).then(res => {
|
if (res?.data?.code === 200) {
|
setTaskStsList(res.data.data);
|
}
|
})
|
request.post('/taskType/list', {}).then(res => {
|
if (res?.data?.code === 200) {
|
setTaskTypeList(res.data.data);
|
}
|
})
|
}, [])
|
|
return (
|
<Card
|
sx={{
|
display: { xs: 'none', md: 'block', },
|
order: -1,
|
mr: 2,
|
mt: 8,
|
alignSelf: 'flex-start',
|
border: theme[0] === 'light' && '1px solid #e0e0e3',
|
width: 255
|
}}
|
>
|
<CardContent>
|
<SavedQueriesList icon={<BookmarkIcon />} />
|
<FilterLiveSearch label={translate("table.field.task.seqNum")} source='seqNum' 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.task.taskSts" icon={<RunningWithErrorsIcon />}>
|
{taskStsList.map(taskSts => {
|
return (
|
<FilterListItem
|
key={taskSts.id}
|
label={`${taskSts.name}`}
|
value={{ taskSts: taskSts.id }}
|
/>
|
)
|
})}
|
</FilterList>
|
|
<FilterList label="table.field.task.taskType" icon={<TypeSpecimenIcon />}>
|
{taskTypeList.map(taskType => {
|
return (
|
<FilterListItem
|
key={taskType.id}
|
label={`${taskType.name}`}
|
value={{ taskType: taskType.id }}
|
/>
|
)
|
})}
|
</FilterList>
|
|
</CardContent>
|
</Card>
|
)
|
}
|
|
export default TaskListAside;
|