Skip to content

Commit

Permalink
feat: add space name filters
Browse files Browse the repository at this point in the history
  • Loading branch information
healim01 committed Jan 24, 2024
1 parent 990cd49 commit aa79c13
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions src/sections/reservelist/view/reserve-list-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
IReserveTableFilterValue,
} from 'src/types/reserveList';
//
import { Typography } from '@mui/material';
import { Button, Typography } from '@mui/material';
import axiosInstance, { endpoints } from 'src/utils/axios';
import { useRecoilValue } from 'recoil';
import { userDeptState } from 'src/utils/atom';
Expand Down Expand Up @@ -125,7 +125,10 @@ export default function ReserveListView() {
const denseHeight = table.dense ? 52 : 72;

const canReset =
!!filters.name || filters.status !== '전체' || (!!filters.startDate && !!filters.endDate);
!!filters.space ||
!!filters.name ||
filters.status !== '전체' ||
(!!filters.startDate && !!filters.endDate);

const notFound = (!dataFiltered.length && canReset) || !dataFiltered.length;

Expand Down Expand Up @@ -240,11 +243,22 @@ export default function ReserveListView() {
)
}
action={
<Tooltip title="Delete">
<IconButton color="primary" onClick={confirm.onTrue}>
<Iconify icon="solar:trash-bin-trash-bold" />
</IconButton>
</Tooltip>
<>
<Tooltip title="Add">
<IconButton color="primary" onClick={confirm.onTrue}>
<Button variant="outlined" color="primary">
전체 승인
</Button>
</IconButton>
</Tooltip>
<Tooltip title="Delete">
<IconButton color="primary" onClick={confirm.onTrue}>
<Button variant="outlined" color="error">
전체 삭제
</Button>
</IconButton>
</Tooltip>
</>
}
/>

Expand Down Expand Up @@ -335,11 +349,23 @@ function applyFilter({
inputData = stabilizedThis.map((el) => el[0]);

if (name) {
inputData = inputData.filter(
(order) =>
order.id.toLowerCase().indexOf(name.toLowerCase()) !== -1 ||
order.createMemberName.toLowerCase().indexOf(name.toLowerCase()) !== -1
);
inputData = inputData.filter((order) => {
const orderId = order.id && typeof order.id === 'string' ? order.id.toLowerCase() : '';
const memberName =
order.createMemberName && typeof order.createMemberName === 'string'
? order.createMemberName.toLowerCase()
: '';
const spaceName =
order.space.name && typeof order.space.name === 'string'
? order.space.name.toLowerCase()
: '';

return (
orderId.indexOf(name.toLowerCase()) !== -1 ||
memberName.indexOf(name.toLowerCase()) !== -1 ||
spaceName.indexOf(name.toLowerCase()) !== -1
);
});
}

if (status !== '전체') {
Expand All @@ -350,8 +376,8 @@ function applyFilter({
if (startDate && endDate) {
inputData = inputData.filter(
(order) =>
fTimestamp(order.modDate) >= fTimestamp(startDate) &&
fTimestamp(order.modDate) <= fTimestamp(endDate)
fTimestamp(order.reserveDate) >= fTimestamp(startDate) &&
fTimestamp(order.reserveDate) <= fTimestamp(endDate)
);
}
}
Expand Down

0 comments on commit aa79c13

Please sign in to comment.