TP-51644 | resolving PR commits
This commit is contained in:
@@ -11,7 +11,8 @@ import { Button } from '@navi/web-ui/lib/primitives';
|
||||
|
||||
import useClickStream from '@src/services/clickStream';
|
||||
import { CLICK_STREAM_EVENT_FACTORY } from '@src/services/clickStream/constants/values';
|
||||
|
||||
import { formatDate } from '@src/services/globalUtils';
|
||||
import { DATE_FORMAT } from '@src/services/constants';
|
||||
export interface DateProps {
|
||||
clearSearchValue: () => void;
|
||||
updateURLAndFetchData: (payload: string) => void;
|
||||
@@ -65,27 +66,27 @@ const Date: React.FC<DateProps> = ({
|
||||
};
|
||||
|
||||
const formatDates = (start_date, end_date) => {
|
||||
const formatDate = date => {
|
||||
const [day, month, year] = date.split('/');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
const fromDate = dayjs(start_date).startOf('day');
|
||||
const toDate = dayjs(end_date).endOf('day');
|
||||
|
||||
const fromDate = dayjs(formatDate(start_date)).startOf('day');
|
||||
const toDate = dayjs(formatDate(end_date)).endOf('day');
|
||||
const formattedFromDate = fromDate.format(DATE_FORMAT);
|
||||
const formattedToDate = toDate.format(DATE_FORMAT);
|
||||
|
||||
const startDateUTC = dayjs(formattedFromDate).utc().format('');
|
||||
const endDateUTC = dayjs(formattedToDate).utc().format('');
|
||||
return {
|
||||
formattedFromDate: fromDate.utc().format('YYYY-MM-DD HH:mm:ss'),
|
||||
formattedToDate: toDate.utc().format('YYYY-MM-DD HH:mm:ss'),
|
||||
formattedFromDate: startDateUTC,
|
||||
formattedToDate: endDateUTC,
|
||||
};
|
||||
};
|
||||
|
||||
const handleApplyClick = () => {
|
||||
fireEvent(EVENT_NAME.Houston_Check_DateFilter, {
|
||||
screen_name: SCREEN_NAME.DASHBOARD_PAGE,
|
||||
});
|
||||
|
||||
if (date?.length === 2) {
|
||||
const [start_date, end_date] = date;
|
||||
let [start_date, end_date] = date;
|
||||
start_date = formatDate(start_date);
|
||||
end_date = formatDate(end_date);
|
||||
const { formattedFromDate, formattedToDate } = formatDates(
|
||||
start_date,
|
||||
end_date,
|
||||
@@ -101,7 +102,6 @@ const Date: React.FC<DateProps> = ({
|
||||
}
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles['date-wrapper']}>
|
||||
<ConfigProvider
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export const JANUS_API = `/events`;
|
||||
export const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
@@ -57,3 +57,7 @@ export const handleCopyClick = (textToCopy: string): void => {
|
||||
export const createURL = (endpoint: string): string => {
|
||||
return `${window?.config?.BASE_API_URL}${endpoint}`;
|
||||
};
|
||||
export const formatDate = (date: string) => {
|
||||
const [day, month, year] = date.split('/');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user