Skip to content

Commit

Permalink
Bug #224665 - Date filter is not working on poll list page
Browse files Browse the repository at this point in the history
  • Loading branch information
sonaliTekdi committed Sep 25, 2024
1 parent 6e102fa commit 6be1c60
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions packages/nulp_elite/src/pages/voting/votingList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import FloatingChatIcon from "components/FloatingChatIcon";
const urlConfig = require("../../configs/urlConfig.json");
import { useTranslation } from "react-i18next";
import { Loading } from "@shiksha/common-lib";
import dayjs from "dayjs";

const VotingList = () => {
const [toasterOpen, setToasterOpen] = useState(false);
Expand All @@ -42,22 +43,17 @@ const VotingList = () => {
selectedEndDate: null,
status: ["Live"],
});

const [finalFilters, setFinalFilters] = useState({});

const handleFilterChange = (newFilters) => {
const formatDateToISO = (dateStr) => {
const localDate = new Date(dateStr);
localDate.setUTCHours(0, 0, 0, 0);
return localDate.toISOString();
};

const formattedFilters = {
...newFilters,
selectedStartDate: newFilters.selectedStartDate
? formatDateToISO(newFilters.selectedStartDate)
? dayjs(newFilters.selectedStartDate).format("YYYY-MM-DD")
: null,
selectedEndDate: newFilters.selectedEndDate
? formatDateToISO(newFilters.selectedEndDate)
? dayjs(newFilters.selectedEndDate).format("YYYY-MM-DD")
: null,
};
setFilters(formattedFilters);
Expand Down Expand Up @@ -257,4 +253,4 @@ const VotingList = () => {
);
};

export default VotingList;
export default VotingList;

0 comments on commit 6be1c60

Please sign in to comment.