Skip to content

Commit

Permalink
fix date filtering issue on table
Browse files Browse the repository at this point in the history
  • Loading branch information
zuies committed Feb 9, 2024
1 parent 1cd093d commit 4a9817c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/announcements/TcAnnouncementsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useSnackbar } from '../../context/SnackbarContext';
import { MdModeEdit, MdDelete } from 'react-icons/md';
import Loading from '../global/Loading';
import { truncateCenter } from '../../helpers/helper';
import moment from 'moment';

interface Channel {
channelId: string;
Expand Down Expand Up @@ -61,12 +62,14 @@ interface Announcement {
interface AnnouncementsTableProps {
announcements: Announcement[];
isLoading: boolean;
selectedZone: string;
handleRefreshList: () => void;
}

function TcAnnouncementsTable({
announcements,
isLoading,
selectedZone,
handleRefreshList,
}: AnnouncementsTableProps) {
const { deleteAnnouncements } = useAppStore();
Expand All @@ -78,6 +81,13 @@ function TcAnnouncementsTable({
string | null
>(null);

const formatDateBasedOnTimezone = (
date: string | number | Date,
timezone: string
) => {
return moment(date).tz(timezone).format('DD/MM/YYYY, h:mm:ss a');
};

const handleClick = (
event: React.MouseEvent<HTMLButtonElement>,
id: string
Expand Down Expand Up @@ -278,7 +288,10 @@ function TcAnnouncementsTable({
return (
<div className="flex flex-row overflow-hidden whitespace-nowrap">
<TcText
text={new Date(announcement.scheduledAt).toLocaleString()}
text={formatDateBasedOnTimezone(
announcement.scheduledAt,
selectedZone
)}
variant="subtitle2"
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/announcements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ function Index() {
}
handleRefreshList={fetchData}
isLoading={loading}
selectedZone={selectedZone}
/>
</div>
) : (
Expand Down

0 comments on commit 4a9817c

Please sign in to comment.