Fix search
This commit is contained in:
parent
2ad1ee195f
commit
0f5c878dd4
|
|
@ -3,7 +3,7 @@ import { Button, Box, Drawer, Grid, Table, Text, ScrollArea, Tooltip, TextInput
|
||||||
import { DateInput } from "@mantine/dates";
|
import { DateInput } from "@mantine/dates";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import type { ISystemLog } from "../untils/types";
|
import type { ISystemLog } from "../untils/types";
|
||||||
import { IconDownload, IconEye, IconInfoCircle } from "@tabler/icons-react";
|
import { IconDownload, IconEye, IconInfoCircle, IconX } from "@tabler/icons-react";
|
||||||
import classes from "./Component.module.css";
|
import classes from "./Component.module.css";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import type { Socket } from "socket.io-client";
|
import type { Socket } from "socket.io-client";
|
||||||
|
|
@ -29,8 +29,8 @@ function DrawerLogs({
|
||||||
// const [isLogModalOpen, setIsLogModalOpen] = useState(false);
|
// const [isLogModalOpen, setIsLogModalOpen] = useState(false);
|
||||||
const [downloadName, setDownloadName] = useState("");
|
const [downloadName, setDownloadName] = useState("");
|
||||||
const [searchFileName, setSearchFileName] = useState("");
|
const [searchFileName, setSearchFileName] = useState("");
|
||||||
const [fromDate, setFromDate] = useState<string | null>(null);
|
const [fromDate, setFromDate] = useState<Date | null>(null);
|
||||||
const [toDate, setToDate] = useState<string | null>(null);
|
const [toDate, setToDate] = useState<Date | null>(null);
|
||||||
|
|
||||||
const [filteredLogs, setFilteredLogs] = useState<ISystemLog[]>([]);
|
const [filteredLogs, setFilteredLogs] = useState<ISystemLog[]>([]);
|
||||||
|
|
||||||
|
|
@ -76,8 +76,8 @@ function DrawerLogs({
|
||||||
// Chuẩn bị trước các giá trị search/date để tránh tính lại trong filter cho từng phần tử
|
// Chuẩn bị trước các giá trị search/date để tránh tính lại trong filter cho từng phần tử
|
||||||
const trimmedSearch = searchFileName.trim().toLowerCase();
|
const trimmedSearch = searchFileName.trim().toLowerCase();
|
||||||
const hasSearch = trimmedSearch.length > 0;
|
const hasSearch = trimmedSearch.length > 0;
|
||||||
const fromMoment = fromDate ? moment(fromDate, "DD/MM/YYYY").startOf("day") : null;
|
const fromMoment = fromDate ? moment(fromDate).startOf("day") : null;
|
||||||
const toMoment = toDate ? moment(toDate, "DD/MM/YYYY").endOf("day") : null;
|
const toMoment = toDate ? moment(toDate).endOf("day") : null;
|
||||||
|
|
||||||
const delayDebounceFn = setTimeout(() => {
|
const delayDebounceFn = setTimeout(() => {
|
||||||
// Nếu không có filter nào, tránh filter tốn công, gán thẳng
|
// Nếu không có filter nào, tránh filter tốn công, gán thẳng
|
||||||
|
|
@ -146,27 +146,47 @@ function DrawerLogs({
|
||||||
placeholder="Search file name"
|
placeholder="Search file name"
|
||||||
value={searchFileName}
|
value={searchFileName}
|
||||||
onChange={(event) => setSearchFileName(event.currentTarget.value)}
|
onChange={(event) => setSearchFileName(event.currentTarget.value)}
|
||||||
|
rightSection={
|
||||||
|
searchFileName ? (
|
||||||
|
<IconX
|
||||||
|
size={14}
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setSearchFileName("")}
|
||||||
|
/>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
rightSectionPointerEvents="auto"
|
||||||
size="xs"
|
size="xs"
|
||||||
/>
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={3}>
|
<Grid.Col span={3}>
|
||||||
<DateInput value={fromDate} onChange={setFromDate} placeholder="From date" valueFormat="DD/MM/YYYY" size="xs" clearable />
|
<DateInput
|
||||||
|
value={fromDate}
|
||||||
|
onChange={(value) => setFromDate(value as Date | null)}
|
||||||
|
placeholder="From date"
|
||||||
|
valueFormat="DD/MM/YYYY"
|
||||||
|
size="xs"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={3}>
|
<Grid.Col span={3}>
|
||||||
<DateInput value={toDate} onChange={setToDate} placeholder="To date" valueFormat="DD/MM/YYYY" size="xs" clearable />
|
<DateInput
|
||||||
|
value={toDate}
|
||||||
|
onChange={(value) => setToDate(value as Date | null)}
|
||||||
|
placeholder="To date"
|
||||||
|
valueFormat="DD/MM/YYYY"
|
||||||
|
size="xs"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
<ScrollArea h={"85vh"} style={{ marginBottom: "20px" }}>
|
<ScrollArea h={"85vh"} style={{ marginTop: "15px" }}>
|
||||||
<Table
|
<Table stickyHeader striped highlightOnHover withRowBorders={true} withTableBorder={true} withColumnBorders={true}>
|
||||||
stickyHeader
|
<Table.Thead
|
||||||
stickyHeaderOffset={-1}
|
style={{
|
||||||
striped
|
top: 1,
|
||||||
highlightOnHover
|
}}>
|
||||||
withRowBorders={true}
|
|
||||||
withTableBorder={true}
|
|
||||||
withColumnBorders={true}>
|
|
||||||
<Table.Thead>
|
|
||||||
<Table.Tr>
|
<Table.Tr>
|
||||||
<Table.Th style={{ width: "50%" }}>File name</Table.Th>
|
<Table.Th style={{ width: "50%" }}>File name</Table.Th>
|
||||||
<Table.Th style={{ width: "30%" }}>Created at</Table.Th>
|
<Table.Th style={{ width: "30%" }}>Created at</Table.Th>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue