Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions client/src/components/updates/UpdatesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { EmptyStateBadge } from '@/components/badges/EmptyStateBadge';
import { useTranslation } from 'react-i18next';

import { AccountUpdatesTable } from './AccountUpdatesTable';
import { programSectionColumns } from './config/updatesColumnConfig';
import {
mediaSectionColumns,
programSectionColumns,
} from './config/updatesColumnConfig';
import {
UpdatesFilterPopover,
UpdatesSearchInput,
Expand Down Expand Up @@ -53,6 +56,15 @@ export const UpdatesPage = () => {

const [searchQuery, setSearchQuery] = useState('');
const [tabIndex, setTabIndex] = useState(0);
const [activeFilters, setActiveFilters] = useState([]);

const handleTabChange = (index) => {
setTabIndex(index);
setActiveFilters([]);
};

const filterColumns =
tabIndex === 1 ? mediaSectionColumns : programSectionColumns;

const handleDownload = () => {
if (tabIndex === 0) downloadProgramUpdatesAsCsv(programUpdatesData, t);
Expand Down Expand Up @@ -93,8 +105,8 @@ export const UpdatesPage = () => {
onChange={setSearchQuery}
/>
<UpdatesFilterPopover
columns={programSectionColumns}
onFilterChange={() => {}}
columns={filterColumns}
onFilterChange={setActiveFilters}
/>
</Flex>
);
Expand Down Expand Up @@ -134,7 +146,7 @@ export const UpdatesPage = () => {
</Flex>
<Tabs
index={tabIndex}
onChange={setTabIndex}
onChange={handleTabChange}
variant="unstyled"
>
<Flex
Expand Down Expand Up @@ -190,6 +202,7 @@ export const UpdatesPage = () => {
isLoading={isLoading}
onSave={refetchProgramUpdates}
searchQuery={searchQuery}
activeFilters={activeFilters}
showStatus
showFlagAndType
embedded
Expand All @@ -216,6 +229,7 @@ export const UpdatesPage = () => {
originalData={originalMediaUpdatesData}
isLoading={isLoading}
searchQuery={searchQuery}
activeFilters={activeFilters}
embedded
/>
</Box>
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/updates/config/useUpdatesPageData.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const mapUpdatesWithFullName = (items) => {
.filter(Boolean)
.join(' ')
.trim();
return { ...item, fullName };
const status = item.status ?? (item.resolved ? 'Resolved' : 'Unresolved');
return { ...item, fullName, status };
});
};

Expand Down
17 changes: 14 additions & 3 deletions client/src/contexts/hooks/TableFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { useEffect, useRef, useState } from 'react';

const str = (v) => (v ?? '').toString();

const toDateStr = (v) => {
const d = new Date(v);
return isNaN(d.getTime()) ? null : d.toISOString().slice(0, 10);
};

const OPERATION_FUNCTIONS = {
contains: (dataVal, filterVal) =>
str(dataVal).toLowerCase().includes(str(filterVal).toLowerCase()),
Expand All @@ -14,9 +19,15 @@ const OPERATION_FUNCTIONS = {
gte: (dataVal, filterVal) => Number(dataVal) >= Number(filterVal),
lte: (dataVal, filterVal) => Number(dataVal) <= Number(filterVal),
is: (dataVal, filterVal) =>
new Date(dataVal).getTime() === new Date(filterVal).getTime(),
before: (dataVal, filterVal) => new Date(dataVal) < new Date(filterVal),
after: (dataVal, filterVal) => new Date(dataVal) > new Date(filterVal),
toDateStr(dataVal) !== null && toDateStr(dataVal) === toDateStr(filterVal),
before: (dataVal, filterVal) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: the "before" filter for update date doesn't work in some cases and displays updates made after and on the same day as the selected date.

Image

toDateStr(dataVal) !== null &&
toDateStr(filterVal) !== null &&
toDateStr(dataVal) < toDateStr(filterVal),
after: (dataVal, filterVal) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix: the "after" filter for update time doesn't work in some cases and still displays program updates from before and on the same day as the selected date.

Image Image

toDateStr(dataVal) !== null &&
toDateStr(filterVal) !== null &&
toDateStr(dataVal) > toDateStr(filterVal),
contains_item: (dataVal, filterVal) =>
dataVal.some((item) =>
str(item).toLowerCase().includes(str(filterVal).toLowerCase())
Expand Down