mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2024-11-17 06:39:25 +08:00
Refined logs search function
This commit is contained in:
parent
5b5a699dd8
commit
9f0bbd7a66
1 changed files with 8 additions and 9 deletions
|
@ -28,7 +28,7 @@ export default function Logs() {
|
|||
(state: OldSessionState) => state.old_session_checked.value
|
||||
);
|
||||
const [searchTerm, setSearchTerm] = useState("");
|
||||
const [searchToday, setSearchToday] = useState(true);
|
||||
const [searchToday, setSearchToday] = useState("");
|
||||
function getToday() {
|
||||
const current = new Date();
|
||||
const date =
|
||||
|
@ -84,11 +84,10 @@ export default function Logs() {
|
|||
<Switch
|
||||
style={{ flex: 1 }}
|
||||
onClick={() => {
|
||||
setSearchToday(!searchToday);
|
||||
if (searchTerm != getToday()) {
|
||||
setSearchTerm(getToday());
|
||||
if (searchToday === "") {
|
||||
setSearchToday(getToday());
|
||||
} else {
|
||||
setSearchTerm("");
|
||||
setSearchToday("");
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
@ -112,7 +111,6 @@ export default function Logs() {
|
|||
}}
|
||||
value={searchTerm}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
setSearchToday(false);
|
||||
setSearchTerm(e.target.value);
|
||||
}}
|
||||
/>
|
||||
|
@ -145,9 +143,10 @@ export default function Logs() {
|
|||
{logs.data
|
||||
.filter(
|
||||
(Log: ProductLog) =>
|
||||
Log.name.toLowerCase().includes(searchTerm) ||
|
||||
(Log.name.toLowerCase().includes(searchTerm) ||
|
||||
Log.history_user.toLowerCase().includes(searchTerm) ||
|
||||
Log.history_date.toLowerCase().includes(searchTerm)
|
||||
Log.history_date.toLowerCase().includes(searchTerm)) &&
|
||||
Log.history_date.toLowerCase().includes(searchToday)
|
||||
)
|
||||
.map((row: ProductLog, index: number) => (
|
||||
<TableRow
|
||||
|
|
Loading…
Reference in a new issue