Commit 056d4711 by asranov0003

fix: filter history default to date

parent a7c21989
......@@ -31,11 +31,27 @@ const BrowserHistory: React.FC = () => {
const filterBrowserHistory = () => {
if (selectedDevice?.id) {
const from = new Date(fromDate);
const to = new Date(toDate);
const isToday = toDate === today;
if (isToday) {
const now = new Date();
to.setHours(
now.getHours(),
now.getMinutes(),
now.getSeconds(),
now.getMilliseconds()
);
} else {
to.setHours(23, 59, 59, 999);
}
dispatch(
fetchBrowserHistory({
deviceId: selectedDevice.id,
dateFrom: new Date(fromDate),
dateTo: new Date(toDate),
dateFrom: from,
dateTo: to,
recStart: 0,
})
);
......
......@@ -42,17 +42,35 @@ const Calls: React.FC = () => {
useEffect(() => {
if (selectedDevice?.id) {
filterBrowserHistory();
filterCallHistory();
}
}, [dispatch, selectedDevice]);
const filterBrowserHistory = () => {
const filterCallHistory = () => {
if (selectedDevice?.id) {
const from = new Date(fromDate);
const to = new Date(toDate);
const todayStr = new Date().toISOString().split("T")[0];
const isToday = toDate === todayStr;
if (isToday) {
const now = new Date();
to.setHours(
now.getHours(),
now.getMinutes(),
now.getSeconds(),
now.getMilliseconds()
);
} else {
to.setHours(23, 59, 59, 999);
}
dispatch(
fetchCallHistory({
deviceId: selectedDevice.id,
dateFrom: new Date(fromDate),
dateTo: new Date(toDate),
dateFrom: from,
dateTo: to,
recStart: 0,
})
);
......@@ -125,7 +143,7 @@ const Calls: React.FC = () => {
<CButton
title={t("button.search")}
onClick={filterBrowserHistory}
onClick={filterCallHistory}
isLoading={loading}
/>
</div>
......
......@@ -30,12 +30,30 @@ const Messengers: React.FC = () => {
const fetchMessengerHistories = () => {
if (selectedDevice?.id) {
const from = new Date(fromDate);
const to = new Date(toDate);
const today = new Date().toISOString().split("T")[0];
const isToday = toDate === today;
if (isToday) {
const now = new Date();
to.setHours(
now.getHours(),
now.getMinutes(),
now.getSeconds(),
now.getMilliseconds()
);
} else {
to.setHours(23, 59, 59, 999);
}
dispatch(
fetchMessengerHistory({
deviceId: selectedDevice.id,
messengerId: selectedMessenger.id,
dateFrom: new Date(fromDate),
dateTo: new Date(toDate),
dateFrom: from,
dateTo: to,
recStart: 0,
})
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment