Skip to content

Commit

Permalink
Refactor lastIngestion rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
noctillion committed Nov 20, 2023
1 parent 5025155 commit a6e6fe3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/js/components/Overview/LastIngestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ import { useTranslation } from 'react-i18next';
import { DEFAULT_TRANSLATION } from '@/constants/configConstants';
import { useAppSelector } from '@/hooks';
import { getDataTypeLabel } from '@/types/dataTypes';
import { LastIngestionDataTypeResponse, DataResponseArray } from '@/types/lastIngestionDataTypeResponse';

import { LastIngestionDataTypeResponse } from '@/types/lastIngestionDataTypeResponse';

const LastIngestionInfo: React.FC = () => {
const { t, i18n } = useTranslation(DEFAULT_TRANSLATION);

const lastEndTimesByDataType: DataResponseArray = useAppSelector((state) => state.lastIngestionData?.dataTypes) || [];
const dataTypesObject = useAppSelector((state) => state.lastIngestionData?.dataTypes) || {};
const dataTypesArray = Object.values(dataTypesObject);

const sortedDataTypes = dataTypesArray.sort((a, b) => a.label.localeCompare(b.label));

const queryableDataTypes = lastEndTimesByDataType.filter((item: LastIngestionDataTypeResponse) => item.queryable);
// Filter out the queryable data types
const queryableDataTypes = sortedDataTypes.filter((dataType: LastIngestionDataTypeResponse) => dataType.queryable);

const formatDate = useCallback(
(dateString: string) => {
Expand Down Expand Up @@ -42,7 +47,7 @@ const LastIngestionInfo: React.FC = () => {
queryableDataTypes.map((dataType: LastIngestionDataTypeResponse) => (
<Card key={dataType.id}>
<Space direction="vertical">
<Typography.Text style={{ color: 'rgba(0,0,0,0.45)' }}>{getDataTypeLabel(dataType.id)}</Typography.Text>
<Typography.Text style={{ color: 'rgba(0,0,0,0.45)' }}>{t(getDataTypeLabel(dataType.id))}</Typography.Text>
<Typography.Text>
<CalendarOutlined /> {dataType.last_ingested ? formatDate(dataType.last_ingested) : 'Not Available'}
</Typography.Text>
Expand Down

0 comments on commit a6e6fe3

Please sign in to comment.