Commit 056d4711 by asranov0003

fix: filter history default to date

parent a7c21989
...@@ -31,11 +31,27 @@ const BrowserHistory: React.FC = () => { ...@@ -31,11 +31,27 @@ const BrowserHistory: React.FC = () => {
const filterBrowserHistory = () => { const filterBrowserHistory = () => {
if (selectedDevice?.id) { 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( dispatch(
fetchBrowserHistory({ fetchBrowserHistory({
deviceId: selectedDevice.id, deviceId: selectedDevice.id,
dateFrom: new Date(fromDate), dateFrom: from,
dateTo: new Date(toDate), dateTo: to,
recStart: 0, recStart: 0,
}) })
); );
......
...@@ -42,17 +42,35 @@ const Calls: React.FC = () => { ...@@ -42,17 +42,35 @@ const Calls: React.FC = () => {
useEffect(() => { useEffect(() => {
if (selectedDevice?.id) { if (selectedDevice?.id) {
filterBrowserHistory(); filterCallHistory();
} }
}, [dispatch, selectedDevice]); }, [dispatch, selectedDevice]);
const filterBrowserHistory = () => { const filterCallHistory = () => {
if (selectedDevice?.id) { 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( dispatch(
fetchCallHistory({ fetchCallHistory({
deviceId: selectedDevice.id, deviceId: selectedDevice.id,
dateFrom: new Date(fromDate), dateFrom: from,
dateTo: new Date(toDate), dateTo: to,
recStart: 0, recStart: 0,
}) })
); );
...@@ -125,7 +143,7 @@ const Calls: React.FC = () => { ...@@ -125,7 +143,7 @@ const Calls: React.FC = () => {
<CButton <CButton
title={t("button.search")} title={t("button.search")}
onClick={filterBrowserHistory} onClick={filterCallHistory}
isLoading={loading} isLoading={loading}
/> />
</div> </div>
......
...@@ -30,12 +30,30 @@ const Messengers: React.FC = () => { ...@@ -30,12 +30,30 @@ const Messengers: React.FC = () => {
const fetchMessengerHistories = () => { const fetchMessengerHistories = () => {
if (selectedDevice?.id) { 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( dispatch(
fetchMessengerHistory({ fetchMessengerHistory({
deviceId: selectedDevice.id, deviceId: selectedDevice.id,
messengerId: selectedMessenger.id, messengerId: selectedMessenger.id,
dateFrom: new Date(fromDate), dateFrom: from,
dateTo: new Date(toDate), dateTo: to,
recStart: 0, 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