mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2024-11-16 22:29:24 +08:00
Moved get date today to separate component
This commit is contained in:
parent
9f0bbd7a66
commit
7dc3729bec
2 changed files with 13 additions and 12 deletions
11
src/Components/LogsPage/GetToday/GetToday.tsx
Normal file
11
src/Components/LogsPage/GetToday/GetToday.tsx
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
export default function GetToday() {
|
||||||
|
const current = new Date();
|
||||||
|
const date =
|
||||||
|
("0" + (current.getMonth() + 1)).slice(-2) +
|
||||||
|
"-" +
|
||||||
|
("0" + current.getDate()).slice(-2) +
|
||||||
|
"-" +
|
||||||
|
current.getFullYear();
|
||||||
|
console.log("Today is " + date);
|
||||||
|
return date;
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import {
|
||||||
} from "../../Interfaces/Interfaces";
|
} from "../../Interfaces/Interfaces";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
import GetToday from "../../Components/LogsPage/GetToday/GetToday";
|
||||||
|
|
||||||
export default function Logs() {
|
export default function Logs() {
|
||||||
const logs = useQuery("logs", GetLogs, { retry: 0 });
|
const logs = useQuery("logs", GetLogs, { retry: 0 });
|
||||||
|
@ -29,17 +30,6 @@ export default function Logs() {
|
||||||
);
|
);
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
const [searchToday, setSearchToday] = useState("");
|
const [searchToday, setSearchToday] = useState("");
|
||||||
function getToday() {
|
|
||||||
const current = new Date();
|
|
||||||
const date =
|
|
||||||
("0" + (current.getMonth() + 1)).slice(-2) +
|
|
||||||
"-" +
|
|
||||||
("0" + current.getDate()).slice(-2) +
|
|
||||||
"-" +
|
|
||||||
current.getFullYear();
|
|
||||||
console.log("Today is " + date);
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
if (logs.isLoading || !old_session_checked) {
|
if (logs.isLoading || !old_session_checked) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -85,7 +75,7 @@ export default function Logs() {
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (searchToday === "") {
|
if (searchToday === "") {
|
||||||
setSearchToday(getToday());
|
setSearchToday(GetToday());
|
||||||
} else {
|
} else {
|
||||||
setSearchToday("");
|
setSearchToday("");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue